Forum

> > CS2D > Scripts > Return breakable entity Health
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Return breakable entity Health

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Return breakable entity Health

Promaster
User Off Offline

Zitieren
I wonder if there is any hook which returns breakable entitys health when a player are attacking a breakable entity?

If there is no addhook for that, can anyone develope a function for me that can returns breakable entity health when a player are attacking the entity?
1× editiert, zuletzt 12.12.17 17:11:34

alt Re: Return breakable entity Health

VaiN
User Off Offline

Zitieren
This should help you get started.

You can check if an entity is a breakable using
1
entity(x,y,"typename") == "Env_Breakable"
You can get the health of a breakable using
1
entity(x,y,"int1")
example:
1
2
3
4
local list = entitylist()
for _,e in pairs(list) do
  print("entity @ ("..e.x..","..e.y..") - "..entity(e.x,e.y,"typename") .. " = " .. entity(e.x,e.y,"int1"))
end

So what you want to do is loop through all entities using cs2d lua cmd entitylist and add the known breakable entities to a table with their x/y coordinates, and their health value. Then in the cs2d lua hook attack hook, interate through each one and check if the health value has changed.

alt Re: Return breakable entity Health

Promaster
User Off Offline

Zitieren
@user VaiN: Thank you for you took your time to write the code Vain. But i have though about that i can make a list and name them after their health value. But my biggest problem is to identify the damage a players dealt to the entity.

alt Re: Return breakable entity Health

Rainoth
Moderator Off Offline

Zitieren
Then after VaiN's "health value has changed", all you need to do is either get how much it has changed (you had health at 100 and now it's at 75, so the difference is 25) or you can check if any breakables were hit and then get the damage dealt through itemtype(player(id,"weapontype),"dmg")

The first method is of course way easier.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht