/*
A more detailed damage displayer then advanced bullet damage(abd)
Colors are being displayed around the cursor accordingly:
yellow - friendly fire
red - damage taken
blue - inflicted harm
green - self harm
white - objects( eg. bomb explosion or fire )
Version history:
1.4 - fixed team indication in cstrike
1.3 - removed team coloring to make plugin applyable to mods other then cs
turned back to switches to increase sourcecode's readability
1.22 - removed some variables to reduce resource usage
1.21 - added team specific colors( T = red, CT = blue, OTHER = magenta ) in both harm and damage
1.2 - turned switches into ?: statements and clearing out a few variables this way
1.11 - more optimalization and extracting datas, restructuring if cases, turning them to switches
1.1 - optimazed code, added friendly fire coloring in damage, plus damage HARM non players
1.0 - started project: indicating friendly fire(yellow), normal fire(blue) and damage(red)
Future developements:
- Indicating damage done on/recieve from objects, such as breakable things or monstermod monsters.
Topic link:
*/
//comment this line out if you aren't using this plugin in cstrike or czero
#define FOR_CSTRIKE
#include <amxmodx>
#if defined FOR_CSTRIKE
#include <cstrike>
#define get_team(%1) cs_get_user_team(%1)
#else
#define get_team(%1) get_user_team(%1)
#endif
#define NOT_PLAYER_TEAM_ID -1
// r , g , b
#define COLOR_ATTACK_TEAMMATE { 127,127, 0 }
#define COLOR_ATTACK_ENEMY { 0, 0,127 }
#define COLOR_DAMAGE_TEAMMATE { 127,127, 0 }
#define COLOR_DAMAGE_ENEMY { 127, 0, 0 }
#define COLOR_DAMAGE_OBJECT { 127,127,127 }
#define COLOR_DAMAGE_SELF { 0,127, 0 }
#define DAMAGE_ENEMY 0
#define DAMAGE_TEAMMATE 1
#define DAMAGE_OBJECT 2
#define DAMAGE_SELF 3
new attack_hud, damage_hud;
public plugin_init(){
register_plugin( "Damage displayer", "1.4", "Lulu the hero" );
//hook a damage event
register_event( "Damage", "damage_event", "b", "2!0" );
attack_hud = CreateHudSyncObj();
damage_hud = CreateHudSyncObj();
}
public damage_event(victim){
static damage, attacker, attacker_team, victim_team, is_attacker_player, color[3], damage_type;
//if victim is not a player then return
if(!is_user_connected(victim)) return PLUGIN_CONTINUE;
//if no damage then return
damage = read_data(2);
if(!damage) return PLUGIN_CONTINUE;
//get the attacker
attacker = get_user_attacker(victim);
is_attacker_player = is_user_connected(attacker);
//if attacker is not a player, then mark that
//this way, if an entity hurts the player, then we can still indicate that
attacker_team = is_attacker_player ? (_:get_team(attacker)) : NOT_PLAYER_TEAM_ID;
//precache the victim's team
victim_team = _:get_team(victim);
//displaying inflicted damage to attacker
if(!is_user_bot(attacker) && is_attacker_player && attacker != victim){
//get the nature of the damage
damage_type = victim_team == attacker_team ? DAMAGE_TEAMMATE : DAMAGE_ENEMY;
//set the color according to damage type
switch(damage_type){
case DAMAGE_TEAMMATE : color = COLOR_ATTACK_TEAMMATE;
case DAMAGE_ENEMY : color = COLOR_ATTACK_ENEMY;
}
set_hudmessage( color[0], color[1], color[2], -1.0, 0.55, 0, 2.0, 2.0, 0.1, 1.0, -1 );
ShowSyncHudMsg( attacker, attack_hud, "%d", damage);
}
//displaying damage to victim
if(!is_user_bot(victim)){
//get the nature of the damage
damage_type = attacker == victim ? DAMAGE_SELF : victim_team == attacker_team ? DAMAGE_TEAMMATE : attacker_team == NOT_PLAYER_TEAM_ID ? DAMAGE_OBJECT : DAMAGE_ENEMY;
//set the color according to damage type
switch(damage_type){
case DAMAGE_TEAMMATE : color = COLOR_DAMAGE_TEAMMATE;
case DAMAGE_ENEMY : color = COLOR_DAMAGE_ENEMY;
case DAMAGE_OBJECT : color = COLOR_DAMAGE_OBJECT;
case DAMAGE_SELF : color = COLOR_DAMAGE_SELF;
}
set_hudmessage( color[0], color[1], color[2], 0.45, -1.0, 0, 2.0, 2.0, 0.1, 1.0, -1 );
ShowSyncHudMsg( victim, damage_hud, "%d", damage );
}
return PLUGIN_HANDLED;
}