Raised This Month: $ Target: $400
 0% 

Tracing damage indicator


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-27-2010 , 01:45   Re: Tracing damage indicator
Reply With Quote #4

To make the game itself send a Damage event, all you have to do is to set properly pev_dmg_take, m_bitsDamageType and pev_dmg_inflictor, Damage message will be sent at UpdateClientData :

Code:
	if (pev->dmg_take || pev->dmg_save || m_bitsHUDDamage != m_bitsDamageType)
	{
		// Comes from inside me if not set
		Vector damageOrigin = pev->origin;
		// send "damage" message
		// causes screen to flash, and pain compass to show direction of damage
		edict_t *other = pev->dmg_inflictor;
		if ( other )
		{
			CBaseEntity *pEntity = CBaseEntity::Instance(other);
			if ( pEntity )
				damageOrigin = pEntity->Center();
		}

		// only send down damage type that have hud art
		int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD;

		MESSAGE_BEGIN( MSG_ONE, gmsgDamage, NULL, pev );
			WRITE_BYTE( pev->dmg_save );
			WRITE_BYTE( pev->dmg_take );
			WRITE_LONG( visibleDamageBits );
			WRITE_COORD( damageOrigin.x );
			WRITE_COORD( damageOrigin.y );
			WRITE_COORD( damageOrigin.z );
		MESSAGE_END();
	
		pev->dmg_take = 0;
		pev->dmg_save = 0;
		m_bitsHUDDamage = m_bitsDamageType;
		
		// Clear off non-time-based damage indicators
		m_bitsDamageType &= DMG_TIMEBASED;
	}
From my gasnade plugin :

PHP Code:
TakeDamage(idiEntiAttackerFloat:flDmgiDmgBit)
{
    new 
Float:flHealth;
    
pev(idpev_healthflHealth);

    
flHealth -= flDmg;

    if( 
flHealth )
    {
        
ExecuteHamBHam_KilledidiAttacker);
        return;
    }

    
set_pev(idpev_healthflHealth);

    
set_pev(idpev_dmg_takeflDmg);
    
set_pdata_int(idm_bitsDamageTypeiDmgBit);
    
set_pev(idpev_dmg_inflictoriEnt);

This is an alternative to ExecuteHamB(Ham_TakeDamage so you know the exact damage done, because with Ham_TakeDamage you can't know the final damage.
Then the game will know that player has just taken damage and will send a Damage message with correct origins values.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-27-2010 at 01:47.
ConnorMcLeod is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode