AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   extra dmg to a random bullet (https://forums.alliedmods.net/showthread.php?t=63737)

Pamaliska 11-28-2007 14:38

extra dmg to a random bullet
 
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.

[ --<-@ ] Black Rose 11-28-2007 14:46

Re: extra dmg to a random bullet
 
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); }

Pamaliska 11-29-2007 06:54

Re: extra dmg to a random bullet
 
Thx indeed, I'll give it a try this afternoon.

VEN 11-30-2007 11:16

Re: extra dmg to a random bullet
 
HamSandwich module is more suitable for such kind of things.

Pamaliska 11-30-2007 12:03

Re: extra dmg to a random bullet
 
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]

ConnorMcLeod 11-30-2007 12:15

Re: extra dmg to a random bullet
 
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 }

Pamaliska 11-30-2007 12:37

Re: extra dmg to a random bullet
 
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.

ConnorMcLeod 11-30-2007 14:21

Re: extra dmg to a random bullet
 
edited the code

Pamaliska 11-30-2007 15:24

Re: extra dmg to a random bullet
 
No activity, although set "randombullet_chance", "50"

[ --<-@ ] Black Rose 11-30-2007 16:05

Re: extra dmg to a random bullet
 
Do you have the module?


All times are GMT -4. The time now is 11:13.

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