Forum

> > CS2D > Scripts > How to spawn a projectile?
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to spawn a projectile?

14 replies
To the start Previous 1 Next To the start

moved How to spawn a projectile?

Louie
User Off Offline

Quote
I've seen in some maps that when u "Use" something(like a button) then a projectile will spawn at a location,how do i do that?

old Re: How to spawn a projectile?

Louie
User Off Offline

Quote
I opened one of my favorite maps in the editor and this is what i saw to spawn the projectile(it was a Trigger_If entity) parse('spawnprojectile 0 47 2736 3760 448 0') tho,i dont know what all those numbers mean lol,can someone please explain that.
edited 1×, last 30.12.14 05:28:42 pm

old Re: How to spawn a projectile?

DC
Admin Off Offline

Quote
The map editor shows the tile position in the bottom left as small text. The first number is x, the second y. Multiply each with 32 to get the position in pixels (because each tile has a size of 32 pixels). This is the top left of the tile you are currently pointing at with your cursor. Add another 16 pixels to x and y to get the center position of that tile.

old Re: How to spawn a projectile?

Louie
User Off Offline

Quote
Thx guys now I know how to do it
EDIT: Though when i want it to spawn a Laser projectile(from the Laser gun) it doesn't shoot a projectile,it throws a Laser gun lol and also last question,how do i make it to spawn a projectile at a random angle?
edited 2×, last 31.12.14 09:42:10 am

old Re: How to spawn a projectile?

hacked
User Off Offline

Quote
You can't shoot laser projectile through lua, but you can create your own laser with env_sprite and env_hurt.

EDIT:
Oh and for the random angle:
1
'spawnprojectile 0 47 2736 3760 448 math.random(0, 360)'

old Re: How to spawn a projectile?

Mora
User Off Offline

Quote
@topic:
goto your cs2d folder,
open sys/lua/samples/projectiles.lua <-open it by any txt editor..
@ot
Can i ask?-because topic about projectiles:
i have array, i have kill hook:
if i kill players with any weapon that attacks bullets, i got +1 array.
if i kill players with any weapon that attacks projectiles (hegren,GL,RL,RPG), i got nothing..
just nothing..
maybe something wrong?:
1
2
3
4
5
6
7
8
9
10
function at_kill(id)
local wwp = player(id,"weapontype")
	if wwp==2 then
uspZ[id] = uspZ[id] >= 6 and 6 or uspZ[id] + 1
if uspZ[id] == 5 then uspZ[id] = 6 end
	elseif wwp==51 then
rocketZ[id] = rocketZ[id] >= 6 and 6 or rocketZ[id] + 1
if rocketZ[id] == 5 then rocketZ[id] = 6 end
	end
end

old Re: How to spawn a projectile?

eledah
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
function at_kill(killer, victim, wep)
	if   wep~=47 and wep~=48 and wep~=49 and
		wep~=51 and wep~=72 and wep~=73 and 
		wep~=75 and wep~=76 and wep~=86 and 
		wep~=89 then
		--Killed with normal weps
	else
		--Killed with projectile type weps
	end
end

old Re: How to spawn a projectile?

Mora
User Off Offline

Quote
@user eledah: i have array of ALL weapons, and as you can see:
uspZ is only first array using, the next one is elite, the next is deagle. isn't means that they all using one array,-not, it's like a stats.. but it possible to do it for any projectile weapons personaly?= means if that id 47 then i do for it array:
rpgZ = arraybalalba, so, the next will be like in my code for bullets weapon.
and note: i mean not that i need for projectiles will do nothing, i mean that if i try to do same as with bullet weapons - nothing happened, i need fix that "nothing happened or buggy when i kill from projetile bullets weapons".
Hope is understandable. Sorry my english

old Re: How to spawn a projectile?

Louie
User Off Offline

Quote
user hacked has written
You can't shoot laser projectile through lua, but you can create your own laser with env_sprite and env_hurt.

EDIT:
Oh and for the random angle:
1
'spawnprojectile 0 47 2736 3760 448 math.random(0, 360)'

it doesn't work it shoot a projectile but it explodes just after the projectile was launched heres what i did
parse('spawnprojectile 0 47 432 825 500 math.random(150, 230') though it doesn't work(the random thing)
edited 1×, last 01.01.15 05:27:05 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview