Raised This Month: $ Target: $400
 0% 

Damage Modify Problem (Blue Raja)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TaRgEt*TuRkEy
Member
Join Date: Oct 2004
Old 01-15-2005 , 17:36   Damage Modify Problem (Blue Raja)
Reply With Quote #1

Hello, I have been modifying a plugin (what else do I do) by Blue Raja recently because it sparked an idea I had many of years ago, balancing all those crappy never used guns in CS. When I get it working, I will input the commands and abilities to edit any guns through cvars, but right now, I have a problem:

For some reason (even though I took out all the specific admin targeted damage multipliers, it is still (i think) doubling the damage from each gun from every player. They are even stronger if they are a gun on the list below (multiplying from a multiplier).

Can somebody point to the code that I missed to remove? I have been looking and tweaking for half an hour, and I can't see anything.

NOTE TO BLUE RAJA: If you don't want me to release this plugin, just say so, but it would be nice if you could help me with this, for my server.


Code:
/************************************************     Damage Modify     Author: TaRgEt*TuRkEy (Code From Blue Raja)     Version: 1.0     Mod: Counter-Strike     Requires: AMX Mod X v1.0     Description:         Allows admins to set the multiplier for each         weapon in counterstrike. You can set values         to 0, to have the gun do no damage, or even         negative values to inflict health into the         victim.         Notes:         90% of this code is from Blue Raja's plugin,         Damage Multiplier (WC3). Located here:         <a href="http://forums.alliedmods.net/showthread.php?t=8437" target="_blank" rel="nofollow noopener">http://forums.alliedmods.net/showthread.php?t=8437</a>                 I got the idea many years ago when I seen how         little the crappy guns in cs were used because,         well... they suck. You can fix that with this         plugin.     ************************************************/ #include <amxmodx> #include <amxmisc> #include <cstrike> #include <engine> #include <fun> new Title[32] = "Damage Modify" new Version[32] = "1.0.0" new Author[16] = "TaRgEt*TuRkEy" new gmsgDeathMsg new gmsgScoreInfo new DeathHandled[33] public client_connect(id) {     DeathHandled[id]=false } public RoundStart() {    new Float:roundtime = get_cvar_float("mp_roundtime") * 60.0    new rtime = read_data(1)        if ( roundtime == rtime )   { //Roundstart after freezetime     for (new i=0; i<33; i++){         DeathHandled[i]=false       }    }      return PLUGIN_CONTINUE } public damage_event(id) {     new weapon, bodypart, attacker = get_user_attacker(id,weapon,bodypart)     new damage     //If death has already been handled, return     if(DeathHandled[id])         return PLUGIN_CONTINUE     //Is called for all players, regardless of admin status     //In case player died "legitimately"     if (!is_user_alive(id))     {         DeathHandled[id]=true         return PLUGIN_CONTINUE     }     if (attacker==0)         return PLUGIN_CONTINUE     if (attacker==id && weapon==0)         return PLUGIN_CONTINUE //Check is victim and attacker are dead     new victimkilled = 0     new victimhealth = get_user_health(id) //Check if shot was headshot; might want to fake it, if not     new headshot = 0     if (bodypart==HIT_HEAD ||                           //real headshot        (damage>35 && weapon!=CSW_HEGRENADE && bodypart==HIT_CHEST)) //fake headshot ^_^         headshot=1     damage = read_data(2)     if (weapon==CSW_P228)         damage = floatround(float(damage)*1.3)     if (weapon==CSW_MAC10)         damage = floatround(float(damage)*1.5)     if (weapon==CSW_GLOCK18)         damage = floatround(float(damage)*1.1)     if (weapon==CSW_ELITE)         damage = floatround(float(damage)*1.6)     if (weapon==CSW_FIVESEVEN)         damage = floatround(float(damage)*1.3)     if (weapon==CSW_UMP45)         damage = floatround(float(damage)*1.3)     if (weapon==CSW_TMP)         damage = floatround(float(damage)*1.6)     if (weapon==CSW_P90)         damage = floatround(float(damage)*1.2)     //check if player should die; if so, kill 'em     if (victimhealth - damage<=0)         victimkilled = 1     if (victimhealth - damage<=1024 && get_user_health(id)>500)         victimkilled = 1         if (victimkilled){         new weaponname[32]         switch (weapon)         {         case 1:             weaponname = "p228"         case 3:             weaponname = "scout"         case 4:             weaponname = "grenade"         case 5:             weaponname = "xm1014"         case 7:             weaponname = "mac10"         case 8:             weaponname = "aug"         case 10:             weaponname = "elite"         case 11:             weaponname = "fiveseven"         case 12:             weaponname = "ump45"         case 13:             weaponname = "sg550"         case 14:             weaponname = "galil"         case 15:             weaponname = "famas"         case 16:             weaponname = "usp"         case 17:             weaponname = "glock18"         case 18:             weaponname = "awp"         case 19:             weaponname = "mp5navy"         case 20:             weaponname = "m249"         case 21:             weaponname = "m3"         case 22:             weaponname = "m4a1"         case 23:             weaponname = "tmp"         case 24:             weaponname = "g3sg1"         case 26:             weaponname = "deagle"         case 27:             weaponname = "sg552"         case 28:             weaponname = "ak47"         case 29:             weaponname = "knife"         case 30:             weaponname = "p90"         }         if (get_user_team(id)!=get_user_team(attacker)){             set_user_frags(id,get_user_frags(id)+1)             set_user_frags(attacker,get_user_frags(attacker)+1)         }         else{             set_user_frags(id,get_user_frags(id)+1)             set_user_frags(attacker,get_user_frags(attacker)-1)         }         //Kill victim         set_msg_block(gmsgDeathMsg,BLOCK_ONCE)         set_user_health(id,-1)         set_msg_block(gmsgDeathMsg,BLOCK_NOT) //having problems with more than one message being blocked :S         //Display death         message_begin( MSG_ALL, gmsgDeathMsg,{0,0,0},0)         write_byte(attacker)         write_byte(id)         write_byte(headshot)         write_string(weaponname)         message_end()         //Change scoreboard for victim         message_begin(MSG_ALL, gmsgScoreInfo)         write_byte(id)              //Player         write_short(get_user_frags(id)) //Frags         write_short(cs_get_user_deaths(id)) //Deaths         write_short(0)              //"Class"         write_short(get_user_team(id))  //Team         message_end()         //Change scoreboard for attacker         message_begin(MSG_ALL, gmsgScoreInfo)         write_byte(attacker)                //Player         write_short(get_user_frags(attacker))   //Frags         write_short(cs_get_user_deaths(attacker))   //Deaths         write_short(0)                  //"Class"         write_short(get_user_team(attacker))    //Team         message_end()         //Don't handle this death again         DeathHandled[id]=true     }     else {         set_user_health(id,get_user_health(id) - damage)     }     return PLUGIN_CONTINUE } public plugin_init(){     gmsgDeathMsg = get_user_msgid("DeathMsg")     gmsgScoreInfo = get_user_msgid("ScoreInfo")     register_plugin(Title,Version,Author)     register_event("Damage", "damage_event", "b", "2!0")     register_event("RoundTime", "RoundStart", "bc")     return PLUGIN_CONTINUE }
__________________
TaRgEt*TuRkEy is offline
BlueRaja
Senior Member
Join Date: Nov 2004
Old 01-16-2005 , 05:21  
Reply With Quote #2

Score!
I'm glad someone finally appreciates my f*cking work ^_^

But uh...two things:
1. Don't use that code; I'm going to make a complete rewrite of damagemod, so I don't have to give credit to someone else anymore (it's gotten to the point where all of the code except the function names and that big switch statement are mine)...that, plus I think I can optimize it.
Also, it might take a while, since I'm still trying to make the kills commited by the plugin not look like suicides... I won't have time to work on it this week, either; finals are in four days O_o.
2. Check the beginning comments in my source again.
*waits*

