Raised This Month: $ Target: $400
 0% 

Tracing damage indicator


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Lulu the hero
Senior Member
Join Date: Oct 2009
Location: Budapest, Hungary
Old 10-21-2010 , 20:30   Tracing damage indicator
Reply With Quote #1

Hi everyone!

I was looking for new methods of filtering damage recieving for my damage_displayer.sma, and I've had an interesting idea.

I would like to hook the state, where the user has a damage indication red paralelogram around the cursor. I know that hamsandwich's damage hook has a damage_type parameter, but what of the situations, where damage is composed of the following two steps:
1) set user's health directly
2) put a DMG_BULLET indication on it's HUD.

Like in monstermod, or in zp_extra_lasermine, or in much other plugins.

First of all, I've tried invoking it, and came up with the code below:
PHP Code:
#include <amxmodx>
#include <fakemeta>

new msgid_damage;

public 
plugin_init() {
    
msgid_damage get_user_msgid("Damage");
    
    
register_forward(FM_PlayerPreThink,"fw_playerPreThink",1);
}

public 
fw_playerPreThink(id){
    static 
buttons;
    
    
buttons pev(id,pev_button);
    
    if(
buttons&IN_ATTACK){
        
message_begin(MSG_ONE_UNRELIABLEmsgid_damage_id)
        
write_byte(5// damage save
        
write_byte(10// damage take
        
write_long(DMG_BULLET// damage type
        
write_coord(1// x
        
write_coord(1// y
        
write_coord(1// z
        
message_end()
    }

And hurray, we have "damage" all over us.

But how to hook this.

I've tried the code below:
PHP Code:
//in plugin_init:
register_message(msgid_damage,"message_damage");

public 
message_damage(msg_id,msg_dest,msg_ent){
    static 
damagedamage_type;
    
    
damage get_msg_arg_int(2);
    
damage_type get_msg_arg_int(3);
    
    
client_print(msg_ent,print_chat,"damage: %d, type: %d",damage,damage_type);
    
    return 
PLUGIN_CONTINUE;

But the code above only displays, when damage is "properly" invoked - not as explaned above. Plus, at any damage, the damage type is 0. We need special damage, eg. drowning in water to get a 16384 value(1<<14), which is DMG_DROWN according to hldsk_const.inc .

So how can I hook a MSG_ONE_UNRELIABLE? Or any other ideas on how to track if the user has the damage on their screen?

Thanks guys in advance!
Lulu the hero 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