I recently set up my SH server again and decided to add some custom / recode old heros . After messing around with pawn for awhile creating a few of my own heros and doing some work on others, I decided to try and make a more complicated and at least somewhat original hero. But alas, my inferior scripting knowledge could only take me so far. Instead of just scrapping the whole idea, I figured I could turn it over to some hopefully more talented people that would be willing to help me out.
(I know it looks similar to blue vision's hero by the same name. I used it as a starting reference (along side Zeus), but put alot of my own coding and ideas into it.)
Code:
#include <amxmodx>
#include <superheromod>
// GLOBAL VARIABLES
new gHeroName[]="Sacrifice"
new gBetweenRounds
new bool:gHasSacrificePowers[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Sacrifice","0.4", "")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("sacrifice_level", "18" )
register_cvar("sacrifice_cooldown", "60" )
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName, "Ritual of Blood: Revive Teammates", "Revive A Fallen Teammate For 150 HP", true, "sacrifice_level" )
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
register_event("ResetHUD","sacrifice_newspawn","b")
register_srvcmd("sacrifice_init", "sacrifice_init")
shRegHeroInit(gHeroName, "sacrifice_init")
// KEY DOWN
register_srvcmd("sacrifice_kd", "sacrifice_kd")
shRegKeyDown(gHeroName, "sacrifice_kd")
// DEATH
register_event("DeathMsg", "sacrifice_death", "a")
// ROUND EVENTS
register_logevent("round_start", 2, "1=Round_Start")
register_logevent("round_end", 2, "1=Round_End")
register_logevent("round_end", 2, "1&Restart_Round_")
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_sound("warcraft3/resurrecttarget.wav")
}
//----------------------------------------------------------------------------------------------
public sacrifice_newspawn(id)
{
if ( !hasRoundStarted() ) {
gPlayerUltimateUsed[id] = false
}
else {
gPlayerUltimateUsed[id] = true //dead loose their power...
}
}
//----------------------------------------------------------------------------------------------
public sacrifice_init()
{
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the id has sacrifice powers
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
gHasSacrificePowers[id] = (hasPowers != 0)
}
//----------------------------------------------------------------------------------------------
public sacrifice_death()
{
new id = read_data(2)
if ( !is_user_connected(id) || is_user_alive(id) ) return
// Look for alive players with unused Sacrifice Powers on the same team
for ( new player = 1; player <= SH_MAXSLOTS; player++ ) {
if ( player != id && is_user_alive(player) && gHasSacrificePowers[player] && !gPlayerUltimateUsed[player] && get_user_team(id) == get_user_team(player)) {
set_task(1.0,"sacrifice_kd", 0)
}
}
}
//-----------------------------------------------------------------------------------------------
// RESPOND TO KEYDOWN
public sacrifice_kd()
{
// First Argument is an id with Sacrifice Powers!
new temp[6]
read_argv(2,temp,5)
new id=str_to_num(temp)
if ( !is_user_alive(id) )
// Let them know they already used their ultimate if they have
if ( gPlayerUltimateUsed[id] ) {
playSoundDenySelect(id)
}
new sacrificeCooldown=get_cvar_num("sacrifice_cooldown")
if ( sacrificeCooldown > 0 )ultimateTimer(id, sacrificeCooldown * 1.0 )
if ( !is_user_connected(id) || is_user_alive(id) ) return
// Look for alive players with unused Sacrifice Powers on the same team
for ( new player = 1; player <= SH_MAXSLOTS; player++ ) {
if ( player != id && is_user_alive(player) && gHasSacrificePowers[player] && !gPlayerUltimateUsed[player] && get_user_team(id) == get_user_team(player) )
{
// We got a Sacrifice character willing to raise the dead!
new parm[2]
parm[0] = id
parm[1] = (player)
set_task(1.0,"sacrifice_respawn", 0, parm, 2)
}
}
}
//----------------------------------------------------------------------------------------------
public sacrifice_respawn(parm[])
{
new dead = parm[0]
new sacrifice = parm[1]
if (gPlayerUltimateUsed[sacrifice] || gBetweenRounds) return
if ( !is_user_connected(dead) || !is_user_connected(sacrifice)) return
if ( !is_user_alive(sacrifice) || is_user_alive(dead) ) return
if ( get_user_team(dead) != get_user_team(sacrifice) ) return
ultimateTimer(sacrifice, get_cvar_float("sacrifice_cooldown"))
emit_sound(sacrifice, CHAN_STATIC, "warcraft3/resurrecttarget.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
new sacrificeName[32],deadName[32]
get_user_name(sacrifice,sacrificeName,31)
get_user_name(dead,deadName,31)
client_print(0,print_chat,"%s used their Sacrificial Powers to Raise Dead Team Member %s!", sacrificeName, deadName )
set_user_health(1, get_user_health(1)-150)
//Double spawn prevents the no HUD glitch (hopefully)
user_spawn(dead)
user_spawn(dead)
emit_sound(dead, CHAN_STATIC, "warcraft3/resurrecttarget.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
shGlow(dead,255,255,0)
set_task(3.0, "sacrifice_unglow", dead)
set_task(1.0, "sacrifice_teamcheck", 0, parm, 2)
}
//----------------------------------------------------------------------------------------------
public sacrifice_unglow(id)
{
shUnglow(id)
}
//----------------------------------------------------------------------------------------------
public sacrifice_teamcheck(parm[])
{
new dead = parm[0]
new sacrifice = parm[1]
if ( get_user_team(dead) != get_user_team(sacrifice) ) {
client_print(dead,print_chat,"You changed teams and got respawned via Sacrifice, now you shall die")
user_kill(dead,1)
gPlayerUltimateUsed[sacrifice] = false
}
}
//----------------------------------------------------------------------------------------------
public round_start()
{
gBetweenRounds = false
}
//----------------------------------------------------------------------------------------------
public round_end()
{
gBetweenRounds = true
}
//----------------------------------------------------------------------------------------------
A VERY crude start of where I would like the final to be.
The way I have the keydown set right now doesn't work, as I was just testing whether or not you could have the power only active when a certain condition is met (dead teammate search from Zeus's code).
If it is even possible, I would like to have a menu show on key down that would display a list of your current team (ct/t). It will hopefully look similar to that of the one for picking heros, with names of dead teammates (one's that can be revived) in white and alive teammates (one's that cannot be revived) in gray. Then when you press the corresponding key, the power would activate on the selected player. If an incorrect target is chosen, a msg would appear saying so and the menu would stay open until a correct target is chosen or is exited via the 0 key.
Well, any help with coding, or just ideas in general are greatly appreciated!