Forum

> > CS2D > Scripts > Zombie script
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Zombie script

21 Antworten
Seite
Zum Anfang Vorherige 1 2 Nächste Zum Anfang

alt Zombie script

Autumn
User Off Offline

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

alt Re: Zombie script

archmage
User Off Offline

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

alt Thanks!

Autumn
User Off Offline

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

alt Re: Zombie script

archmage
User Off Offline

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

alt Re: Zombie script

archmage
User Off Offline

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

alt Re: Zombie script

Autumn
User Off Offline

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

alt Re: Zombie script

Avo
User Off Offline

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

alt Re: Zombie script

Avo
User Off Offline

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

alt Re: Zombie script

Autumn
User Off Offline

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

alt Re: Zombie script

MikuAuahDark
User Off Offline

Zitieren
user Autumn hat geschrieben
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

alt Re: Zombie script

EngiN33R
Moderator Off Offline

Zitieren
user Avo hat geschrieben
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.

alt Re: Zombie script

Avo
User Off Offline

Zitieren
7749 hat geschrieben
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.

alt Re: Zombie script

Autumn
User Off Offline

Zitieren
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

alt Re: Zombie script

MikuAuahDark
User Off Offline

Zitieren
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
1× editiert, zuletzt 17.07.12 13:52:15
Zum Anfang Vorherige 1 2 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht