PDA

View Full Version : Hero: Mr. Hydrogen


Zul Rivers
05-14-2008, 10:33
Mr. Hydrogen

Image:
Not Available

Descriptions:
Fill Enemy With Hydrogen Gas.
Boost Knife Damage & Victim Floats Like A Balloon When Being Hit By Your Knife.

Cvars:

//Mr. Hydrogen
mrhydrogen_level 0 // Level Acquired To Use Hero
mrhydrogen_knifemult 1.10 // Multiply Knife Damage
mrhydrogen_floattime 8.0 // Time Before Victim Drops
Updates:

VERSION 1.4
- MODIFIED AND ENHANCED CODES FOR MRHYDROGEN_VICTIM_FLOAT(ID) AND MRHYDROGEN_POWERS(ID) - CREDITS: G-DOG

VERSION 1.3
- REMOVED VEXD_UTILITIES INCLUDES AS IT IS NOT NEEDED
- ADDED ENGINE INCLUDES
- CVAR CHANGES - MR_HYDROGEN TO MRHYDROGEN
- MINOR CODE CLEANUP

VERSION 1.2
- REMOVED AMXMOD INCLUDES AS REQUESTED BY VITTU

VERSION 1.1
- ADDED SOUND EFFECTS - WHEN POWER IS USED ON ENEMY, VICTIM MAKES BREATHING SOUNDS UNTIL HYDROGEN GAS IS GONE
- ADDED HUD MESSAGE - WHEN POWER IS USED ON ENEMY, HUD MESSAGE WILL ONLY SHOW TO VICTIM
- MAJOR CODE CLEANUP

VERSION 1.0
- RELEASE OF HERO
Comments:
Best gravity to use with hero - Min(0) Max(2000)
Thanks to D o o m and G-Dog for teaching me to script superheroes :)

Dark_Menace
05-14-2008, 13:17
Seems like a nice hero , though i have a tiny note for you q: vittu doesn't like amxmod includes as he stated in the sticky http://forums.alliedmods.net/showthread.php?t=59519

Zul Rivers
05-14-2008, 18:41
ok, i have updated the attachment, thanks for the reminder. ^^

vittu
05-14-2008, 18:57
#include <Vexd_Utilities>your not even using this amxmod include, you're using engine so don't include it...


Also, attach the sma outside of the zip... guidelines below as stated here (http://forums.alliedmods.net/showthread.php?t=34114):
All heroes must be posted as the sma file, and online compiler will provide a link to the compiled amxx file. All hero extras (models/sounds) must be posted as ZIP files, or it will be moved to the trash (no RARs). Please name the zip the same name as the sma + _required_files, ex. sh_blink_required_files.zip . If your zip is too large because of models or sounds, either separate the extra files and make more then one attachment (make sure you explain what they are), or contact one of us to possibly either compact it smaller or host it for you, send a Private Message (PM).

Zul Rivers
05-15-2008, 04:23
Ok vittu, i have updated the hero and did as you said.. i also changed a little of the cvars.. please report any errors, bugs or any other problems..

G-Dog
05-15-2008, 05:19
one question: why in your "mrhydrogen_victim_float" function do you haveentity_get_vector(id, EV_VEC_velocity, HydroVelocity[id])when your redefining HydroVelocity[id] right below it get_user_origin(id, Origin)
get_user_origin(id, vOrigin)
get_distance(vOrigin, Origin)
HydroVelocity[id][0] = (vOrigin[0] - Origin[0]) / 1000.0
HydroVelocity[id][1] = (vOrigin[1] - Origin[1]) / 1000.0
HydroVelocity[id][2] = 1000.0also since thats the only function you use HydroVelocity theres no reason to make it global. In fact, theres no reason to do what you did there at all since both origin, and vorigin are for the same person the math for HydroVelocity[id][0] = (vOrigin[0] - Origin[0]) / 1000.0
HydroVelocity[id][1] = (vOrigin[1] - Origin[1]) / 1000.0
HydroVelocity[id][2] = 1000.0would always equate to HydroVelocity[id][0] = 0.0
HydroVelocity[id][1] = 0.0
HydroVelocity[id][2] = 1000.0in the damage function you have the is_user_alive(id) check twice, which is just redundent, same thing with if (attacker <= 0 || attacker > SH_MAXSLOTS)andis_user_alive(attacker) they are basically the same check. Also when possible make use of pcvars(mrhydrogen_knifemult, and mrhydrogen_floattime). All in all rescripted it would look like//--------------------------------------------------------------------------------------------------
// INCLUDED HEADERS
//--------------------------------------------------------------------------------------------------
#include <amxmodx>
#include <superheromod>
#include <engine>
//--------------------------------------------------------------------------------------------------
// GLOBAL VARIABLES
//--------------------------------------------------------------------------------------------------
new gHeroName[]="Mr. Hydrogen"
new bool:gHasMrHydrogenPowers[SH_MAXSLOTS+1]
new sndStop=(1<<5)
new bool:gIsHitByMrHydrogen[SH_MAXSLOTS+1]
//pcvars
new cvar_time, cvar_mult
//--------------------------------------------------------------------------------------------------
// PLUGIN EVENTS
//--------------------------------------------------------------------------------------------------
public plugin_init()
{
register_plugin("SUPERHERO Mr. Hydrogen", "1.3", "Zul Rivers")
register_cvar("mrhydrogen_level", "0")
cvar_mult = register_cvar("mrhydrogen_knifemult", "1.10" )
cvar_time = register_cvar("mrhydrogen_floattime", "8.0" )
shCreateHero(gHeroName, "Fill Enemy With Hydrogen Gas", "Boost Knife Damage & Victim Floats When Being Hit By Your Knife", false, "mrhydrogen_level")
register_srvcmd("mrhydrogen_init", "mrhydrogen_init")
shRegHeroInit(gHeroName, "mrhydrogen_init")
register_event("ResetHUD", "mrhydrogen_newspawn", "b")
register_event("DeathMsg", "mrhydrogen_death", "a")
register_event("Damage", "mrhydrogen_powers", "b", "2!0")
}
//--------------------------------------------------------------------------------------------------
// HERO EVENTS
//--------------------------------------------------------------------------------------------------
public mrhydrogen_init()
{
new temp[6]
read_argv(1, temp, 5)
new id = str_to_num(temp)
read_argv(2, temp, 5)
new hasPowers=str_to_num(temp)
gHasMrHydrogenPowers[id] = (hasPowers != 0)
}
//--------------------------------------------------------------------------------------------------
// PLUGIN PRECACHES
//--------------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_sound("player/breathe2.wav")
}
//--------------------------------------------------------------------------------------------------
// EVENTS ON NEW SPAWN
//--------------------------------------------------------------------------------------------------
public mrhydrogen_newspawn(id)
{
if (is_user_alive(id))
mrhydrogen_stop_powers(id)
}
//--------------------------------------------------------------------------------------------------
// EVENTS ON DEATH
//--------------------------------------------------------------------------------------------------
public mrhydrogen_death()
{
new id = read_data(2)
mrhydrogen_stop_powers(id)
}
//--------------------------------------------------------------------------------------------------
// HERO POWERS
//--------------------------------------------------------------------------------------------------
public mrhydrogen_powers(id)
{
if (!shModActive() && !is_user_alive(id))
return PLUGIN_CONTINUE

new damage = read_data(2)
new weapon, bodypart, attacker = get_user_attacker(id, weapon, bodypart)
new headshot = bodypart == 1 ? 1 : 0
if ((attacker <= 0 || attacker > SH_MAXSLOTS) && id != attacker)
return PLUGIN_CONTINUE

if (gHasMrHydrogenPowers[attacker] && weapon == CSW_KNIFE && is_user_alive(id))
{
new extraDamage = floatround(damage * get_pcvar_float(cvar_mult) - damage)
if (extraDamage > 0)
shExtraDamage(id, attacker, extraDamage, "knife", headshot)
if ( !gIsHitByMrHydroggen[id] )
{
gIsHitByMrHydrogen[id] = true
set_task(0.1,"mrhydrogen_victim_float", id, "", 0, "b")
set_task(get_cvar_float("mrhydrogen_floattime"),"mrhydrogen_stop_powers", id)
set_hudmessage(255, 0, 0, -1.0, 0.35, 0, 5.0, 5.0, 0.1, 0.2, 4)
show_hudmessage(id, "Someone Filled You With Hydrogen Gas! - It Will Run Out In Sometime", gHeroName)
emit_sound(id, CHAN_STATIC, "player/breathe2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
}
return PLUGIN_CONTINUE
}
//--------------------------------------------------------------------------------------------------
// VICTIM EFFECTS WHEN BEING HIT BY KNIFE
//--------------------------------------------------------------------------------------------------
public mrhydrogen_victim_float(id)
{
if (is_user_alive(id) && gIsHitByMrHydrogen[id])
{
static Float:fvelocity[3]

HydroVelocity[id][0] = 0.0
HydroVelocity[id][1] = 0.0
HydroVelocity[id][2] = 1000.0
entity_set_vector(id, EV_VEC_velocity, fvelocity)
}
}
//--------------------------------------------------------------------------------------------------
// STOP ALL RUNNING TASK
//--------------------------------------------------------------------------------------------------
public mrhydrogen_stop_powers(id)
{
remove_task(id)
gIsHitByMrHydrogen[id] = false
emit_sound(id, CHAN_STATIC, "player/breathe2.wav", 1.0, ATTN_NORM, sndStop, PITCH_NORM)
}
//--------------------------------------------------------------------------------------------------