Forum

> > CS2D > Scripts > How to create Zombie Kamikaze
Forums overviewCS2D overview Scripts overviewLog in to reply

English How to create Zombie Kamikaze

6 replies
To the start Previous 1 Next To the start

old How to create Zombie Kamikaze

3MSC
User Off Offline

Quote
Please may give me the script of a zombie kamikaze for people who understand lua, I do not think it difficult for them ,
remember it is for the zombie 1.15 simonas

I just need the dying zombie spawns gut bombs

I hope your answers and thanks in advance.

old Re: How to create Zombie Kamikaze

GeoB99
Moderator Off Offline

Quote
Whenever a kamikaze dies, cs2d lua hook die certainly would do the job. In the die hook, firstly you must create a "for" loop which we'll index it to i and its value as 1, 360 (we'll use it as rotation in degrees). Afterwards, use cs2d lua cmd parse to trigger cs2d cmd spawnprojectile. To spawn gut bombs, its ID projectile type is 86 (for further information about spawnprojectile parameters, check the reference). If you want a direct example then look at this line of code below:
1
parse("spawnprojectile " .. id .. " 86 " .. player(id, "x") .. " " .. player(id, "y") .. " 25 " .. i)
As you can see in the last part where's .. i , it's the index of "for" loop which describes the rotation in degrees of those projectiles as explained above. Now, half of this work is done with the exception of how to implement it in user SQ' Zombie Plague script. Unfortunately, I cannot give you a solution into this as I'm not really savvy on how Simonas' zombie script works (judging from coding terms).

Maybe try to check for a file named zp_func.lua or something similar, check the line where it has the function of cs2d lua hook die and try somehow to make a statement if the zombie is truly kamikaze and if he's dead then the function will trigger. Blind guess.

old Re: How to create Zombie Kamikaze

3MSC
User Off Offline

Quote
good first intenatre I get out normally with the normal functions ... to see if someone tells me I did wrong


1
2
3
4
addhook("die","die")
function die(id)
parse("spawnprojectile " .. id .. " 86 " .. player(id, "x") .. " " .. player(id, "y") .. " 25 " .. i)
end

old Re: How to create Zombie Kamikaze

GeoB99
Moderator Off Offline

Quote
@user Headache: And it has to do the FAQ with what's related about this? I guess you should re-read the topic again.

@user 3MSC: Some things are actually forgotten and I am fairly sure you didn't read carefully what I explained about (especially the for loop thingy):

• The snippet of code doesn't have the Code tag in it. I added it anyway.
• The for loop isn't there therefor CS2D will trigger an error either the i is a nil value so it doesn't exist or it's a global variable that still doesn't exist.
• The function name SHOULDN'T be same as the hook name one. Keep that in mind!
• You didn't tab the code which makes the code itself ugly to read. Always tab your code to make it clean to read for other people.

With that said, this is how it should look (check the correct one below).
1
2
3
4
5
6
7
addhook("die","dieHook")

function dieHook(id)
	for i = 1, 360 do
		parse("spawnprojectile " .. id .. " 86 " .. player(id, "x") .. " " .. player(id, "y") .. " 25 " .. i)
	end
end

old Re: How to create Zombie Kamikaze

3MSC
User Off Offline

Quote
above all forgiveness , I know what hise wrong but I put mie part and try to improve with the issue of lua always read tutorials and stuff, but still not handling well the basics

But thank you very much

Thanks for the patience

I will try to improve !

Admin/mod comment

You posted same phrase twice. Removed! Also, seems like you're using a translator. /ZxC Rules §4.1 - Use proper, understandable language. No dialects / translation tools.

old Re: How to create Zombie Kamikaze

Zeik
User Off Offline

Quote
A little modification:
1
2
3
4
5
6
7
8
9
addhook("die","dieHook")

function dieHook(id)
   if player(id, "team") == 1 then
      for i = 0, 7 do
         parse("spawnprojectile " .. id .. " 86 " .. player(id, "x") .. " " .. player(id, "y") .. " 25 " .. i*45)
      end
   end
end

(checks if the player is a zombie and spawns 8 projectiles instead of 360)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview