Forum

> > CS2D > Scripts > How to spawn a projectile?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch How to spawn a projectile?

14 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

verschoben How to spawn a projectile?

Louie
User Off Offline

Zitieren
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?

alt Re: How to spawn a projectile?

Louie
User Off Offline

Zitieren
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.
1× editiert, zuletzt 30.12.14 17:28:42

alt Re: How to spawn a projectile?

DC
Admin Off Offline

Zitieren
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.

alt Re: How to spawn a projectile?

Louie
User Off Offline

Zitieren
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?
2× editiert, zuletzt 31.12.14 09:42:10

alt Re: How to spawn a projectile?

hacked
User Off Offline

Zitieren
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)'

alt Re: How to spawn a projectile?

Mora
User Off Offline

Zitieren
@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

alt Re: How to spawn a projectile?

eledah
User Off Offline

Zitieren
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

alt Re: How to spawn a projectile?

Mora
User Off Offline

Zitieren
@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

alt Re: How to spawn a projectile?

Louie
User Off Offline

Zitieren
user hacked hat geschrieben
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)
1× editiert, zuletzt 01.01.15 05:27:05
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht