Raised This Month: $ Target: $400
 0% 

extra dmg to a random bullet


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 11-28-2007 , 14:38   extra dmg to a random bullet
Reply With Quote #1

Hi everyone, what would be the mechanism of adding extra damage to a random bullet. Let's say 5% chance to make 20% more damage with a bullet.
This is what I'm using just now:
Code:
//// register_event("Damage", "on_damage", "b", "2!0", "3=0", "4!0"); /// public on_damage(victim) {     if( !get_cvar_num("amx_vipscript") )         return;         static attacker, damage;     attacker = get_user_attacker(victim);     damage = read_data(2);         if( !attacker || !damage )         return;         if( menu_selected[victim] == 1 && IsPlayerVip(victim) )     {         set_hudmessage(200, 100, 0, 0.4, -1.0, 2, 0.1, 2.0, 0.02, 0.02, -1);         ShowSyncHudMsg(victim, g_MsgSync, "I wonder what has happened here %d", damage);     }

Cheers.
Pamaliska is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-28-2007 , 14:46   Re: extra dmg to a random bullet
Reply With Quote #2

It's not exactly only bullets but that can be changed.
Code:
#include <amxmodx> #include <csx> #include <fun> new pCvar_Chance, pCvar_Mult; new gmsgDeathMsg; public plugin_init() {     register_plugin("", "", "")     pCvar_Chance = register_cvar("randombullet_chance", "5"); // Percent     pCvar_Mult = register_cvar("randombullet_mult", "1.5");         gmsgDeathMsg = get_user_msgid("DeathMsg"); } public client_damage(a, v, damage, wpnID, hitplace, TA) {         if ( ! a || random_num(1,100) > get_pcvar_num(pCvar_Chance) )         return;         damage = floatround( get_pcvar_float(pCvar_Mult) * damage ) - damage;         new vHealth = get_user_health(v);         if ( vHealth < damage ) {                 user_silentkill(v);                 new wpnName[32];         get_weaponname(wpnID, wpnName, 31);                 message_begin(MSG_BROADCAST, gmsgDeathMsg);         write_byte(a);         write_byte(v);         write_byte(hitplace == 1 ? 1 : 0);         write_string(wpnName);         message_end();                 set_user_frags(a, get_user_frags(a) + 1);         set_user_frags(v, get_user_frags(v) + 1);     }     else         set_user_health(v, vHealth - damage); }

Last edited by [ --<-@ ] Black Rose; 11-29-2007 at 02:29.
[ --<-@ ] Black Rose is offline
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 11-29-2007 , 06:54   Re: extra dmg to a random bullet
Reply With Quote #3

Thx indeed, I'll give it a try this afternoon.
Pamaliska is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 11-30-2007 , 11:16   Re: extra dmg to a random bullet
Reply With Quote #4

HamSandwich module is more suitable for such kind of things.
VEN is offline
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 11-30-2007 , 12:03   Re: extra dmg to a random bullet
Reply With Quote #5

This is what it does: it adds a frag if I kill somebody, but the death message is screwed up.
It first shows that I killed a bot with ak47, but then shows the same death message indicating that I killed the bot with world kill or something (duplicate death message). Although it adds only one frag as it should.

[img]http://img255.**************/img255/9725/deaztec0000xh1.png[/img]
Pamaliska is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-30-2007 , 12:15   Re: extra dmg to a random bullet
Reply With Quote #6

Try this :
Code:
#include <amxmodx> #include <hamsandwich> new pCvar_Chance, pCvar_Mult public plugin_init() {         register_plugin("Random Extra Damage", "0.1", "author")         pCvar_Chance = register_cvar("randombullet_chance", "5") // 5%         pCvar_Mult = register_cvar("randombullet_mult", "1.2")   // + 20%         RegisterHam(Ham_TakeDamage, "player", "player_TakeDamage") } public player_TakeDamage(id, idinflictor, idattacker, Float:damage, dmgbits) {         if ( ! idattacker || random_num(1,100) > get_pcvar_num(pCvar_Chance) )                 return HAM_IGNORED           new Float:new_damage = damage * get_pcvar_float(pCvar_Mult)         SetHamParamFloat(4, new_damage)         /* just to see */         client_print(idattacker, print_chat, "previous damage inflicted: %.1f , new damage inflicted: %.1f", damage, new_damage)         client_print(id, print_chat, "previous damage took: %.1f , new damage took: %.1f", damage, new_damage)         /* just to see */         return HAM_HANDLED }

Last edited by ConnorMcLeod; 11-30-2007 at 16:08.
ConnorMcLeod is offline
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 11-30-2007 , 12:37   Re: extra dmg to a random bullet
Reply With Quote #7

Where do I add this?
client_print(idinflictor, print_chat, "[VIP] BONUS HIT.");

Does it mean I need to upgrade amxx to 1.8 ?
So far I just added hansandwitch module, seems it's running fine.

Unable to test it properly without any output from plugin about its activity, tried to set the chance of extra dmg to 100 and dmg multiplier, but it seems that you need to cause usual ammount of dmg to kill an apponent.

Last edited by Pamaliska; 11-30-2007 at 13:12.
Pamaliska is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-30-2007 , 14:21   Re: extra dmg to a random bullet
Reply With Quote #8

edited the code

Last edited by ConnorMcLeod; 11-30-2007 at 14:27.
ConnorMcLeod is offline
Pamaliska
Senior Member
Join Date: Apr 2006
Location: Edinburgh, UK
Old 11-30-2007 , 15:24   Re: extra dmg to a random bullet
Reply With Quote #9

No activity, although set "randombullet_chance", "50"
Pamaliska is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 11-30-2007 , 16:05   Re: extra dmg to a random bullet
Reply With Quote #10

Do you have the module?
[ --<-@ ] Black Rose is offline
Reply



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 11:13.


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