This is because registering the message with register_event() doesn't stop the message from getting to the engine (I think, in fact, it catches the message after the server deals with it) - thus, the damage done by the plugin is damage done EXTRA to the player.
If, for example, sv_highgunmult is 1, your code will change the damage variable to 1.6 if the player is using a TMP. That's 160% damage EXTRA done to the victim - a total of 260% damage.

If I were you, I'd just rewrite it all. Either that, or wait until Raja can figure out how to use the damn death-camera O_o Otherwise, do what I was obviously implying and change the numbers to 0.x et cetera blah blah blah...

Hope that helps.
BlueRaja is offline
Send a message via AIM to BlueRaja Send a message via MSN to BlueRaja
BlueRaja
Senior Member
Join Date: Nov 2004
Old 01-16-2005 , 05:24  
Reply With Quote #3

PS. I would prefer if you didn't release it until after I can make my changes to damagemod, to make it less shitty; but if you're insistant, I won't stop you. Just make sure to give credit where credit is due ^_^.
BlueRaja is offline
Send a message via AIM to BlueRaja Send a message via MSN to BlueRaja
TaRgEt*TuRkEy
Member
Join Date: Oct 2004
Old 01-16-2005 , 05:54  
Reply With Quote #4

Quote:
If, for example, sv_highgunmult is 1, your code will change the damage variable to 1.6 if the player is using a TMP. That's 160% damage EXTRA done to the victim - a total of 260% damage.
That is exactly what I thought was happening, but wasn't sure how to explain it .

Well I will try to rewrite my own, and then write my own faking the death messages based on your code. If that doesn't turn out, I will just wait for you .

PS- Thanks for positive response.
__________________
TaRgEt*TuRkEy is offline
EKS
Veteran Member
Join Date: Mar 2004
Location: Norway
Old 01-16-2005 , 09:58  
Reply With Quote #5

You cant change the damage with a plugin. (Maybie with the fakemeta module, but not with register_message or register_event)

One of the problems is that the modules get information BEFORE the plugins. So if you use register_message() you will alter the message that the client sees, But the other modules(Or plugins loaded before yours) will no see the change.

On another note you plugin will fail on servers that resurect players.(like DM mods,War3 and so on)
__________________
Github archive for plugins, the repos for the other c++ projects are there to.
EKS is offline
BlueRaja
Senior Member
Join Date: Nov 2004
Old 01-16-2005 , 15:10  
Reply With Quote #6

Well I'm not sure if there's anything I can do about getting it to work with stats-module and other modules...I'll check it out later
However, I know I could fix the DM thing - just check is_user_alive on reset_hud message, and set DeathHandled[id] appropriately.
I'll write that into my rewrite of damagemod; thanks, EKS ^_^
BlueRaja is offline
Send a message via AIM to BlueRaja Send a message via MSN to BlueRaja
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 01-16-2005 , 17:08  
Reply With Quote #7

This may have been what BlueRaja was talking about improving, but wouldn't it be easier to use get_weaponname and strip the weapon_ prefix, instead of having a huge switch statement?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
BlueRaja
Senior Member
Join Date: Nov 2004
Old 01-16-2005 , 22:18  
Reply With Quote #8

I was actually going to go one better and just create an array with all the names (which I'm assuming would be slightly faster; not that it really matters, as it's only evaluated on a player's death anyways...)
That switch statement was basically the only notable code left from WC3 mod, whose code I used as a base when I began this plugin.
BlueRaja is offline
Send a message via AIM to BlueRaja Send a message via MSN to BlueRaja
Reply


Thread Tools
Display Modes

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 19:28.


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