Help unite this code:
*********BUT THIS HERO MUST OPERATE ON ALL ENEMYES IN RADIUS, BUT NOT ON ONE WHEN POWER IS USE*********
PHP Code:
// ELECTRO! - from Marvel Comics, Spider-Man villain.
/* CVARS - copy and paste to shconfig.cfg
//Electro
electro_level 0
electro_cooldown 45 //# of seconds for cooldown between use (Default 45)
electro_searchtime 45 //# of seconds to search for a victim when key is pressed (Default 45)
electro_maxdamage 50 //Damage on first victim, amount is decreased each jump by decay rate (Default 50)
electro_jumpdecay 0.66 //Decay rate for damage and sprite line width each lightning jump (Default 0.66)
electro_jumpradius 500 //Radius to search for a lightning jump (Default 500)
*/
/*
* v1.1 - vittu - 9/27/09
* - Cleaned up and recoded using wc3ft chain lightning as a base.
*
* Based on a mix of wc3 and wc3ft Orc Chain Lightning.
* Originally commented with "WC3 Chain Lightning Ripoff :D".
*/
#include <superheromod>
#define LINE_WIDTH 80
// GLOBAL VARIABLES
new gHeroID
new bool:gHasElectro[SH_MAXSLOTS+1]
new bool:gLightningHit[SH_MAXSLOTS+1]
new bool:gIsSearching[SH_MAXSLOTS+1]
new const gSoundSearch[] = "turret/tu_ping.wav"
new const gSoundLightning[] = "weapons/gauss2.wav"
new gSpriteLightning
new gPcvarCooldown, gPcvarSearchTime, gPcvarMaxDamage, gPcvarJumpDecay, gPcvarJumpRadius
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Electro", "1.1", "AssKicR")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
new pcvarLevel = register_cvar("electro_level", "0")
gPcvarCooldown = register_cvar("electro_cooldown", "45")
gPcvarSearchTime = register_cvar("electro_searchtime", "45")
gPcvarMaxDamage = register_cvar("electro_maxdamage", "50")
gPcvarJumpDecay = register_cvar("electro_jumpdecay", "0.66")
gPcvarJumpRadius = register_cvar("electro_jumpradius", "500")
// FIRE THE EVENTS TO CREATE THIS SUPERHERO!
gHeroID = sh_create_hero("Electro", pcvarLevel)
sh_set_hero_info(gHeroID, "Chain Lightning", "Powerful Lightning Attack that can hurt Multiple Enemies")
sh_set_hero_bind(gHeroID)
register_forward(FM_TraceLine, "fm_TraceLine")
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_sound(gSoundSearch)
precache_sound(gSoundLightning)
gSpriteLightning = precache_model("sprites/lgtning.spr")
}
//----------------------------------------------------------------------------------------------
public sh_hero_init(id, heroID, mode)
{
if ( gHeroID != heroID ) return
gHasElectro[id] = mode ? true : false
}
//----------------------------------------------------------------------------------------------
public sh_client_spawn(id)
{
gPlayerInCooldown[id] = false
gIsSearching[id] = false
gLightningHit[id] = false
remove_task(id)
}
//----------------------------------------------------------------------------------------------
public sh_hero_key(id, heroID, key)
{
if ( gHeroID != heroID || sh_is_freezetime() ) return
if ( !is_user_alive(id) || !gHasElectro[id] ) return
if ( gIsSearching[id] ) return
if ( key == SH_KEYDOWN )
{
// Let them know they already used their ultimate if they have
if ( gPlayerInCooldown[id] )
{
sh_sound_deny(id)
return
}
gIsSearching[id] = true
new parm[2]
parm[0] = id
parm[1] = get_pcvar_num(gPcvarSearchTime)
electro_search(parm)
}
}
//----------------------------------------------------------------------------------------------
public electro_search(parm[2])
{
new id = parm[0]
new timeLeft = parm[1]
// Decrement our timer
parm[1]--
// User died or diconnected
if ( !is_user_alive(id) || !gHasElectro[id] )
{
gIsSearching[id] = false
}
// This is the last "playing" of the sound, no target was found :/
if ( timeLeft == 0 )
{
gIsSearching[id] = false
}
// Then we need to play the sound + flash their icon!
if ( gIsSearching[id] )
{
// Play the ping sound
emit_sound(id, CHAN_STATIC, gSoundSearch, 1.0, ATTN_NORM, 0, PITCH_NORM)
set_task(1.0, "electro_search", id, parm, 2)
}
}
//----------------------------------------------------------------------------------------------
public fm_TraceLine(Float:v1[3], Float:v2[3], const noMonsters, const pentToSkip)
{
if ( !sh_is_active() ) return FMRES_IGNORED
new victim = get_tr(TR_pHit)
if ( !is_user_alive(victim) ) return FMRES_IGNORED
//new attacker = pentToSkip
if ( !is_user_alive(pentToSkip) || !gHasElectro[pentToSkip] || !gIsSearching[pentToSkip] ) return FMRES_IGNORED
if ( cs_get_user_team(pentToSkip) == cs_get_user_team(victim) ) return FMRES_IGNORED
new damage = get_pcvar_num(gPcvarMaxDamage)
electro_attack(victim, pentToSkip, damage, LINE_WIDTH, pentToSkip)
new Float:seconds = get_pcvar_float(gPcvarCooldown)
if ( seconds > 0.0 ) sh_set_cooldown(pentToSkip, seconds)
gIsSearching[pentToSkip] = false
// Now we need to search for the next "jump"
new parm[4]
parm[0] = victim
parm[1] = damage
parm[2] = LINE_WIDTH
parm[3] = pentToSkip
set_task(0.2, "electro_jump_check", pentToSkip, parm, 4)
return FMRES_IGNORED
}
//----------------------------------------------------------------------------------------------
public electro_jump_check(parm[4])
{
// parm[0] = victim
// parm[1] = damage
// parm[2] = linewidth
// parm[3] = attacker
new lastVictim = parm[0]
new players[32], numberofplayers, i
get_players(players, numberofplayers, "a")
new Float:decay = get_pcvar_float(gPcvarJumpDecay)
// Damage should be decreased on each jump
new damage = floatround(parm[1] * decay)
if ( is_user_connected(lastVictim) && damage > 0 )
{
new lvOrigin[3]
get_user_origin(lastVictim, lvOrigin)
new attacker = parm[3]
new CsTeams:attackerTeam = cs_get_user_team(attacker)
new target, closestTarget, closestDistance
new distance, targetOrigin[3]
new radius = get_pcvar_num(gPcvarJumpRadius)
// Loop through every alive player
for ( i = 0; i < numberofplayers; i++ )
{
target = players[i]
if ( target == attacker || target == lastVictim ) continue
if ( gLightningHit[target] ) continue
// Make sure our target player isn't on the same team!
if ( cs_get_user_team(target) != attackerTeam )
{
get_user_origin(target, targetOrigin)
distance = get_distance(lvOrigin, targetOrigin)
// Verify the user is within range
if ( distance <= radius )
{
// This user is closest!! Lets make a note of this...
if ( distance < closestDistance || !closestTarget )
{
closestDistance = distance
closestTarget = target
}
}
}
}
if ( closestTarget )
{
// Then we have a valid target!!!
// Decrease line width as well
new lineWidth = floatround(parm[2] * decay)
// Display the actual lightning
electro_attack(closestTarget, attacker, damage, lineWidth, lastVictim)
// Lets call this again on our next target!
parm[0] = closestTarget
parm[1] = damage
parm[2] = lineWidth
set_task(0.2, "electro_jump_check", attacker, parm, 4)
return
}
}
// No valid target found - reset all lightning hit variables
for ( i = 0; i < numberofplayers; i++ )
{
gLightningHit[players[i]] = false
}
}
//----------------------------------------------------------------------------------------------
electro_attack(const victim, const attacker, const damage, const linewidth, const beamStartID)
{
// Make sure we set this user as hit, otherwise we'll hit him again
gLightningHit[victim] = true
// Get the target's origin
new Float:beamOrigin[3]
pev(beamStartID, pev_origin, beamOrigin)
// Damage the user
sh_extra_damage(victim, attacker, damage, "chain lightning", 0, SH_DMG_NORM, true, false, beamOrigin)
// Create the lightning
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_BEAMENTS)
write_short(beamStartID)// start entity
write_short(victim) // entity
write_short(gSpriteLightning) // model
write_byte(0) // starting frame
write_byte(15) // frame rate
write_byte(40) // life
write_byte(linewidth) // line width
write_byte(10) // noise amplitude
write_byte(0) // r, g, b
write_byte(191) // r, g, b
write_byte(255) // r, g, b 125
write_byte(255) // brightness 175
write_byte(0) // scroll speed
message_end()
// Get the victim's origin
new vicOrigin[3]
get_user_origin(victim, vicOrigin)
// Create an elight on the target
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_ELIGHT)
write_short(victim) // entity
write_coord(vicOrigin[0]) // initial position
write_coord(vicOrigin[1]) // initial position
write_coord(vicOrigin[2]) // initial position
write_coord(100) // radius
write_byte(255) // r, g, b
write_byte(255) // r, g, b
write_byte(100) // r, g, b
write_byte(10) // life
write_coord(0) // decay rate
message_end()
// Play the lightning sound
emit_sound(beamStartID, CHAN_STATIC, gSoundLightning, 1.0, ATTN_NORM, 0, PITCH_NORM)
}
//----------------------------------------------------------------------------------------------
with set X gravity on X seconds on all enemy attacked, who get in a radius (like ZeroG) and Force push all with X velocity (like Yoda)
The total we have cvars:
electromagnet_level //set level hero
electromagnet_radius //set radius of electro-magnet power (cvar from electro hero)
electromagnet_damage //set damage on attacked (cvar from electro hero)
electromagnet_cooldown //set cooldown here before u can use powe again (cvar from electro hero)
electromagnet_selfdamage //set damage on your team (cvar from yoda hero) - OPTIONAL
electromagnet_gravtime //time of players have gravity (cvar from zeroG hero)
electromagnet_playergrav //set gravity, which will have attacked players (regulation gravity cvar)
electromagnet_velocity // set force push power (cvar from yoda hero)
warning: sounds from yoda hero not use
Thank you!