Forum

> > CS2D > Scripts > Zombie script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Zombie script

21 replies
Page
To the start Previous 1 2 Next To the start

old Zombie script

Autumn
User Off Offline

Quote
Hi guys.
Help create script.When the health zombies is below 30%, he teleports to the player who attacked him and explodes!

old Re: Zombie script

archmage
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
function __hit(id, s)
	-- check if player is zombie and if health is below 30
	if ( player(id, "team") == 1 and player(id, "health") < 30 ) then
		-- get source player's pos
		local x, y = player(s, "x"), player(s, "y")
		-- teleport zombie
		parse("setpos "..id.." "..x.." "..y)
		-- explosion
		parse("explosion "..x.." "..y.." 100 50 "..id)
	end
end
addhook("hit", "__hit")

old Thanks!

Autumn
User Off Offline

Quote
Thanks it works.But can this script to bind to specific zombies, for example with the name LOL.And so when you create a server that zombies appear with the name LOL.

old Re: Zombie script

archmage
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
function __hit(id, s)
     -- check if player is zombie and if health is below 30
     if ( player(id, "team") == 1 and player(id, "health") < 30 and player(id, "name") == "LOL" ) then
          -- get source player's pos
          local x, y = player(s, "x"), player(s, "y")
          -- teleport zombie
          parse("setpos "..id.." "..x.." "..y)
          -- explosion
          parse("explosion "..x.." "..y.." 100 50 "..id)
     end
end
addhook("hit", "__hit")

old Re: Zombie script

archmage
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
function __hit(id, s)
     -- check if player is zombie and if health is below 30
     if ( player(id, "team") == 1 and player(id, "health") < 30 and player(id, "bot") ) then
          -- get source player's pos
          local x, y = player(s, "x"), player(s, "y")
          -- teleport zombie
          parse("setpos "..id.." "..x.." "..y)
          -- explosion
          parse("explosion "..x.." "..y.." 100 50 "..id)
     end
end
addhook("hit", "__hit")
If you want the script to only affect bots use this code.

old Re: Zombie script

Autumn
User Off Offline

Quote
The game is not a bot with the name LoL, how to change the name of the bot LoL=)?

old Re: Zombie script

Avo
User Off Offline

Quote
Open names.txt file from bots folder.
At user archmage reply: you must check if player exists, otherwise cs2d would get position of not existing player, what lead to bugs. (teleport to random position for example).

old Re: Zombie script

Avo
User Off Offline

Quote
Nope. You just can chceck if player name´s first 3 chars are "LoL". Changing name during game is not a good idea.

old Re: Zombie script

Autumn
User Off Offline

Quote
I decided not to create a new topic and write here.
Help create script.When a player moves on the tile # 20, the image is removed, but when to leave the tile # 20, the image is back!

old Re: Zombie script

MikuAuahDark
User Off Offline

Quote
user Autumn has written
When a player moves on the tile # 20, the image is removed, but when to leave the tile # 20, the image is back!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
imgs={}
for id = 1,32 do
imgs[id]=0
end

addhook("movetile","_movetile")
function movetile(id,tx,ty)
	if tile(tx,ty,"frame")~=20 then
		if imgs[id]==0 then
			imgs[id]=image("imagepath",1,0,132+id)
		end
	elseif tile(tx,ty,"frame")==20 then
		if imgs[id]>0 then
			freeimage(imgs[id])
			imgs[id]=0
		end
	end
end

old Re: Zombie script

EngiN33R
Moderator On Online

Quote
user Avo has written
Nope. You just can chceck if player name´s first 3 chars are "LoL". Changing name during game is not a good idea.


How so?

1
parse("setname "..botid.." LOL")

That will change the name of the bot, provided you replace botid with an actual variable. Not much voodoo involved, and it won't break the game.

Oh, and please, create a new thread for each question with a title describing the question itself. It will be better for everyone that way.

old Re: Zombie script

Avo
User Off Offline

Quote
7749 has written
Not much voodoo involved, and it won't break the game.

Voodoo, I lol'd.

user EngiN33R, yes, creating new threads is better to find in forum answer for question, asked some time ago.

old Re: Zombie script

Autumn
User Off Offline

Quote
How to add tiles to this script?I need tile#114 and tile#85
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
imgs={}
for id = 1,32 do
imgs[id]=0
end

addhook("movetile","_movetile")
function _movetile(id,tx,ty)
     if tile(tx,ty,"frame")~=20 then
          if imgs[id]==0 then
               imgs[id]=image("imagepath",1,0,132+id)
          end
     elseif tile(tx,ty,"frame")==20 then
          if imgs[id]>0 then
               freeimage(imgs[id])
               imgs[id]=0
          end
     end
end

old Re: Zombie script

MikuAuahDark
User Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
imgs={}
for id = 1,32 do
imgs[id]=0
end

tilepenghilang = {114,85}

addhook("movetile","_movetile")
function _movetile(id,tx,ty)
	for _, tiles in pairs(tilepenghilang) do
		if tile(tx,ty,"frame")~=tiles then
			if imgs[id]==0 then
				imgs[id]=image("imagepath",1,0,132+id)
			end
		elseif tile(tx,ty,"frame")==tiles then
			if imgs[id]>0 then
				freeimage(imgs[id])
				imgs[id]=0
			end
		end
	end
end
if you want to add more tileID(frame) just add it at "tilepenghilang" table, separated by comma
EDIT: Fixed bugs
edited 1×, last 17.07.12 01:52:15 pm
To the start Previous 1 2 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview