Code:
#include <amxmod.inc>
#include <xtrafun>
#include <Vexd_Utilities>
#include <superheromod.inc>
// MiRAGE - You Will See Nothing
// CVARS
// mirage_cooldown # of seconds before mirage can NoClip Again
// mirage_cliptime # of seconds mirage has in noclip mode.
// mirage_level - What level till they can use mirage (Default 15)
// mirage_speed - How fast can this mirage run? (Default 375)
// mirage_health - How much health for mirage? (Default 125)
// mirage_armor - How much armor for mirage? (Default 120)
// mirage_delay – How long does it take to kick in
// VARIABLES
new gHeroName[]="MiRAGE" //Name Of The Hereo
new bool:gHasmiragePower[SH_MAXSLOTS+1]
new g_mirageTimer[SH_MAXSLOTS+2]
new g_lastPosition[SH_MAXSLOTS+3][3];
new g_mirageSound[]="ambience/alien_zonerator.wav"
new gmirageShield
new gmirageId
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO MiRAGE","1.0","p4haze") //Register The Plugin (name,version,creator)
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
if ( isDebugOn() ) server_print("Attempting to create MiRAGE Hero")
register_cvar("mirage_level", "20" )
shCreateHero(gHeroName, "Phase/Health/Spee/Arm/Proto", "Can Phase Through Walls for Short Time - GET Lost AND YOU'LL BE SLAYED", true, "mirage_level")
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
register_event("ResetHUD","newRound","b")
// WHAT MOD IS RUNNING
register_event("CurWeapon","changeWeapon","be","1=1")
// KEY DOWN
register_srvcmd("mirage_kd", "mirage_kd")
shRegKeyDown(gHeroName, "mirage_kd")
// INIT
register_srvcmd("mirage_init", "mirage_init")
shRegHeroInit(gHeroName, "mirage_init")
// LOOP
register_srvcmd("mirage_loop", "mirage_loop")
//shRegLoop1P0(gHeroName, "mirage_loop", "ac" ) // Alive MiRAGEHeros="ac"
set_task(1.0,"mirage_loop",0,"",0,"b" )
// DEATH
register_event("DeathMsg", "mirage_death", "a")
// CHECK SOME BUTTONS
set_task(0.01,"check_attack",0,"",0,"b")
set_task(0.01,"check_two_buttons",0,"",0,"b")
set_task(0.01,"check_move_buttons",0,"",0,"b")
// DEFAULT THE CVARS
register_cvar("mirage_cooldown", "30" )
register_cvar("mirage_cliptime", "10"
register_cvar("mirage_gravity", "375" )
register_cvar("mirage_health", "250" )
register_cvar("mirage_armor", "150" )
register_cvar("mirage_delay", "1.0")
shSetMaxSpeed(gHeroName, "mirage_speed","[0]")
shSetMaxHealth(gHeroName, "mirage_health" )
shSetMaxArmor(gHeroName, "mirage_armor" )
}
//----------------------------------------------------------------------------------------------
public mirage_damage(id)
{
new weapon, bodypart, attacker = get_user_attacker(id,weapon,bodypart)
if (!shModActive() || !gHasmiragePower[attacker] || gPlayerUltimateUsed[id] ) return PLUGIN_CONTINUE
if ( is_user_alive(id) && id != attacker )
{
if ( !gHasmiragePower[attacker] ) return PLUGIN_HANDLED
if ( gPlayerUltimateUsed[attacker] )
{
playSoundDenySelect(attacker)
return PLUGIN_HANDLED
}
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
sh_screenShake(attacker, 14, 14, 14 )
ultimateTimer(attacker, get_cvar_num("mirage_cooldown") * 0.5)
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public mirage_init()
{
new temp[6]
// First Argument is an id
read_argv(1,temp,5)
new id=str_to_num(temp)
// 2nd Argument is 0 or 1 depending on whether the id has iron man powers
read_argv(2,temp,5)
new hasPowers=str_to_num(temp)
if ( !hasPowers )
{
if ( is_user_alive(id) && g_mirageTimer[id]>=0 && gHasmiragePower[id] )
{
invis(id)
mirage_endnoclip(id)
uninvis(id)
set_user_rendering(id)
}
}
else
{
g_mirageTimer[id]=-1 // Make sure looop doesn't fire for em... 1.14.4-b check
}
gHasmiragePower[id]=(hasPowers!=0)
}
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
// precache_sound("mirage/mirage.wav")
}
//----------------------------------------------------------------------------------------------
// RESPOND TO KEYDOWN
public mirage_kd()
{
new temp[6]
// First Argument is an id with mirage Powers!
read_argv(1,temp,5)
new id=str_to_num(temp)
if ( !is_user_alive(id) ) return PLUGIN_HANDLED
// Let them know they already used their ultimate if they have
if ( gPlayerUltimateUsed[id] )
{
playSoundDenySelect(id)
return PLUGIN_HANDLED
}
// Make sure they're not in the middle of clip already
if ( g_mirageTimer[id]>0 ) return PLUGIN_HANDLED
g_mirageTimer[id]=get_cvar_num("mirage_cliptime")+1
set_user_noclip(id,1)
ultimateTimer(id, get_cvar_num("mirage_cooldown") * 1.0)
// MiRAGE Messsage
new message[128]
format(message, 127, "Entered Phase Mode - Don't get Stuck or you will die" )
set_hudmessage(255,0,0,-1.0,0.3,0,0.25,1.0,0.0,0.0,4)
show_hudmessage(id, message)
emit_sound(id,CHAN_STATIC, g_mirageSound, 0.1, ATTN_NORM, 0, PITCH_LOW)
return PLUGIN_HANDLE
}
//----------------------------------------------------------------------------------------------
public newRound()
{
gPlayerUltimateUsed[id]=false
g_miragerTimer[id]=-1
if (is_user_alive(id) && get_user_noclip(id) ) set_user_noclip(id,0)
return PLUGIN_HANDLED
{
if ( miragePowers[id] && is_user_alive(id) && shModActive() )
{
mirage_glock(id)
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public mirage_loop()
{
for ( new id=1; id<=SH_MAXSLOTS; id++ )
{
if ( gHasmiragePower[id] && is_user_alive(id) )
{
if ( g_mirageTimer[id]>0 )
{
g_mirageTimer[id]--
new message[128]
format(message, 127, "%d seconds left of Phase Mode - Don't get Stuck or you will die", g_mirageTimer[id] )
set_hudmessage(255,0,0,-1.0,0.3,0,1.0,1.0,0.0,0.0,4)
show_hudmessage( id, message)
}
else
{
if ( g_mirageTimer[id] == 0 )
{
g_mirageTimer[id]--
mirage_endnoclip(id)
stopSound(id)
}
}
}
}
}
//----------------------------------------------------------------------------------------------
public mirage_endnoclip()
{
g_mirageTimer[id]=0
if ( get_user_noclip(id) == 1)
{
// Turn off no-clipping and make sure the user has moved in 1/4 second
stopSound(id)
g_mirageTimer[id]=-1
set_user_noclip(id,0)
if ( is_user_alive(id) ) positionChangeTimer(id, 0.1 )
}
}
//----------------------------------------------------------------------------------------------
public mirage_death()
{
new id=read_data(2)
mirage_endnoclip(id)
gPlayerUltimateUsed[id]=false
}
//----------------------------------------------------------------------------------------------
public positionChangeTimer(id, Float: secs)
{
new origin[3]
new velocity[3]
if ( !is_user_alive(id) ) return
get_user_origin(id, origin, 0)
g_lastPosition[id][0]=origin[0]
g_lastPosition[id][1]=origin[1]
g_lastPosition[id][2]=origin[2]
get_user_velocity(id, velocity)
if ( velocity[0]==0 && velocity[1]==0 && velocity[2] )
{
// Force a Move (small jump)
velocity[0]=50
velocity[1]=50
set_user_velocity(id, velocity)
}
new parm[1]
parm[0]=id
set_task(secs,"positionChangeCheck",0,parm,1)
}
//----------------------------------------------------------------------------------------------
public positionChangeCheck( parm[1] )
{
new id=parm[0]
new origin[3]
if (!is_user_alive(id) ) return
get_user_origin(id, origin, 0)
if ( g_lastPosition[id][0] == origin[0] && g_lastPosition[id][1] == origin[1] && g_lastPosition[id][2] == origin[2] && is_user_alive(id) )
{
// Kill this player - MiRAGE Still Stuck in wall!
set_user_health(id, -1)
set_user_frags(id, get_user_frags(id)-1)
}
}
//----------------------------------------------------------------------------------------------
public changeWeapon(id)
{
if ( !ghasMiRAGEPowers[id] || !shModActive() ) return PLUGIN_CONTINUE
new clip, ammo
new wpn_id=get_user_weapon(id, clip, ammo);
new wpn[32]
if ( wpn_id!=CSW_GLOCK18 ) return PLUGIN_CONTINUE
// Never Run Out of Ammo!
//server_print("STATUS ID=%d CLIP=%d, AMMO=%d WPN=%d", id, clip, ammo, wpn_id)
if ( clip == 0 )
{
//server_print("INVOKING MiRAGE MODE! ID=%d CLIP=%d, AMMO=%d WPN=%d", id, clip, ammo, wpn_id)
get_weaponname(wpn_id,wpn,31)
//highly recommend droppging weapon - buggy without it!
give_item(id,wpn)
engclient_cmd(id, wpn )
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public mirage_glock(id)
{
shGiveWeapon(id,"weapon_glock18")
shGiveWeapon(id,"ammo_9mm")
}
//----------------------------------------------------------------------------------------------
public invis(id) {
if (gPlayerUltimateUsed[id]==false) {
set_user_rendering(id,kRenderFxGlowShell,255,0,0,kRenderNormal,16)
gmirageShield=1
}
}
//----------------------------------------------------------------------------------------------
public uninvis(id) {
set_user_rendering(id,kRenderFxGlowShell,100,100,100,kRenderNormal,16)
gmirageShield=0
}
//----------------------------------------------------------------------------------------------
public check_attack() {
for(new i = 1; i <= get_maxplayers(); ++i) {
if (is_user_alive(i)) {
if ((get_user_button(i)&IN_ATTACK) && gHasmiragePower[i]) {
ultimateTimer(gmirageId, Float:get_cvar_float("mirage_delay"))
uninvis(i)
}
else if (!(get_user_button(i)&IN_ATTACK) && gHasmiragePower[i]) {
invis(i)
}
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public check_two_buttons() {
for(new i = 1; i <= get_maxplayers(); ++i) {
if (is_user_alive(i)) {
if ((get_user_button(i)&IN_USE) && gHasmiragePower[i]) {
uninvis(i)
}
if ((get_user_button(i)&IN_ATTACK2) && gHasmiragePower[i]) {
uninvis(i)
}
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public check_move_buttons() {
for(new i = 1; i <= get_maxplayers(); ++i) {
if (is_user_alive(i)) {
if ((get_user_button(i)&IN_BACK) && gHasmiragePower[i]) {
uninvis(i)
}
if ((get_user_button(i)&IN_MOVELEFT) && gHasmiragePower[i]) {
uninvis(i)
}
if ((get_user_button(i)&IN_MOVERIGHT) && gHasmiragePower[i]) {
uninvis(i)
}
if ((get_user_button(i)&IN_FORWARD) && gHasmiragePower[i]) {
uninvis(i)
}
if ((get_user_button(i)&IN_RUN) && gHasmiragePower[i]) {
uninvis(i)
}
}
}
return PLUGIN_CONTINUE
}
//----------------------------------------------------------------------------------------------
public mirage_damage() {
new id=gmirageId
if (gmirageShield==1) {
new damage = read_data(2) //This reads the damage done to ID
new weapon, bodypart = get_user_attacker(id,weapon,bodypart)
if (weapon!=CSW_KNIFE) {
shAddHPs(id, (damage), 1000)//Nullify damage
}
}
}
//----------------------------------------------------------------------------------------------