Forum

> > CS2D > Scripts > I need bot level system
Forums overviewCS2D overview Scripts overviewLog in to reply

English I need bot level system

7 replies
To the start Previous 1 Next To the start

old Re: I need bot level system

Rainoth
Moderator Off Offline

Quote
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
exp = {}

addhook("kill","_k")
function _k(k,v)
	if player(k,"bot") then
		exp[k] = exp[k] + 1
		parse("setmaxhealth "..k.." "..player(k,"maxhealth)+math.floor(exp[k]/10))
	end
end

addhook("spawn","_s")
function _s(id)
	if player(id,"bot") then
		parse("sethealth "..id.." "..player(id,"maxhealth")
	end
end

Every 10 kills the bot will gain max health.
You can make other things. Just check
if exp[id] >= 50 then

or any other number. That way you can make explicit stats. For example "if bot has more than 50 kills then set his armor to 150" or anything else you want.

old Re: I need bot level system

GeoB99
Moderator Off Offline

Quote
Think on this way:
The Pseudo Code >

Note that this is a pseudo code and not an actual Lua code. I only gave you a little and basic representation of how a save/load system for bots works. For this case, our main hooks are cs2d lua hook join and cs2d lua hook leave with the conjunction with I/O library functions of Lua. For these functions and their documentation you can find them at this website. This Lua pil (Click me!) also gives a great explanation of how you use them.

I would also recommend the cs2d lua hook minute hook to trigger occasionally the save system for the sake of the data not being lost during a map change (since the leave and map change events are obviously two different things).

old Re: I need bot level system

Masea
Super User Off Offline

Quote
@user GeoB99: You are trying to teach everytime the Lua. Good guy. However, the thing is, they will never understand them. Giving prepared code would be better.

old Re: I need bot level system

GeoB99
Moderator Off Offline

Quote
@user Masea: Couldn't agree more. A person understands better when he/she creates his/her own stuff. Imagine when people ask here every time "I need an armor menu script, I need this I need that etc. etc." and we'll be going to give a Lua code. A fully working one. Eventually they are satisfied but let me ask you a question, do they understand how the Lua code specific works? I bet they don't.

This of course it doesn't apply to every user demanding for a Lua code but it's also not pleasant to see people asking every time for scripts without even understanding the basics.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview