SC_AngelScript icon indicating copy to clipboard operation
SC_AngelScript copied to clipboard

Player Hurt (to target)

Open fnky opened this issue 9 years ago • 2 comments

Script types: All

Getting target type, damage dealt, damage type, etc.

See CBaseEntity::TakeDamage and CBaseEntity::TraceAttack

fnky avatar Feb 09 '17 23:02 fnky

yes, my VOTE ! i really think we need more events to keep coding alive and stuff

HookReturnCode onPlayerHurt (CEntityDamageEvent@ ede) { ede.GetVictim(); // in this case, always a Player ede.GetDamageType(); // fire, poison, crush, etc ... ede.GetDamage(); // int ede.SetDamage(int); // <<-- THIS can change the outcome or even negate the event ede.GetAttacker() // entity (or null if falldamage etc was the cause) ede.GetCause() // new Enum: WORLD, TRIGGER, PLAYER, NPC, SCRIPT, ... }

Rei-57645 avatar Jul 13 '17 19:07 Rei-57645

NOW you can do nice stuff like server side difficulty, on TOP of map difficulty balance, without interfering:

float difficulty = 0.5f; // easy float difficulty = 1.0f; // normal float difficulty = 2.0f; // hard

HookReturnCode onPlayerHurt (CEntityDamageEvent@ ede) { if ( ede.GetCause() == DamageCause.NPC ) ede.SetDamage( ede.GetDamage() * difficulty ); }

Rei-57645 avatar Jul 13 '17 19:07 Rei-57645