Forum

> > CS2D > Scripts > Dispenser infinite health
Forums overviewCS2D overview Scripts overviewLog in to reply

English Dispenser infinite health

8 replies
To the start Previous 1 Next To the start

old Dispenser infinite health

Mami Tomoe
User Off Offline

Quote
Hi my problem is simple I just want the dispenser to have infinite health using the
mp_building_health
command.

Thanks

I made this and it doesn't work:
1
2
3
4
5
6
7
8
9
10
11
12
addhook("second","map_second")
function map_second()
	if lessfrog==true then
		parse("mp_building_health Dispenser 9999")
		parse("mp_dispenser_health 6")
		parse("mp_dispenser_money 0")
	else
		parse("mp_building_health Dispenser 800")
		parse("mp_dispenser_health 10")
		parse("mp_dispenser_money 100")
	end
end

old Re: Dispenser infinite health

Rainoth
Moderator Off Offline

Quote
Well, you shouldn't do this in second hook. Instead you should parse those commands when "lessfrog" becomes true or false.

Apart from that, everything seems fine which means that the only thing that could screw up your code is 'lessfrog' being false all the time.

old Re: Dispenser infinite health

Mami Tomoe
User Off Offline

Quote
lessfrog is a boss in a map and when it becomes true all dispensers will have 1% HP but act as if their HP was never changed at all (800HP)

You should try it, it's weird...

old Re: Dispenser infinite health

Rainoth
Moderator Off Offline

Quote
OH, I get what you're trying to do. That's a completely wrong approach.
The cs2d command cs2d cmd mp_building_health changes the maximum amount of health that buildings have.

So if you want objects to have unchanged health but be at 1% you'll have to increase the dispenser health and then reduce it with cs2d cmd damageobject

I'll give you an example:

Normal Object Health - 100 (100%)
Boss Spawns
Normal Object Health - 100 (1% as the max health it can have is 10000)

I guess something like this (put it where the boss spawns)

1
2
3
4
5
6
parse("mp_building_health Dispenser 9999")
for k,v in pairs (object(0,"table")) do
	if v.type == 7 then
		parse("damageobject "..v.." 9900 0")
	end
end

and then put this where the boss is killed
1
parse("mp_buildinghealth Dispenser 99")

old Re: Dispenser infinite health

Mami Tomoe
User Off Offline

Quote
I just want the dispenser to have infinite health when lessfrog is true and back to normal when its false.
I don't care for the % or anything else...

old Re: Dispenser infinite health

Mami Tomoe
User Off Offline

Quote
1
2
3
4
5
6
addhook("objectdamage","objectdamage")
function objectdamage(id,damage,player)
	if id == 7 and lessfrog==true then
		return 1
	end
end

Is this right?

old Re: Dispenser infinite health

Waldin
User Off Offline

Quote
1
2
3
4
5
6
addhook("objectdamage","objectdamage")
function objectdamage(id)
	if object(id,"type")==7 and lessfrog then
		return 1
	end
end
cs2d lua hook objectdamage's first parameter is the DYNAMIC object id, so you need use cs2d lua cmd object function to check the type id.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview