Junior Member
Join Date: Oct 2004
Location: Hannover
|
02-08-2007
, 12:48
inviswoman getting visible when shooting
|
#1
|
i think the topic says everything...
inviswoman:
Code:
//INVISIBLE WOMAN! from the Fantastic Four, Sue Richards psionic ability to manipulate ambient cosmic energy enables her to bend light around her body without distortion.
/* CVARS - copy and paste to shconfig.cfg
//Invisible Woman
inviswoman_level 6
inviswoman_alpha 0 //Value of invisiblity 0-invisible 255-completly visible (default=0)
inviswoman_time 5 //# of seconds of invisiblity
inviswoman_cooldown 30 //# of seconds before invisiblity can be used again from keydown
*/
/*
* v1.1 - vittu - 8/8/05
* - Cleaned up code.
* - Added cvar for alpha value.
* - Changed sound from cows "moo" to a heartbeat, very low volume.
*
*/
#include <amxmod>
#include <superheromod>
// GLOBAL VARIABLES
new gHeroName[]="Invisible Woman"
new bool:gHasInvisWomanPower[SH_MAXSLOTS+1]
new gInvisWomanTimer[SH_MAXSLOTS+1]
new gInvisWomanMode[SH_MAXSLOTS+1]
new gAlpha
new gInvisWomanSound[]="player/heartbeat1.wav"
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO Invisible Woman", "1.1", "Glooba")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("inviswoman_level", "6")
register_cvar("inviswoman_alpha", "0")
register_cvar("inviswoman_time", "5")
register_cvar("inviswoman_cooldown", "30")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName, "Invisibility", "Press +power key to become invisible for a short period of time", true, "inviswoman_level")
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
// INIT
register_srvcmd("inviswoman_init", "inviswoman_init")
shRegHeroInit(gHeroName, "inviswoman_init")
// KEY DOWN
register_srvcmd("inviswoman_kd", "inviswoman_kd")
shRegKeyDown(gHeroName, "inviswoman_kd")
// NEW SPAWN
register_event("ResetHUD", "newSpawn", "b")
// DEATH
register_event("DeathMsg", "inviswoman_death", "a")
// LOOP
set_task(1.0, "inviswoman_loop", 0, "", 0, "b")
}
//----------------------------------------------------------------------------------------------
public plugin_precache()
{
precache_sound(gInvisWomanSound)
}
//----------------------------------------------------------------------------------------------
public inviswoman_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
read_argv(2, temp, 5)
new hasPowers = str_to_num(temp)
if ( hasPowers ) {
// Make sure looop doesn't fire for them
gInvisWomanTimer[id] = -1
}
//This gets run if they had the power but don't anymore
else if ( gHasInvisWomanPower[id] && gInvisWomanTimer[id] >= 0 ) {
inviswoman_endmode(id)
}
//Sets this variable to the current status
gHasInvisWomanPower[id] = (hasPowers != 0)
}
//----------------------------------------------------------------------------------------------
public newSpawn(id)
{
gPlayerUltimateUsed[id] = false
gInvisWomanTimer[id] = -1
if ( gHasInvisWomanPower[id] ) {
inviswoman_endmode(id)
}
}
//----------------------------------------------------------------------------------------------
// RESPOND TO KEYDOWN
public inviswoman_kd()
{
if ( !hasRoundStarted() ) return
// First Argument is an id
new temp[6]
read_argv(1,temp,5)
new id = str_to_num(temp)
if ( !is_user_alive(id) || !gHasInvisWomanPower[id] ) return
// Make sure they're not in the middle of invisible woman mode
// Let them know they already used their ultimate if they have
if ( gPlayerUltimateUsed[id] || gInvisWomanTimer[id] > 0 ) {
playSoundDenySelect(id)
return
}
gInvisWomanTimer[id] = get_cvar_num("inviswoman_time")
if (get_cvar_float("inviswoman_cooldown") > 0.0 ) ultimateTimer(id, get_cvar_float("inviswoman_cooldown"))
gAlpha = get_cvar_num("inviswoman_alpha")
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, gAlpha)
gInvisWomanMode[id] = true
new message[128]
format(message, 127, "You have now turned invisible")
set_hudmessage(50, 50, 255, -1.0, 0.28, 0, 0.0, 1.0, 0.0, 0.0, 54)
show_hudmessage(id, message)
emit_sound(id, CHAN_STATIC, gInvisWomanSound, 0.1, ATTN_NORM, 0, PITCH_NORM)
}
//----------------------------------------------------------------------------------------------
public stopSound(id)
{
new SND_STOP = (1<<5)
emit_sound(id, CHAN_STATIC, gInvisWomanSound, 0.1, ATTN_NORM, SND_STOP, PITCH_NORM)
}
//----------------------------------------------------------------------------------------------
public inviswoman_loop()
{
for ( new id = 1; id <= SH_MAXSLOTS; id++ ) {
if ( gHasInvisWomanPower[id] && is_user_alive(id) ) {
if ( gInvisWomanTimer[id] > 0 ) {
new message[128]
format(message, 127, "%d second%s left of invisibility", gInvisWomanTimer[id], gInvisWomanTimer[id] == 1 ? "" : "s")
set_hudmessage(50, 50, 255, -1.0, 0.28, 0, 0.0, 1.0, 0.0, 0.0, 54)
show_hudmessage(id, message)
set_user_rendering(id, kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, gAlpha)
gInvisWomanTimer[id]--
}
else if ( gInvisWomanTimer[id] == 0 ) {
gInvisWomanTimer[id]--
inviswoman_endmode(id)
}
}
}
}
//----------------------------------------------------------------------------------------------
public inviswoman_endmode(id)
{
if ( !is_user_connected(id) ) return
gInvisWomanTimer[id] = -1
stopSound(id)
if ( gInvisWomanMode[id]) {
set_user_rendering(id)
gInvisWomanMode[id] = false
}
}
//----------------------------------------------------------------------------------------------
public inviswoman_death()
{
new id = read_data(2)
gPlayerUltimateUsed[id] = false
gInvisWomanTimer[id] = -1
if (gHasInvisWomanPower[id]) {
inviswoman_endmode(id)
}
}
//----------------------------------------------------------------------------------------------
invisman:
Code:
//Invisible Man
/* CVARS - copy and paste to shconfig.cfg
//Invisible Man
invisman_level 0
invisman_alpha 50 //Alpha level when invisible. 0 = invisible, 255 = full visibility.
invisman_delay 5 //Time a player must be still to become invisible
invisman_checkmove 1 //Should movement be checked, or only shooting? 0 = only check shooting
*/
#include <amxmod>
#include <Vexd_Utilities>
#include <superheromod>
#if defined AMX98
#include <xtrafun> //Only for the constants, doesn't use any functions
#endif
// VARIABLES
new gHeroName[]="Invisible Man"
new bool:gHasInvisPower[SH_MAXSLOTS+1]
new gIsInvisible[SH_MAXSLOTS+1]
new gStillTime[SH_MAXSLOTS+1]
//----------------------------------------------------------------------------------------------
public plugin_init()
{
// Plugin Info
register_plugin("SUPERHERO The Invisible Man","1.1","AssKicR")
// DO NOT EDIT THIS FILE TO CHANGE CVARS, USE THE SHCONFIG.CFG
register_cvar("invisman_level", "0")
register_cvar("invisman_alpha", "50")
register_cvar("invisman_delay", "5")
register_cvar("invisman_checkmove", "1")
// FIRE THE EVENT TO CREATE THIS SUPERHERO!
shCreateHero(gHeroName, "Invisibility", "Makes you less visible and harder to see. Only works while standing/not shooting and not zooming.", false, "invisman_level" )
// REGISTER EVENTS THIS HERO WILL RESPOND TO! (AND SERVER COMMANDS)
register_event("ResetHUD","newRound","b")
register_event("Damage", "invisman_damage", "b", "2!0")
// INIT
register_srvcmd("invisman_init", "invisman_init")
shRegHeroInit(gHeroName, "invisman_init")
// CHECK SOME BUTTONS
set_task(0.1,"checkButtons",0,"",0,"b")
}
//----------------------------------------------------------------------------------------------
public invisman_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 flash
read_argv(2,temp,5)
new hasPowers = str_to_num(temp)
gHasInvisPower[id] = (hasPowers != 0)
//Give Powers to the Invisible Man
if ( !gHasInvisPower[id] ) remInvisibility(id)
}
//----------------------------------------------------------------------------------------------
public newRound(id)
{
remInvisibility(id)
}
//----------------------------------------------------------------------------------------------
public setInvisibility(id, alpha)
{
if (alpha < 125) {
set_user_rendering(id,kRenderFxGlowShell,8,8,8,kRenderTransAlpha,alpha)
}
else {
set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,alpha)
}
}
//----------------------------------------------------------------------------------------------
public remInvisibility(id)
{
gStillTime[id] = -1
if (gIsInvisible[id] > 0) {
shUnglow(id)
client_print(id,print_center,"[SH]Invisible Man: You are no longer cloaked")
}
gIsInvisible[id] = 0
}
//----------------------------------------------------------------------------------------------
public checkButtons()
{
if ( !hasRoundStarted() || !shModActive()) return
new bool:setVisible
new butnprs
for(new id = 1; id <= SH_MAXSLOTS; id++) {
if (!is_user_alive(id) || !gHasInvisPower[id]) continue
setVisible = false
butnprs = Entvars_Get_Int(id, EV_INT_button)
//Always check these
if (butnprs&IN_ATTACK || butnprs&IN_ATTACK2 || butnprs&IN_RELOAD || butnprs&IN_USE) setVisible = true
//Only check these if invisman_checkmove is off
if ( get_cvar_num("invisman_checkmove") ) {
if (butnprs&IN_JUMP) setVisible = true
if (butnprs&IN_FORWARD || butnprs&IN_BACK || butnprs&IN_LEFT || butnprs&IN_RIGHT) setVisible = true
if (butnprs&IN_MOVELEFT || butnprs&IN_MOVERIGHT) setVisible = true
}
if (setVisible) remInvisibility(id)
else {
new sysTime = get_systime()
new delay = get_cvar_num("invisman_delay")
if ( gStillTime[id] < 0 ) {
gStillTime[id] = sysTime
}
if ( sysTime - delay >= gStillTime[id] ) {
if (gIsInvisible[id] != 100) client_print(id,print_center,"[SH]Invisible Man: 100%s cloaked", "%")
gIsInvisible[id] = 100
setInvisibility(id, get_cvar_num("invisman_alpha"))
}
else if ( sysTime > gStillTime[id] ) {
new alpha = get_cvar_num("invisman_alpha")
new Float:prcnt = float(sysTime - gStillTime[id]) / float(delay)
new rPercent = floatround(prcnt * 100)
alpha = floatround(255 - ((255 - alpha) * prcnt) )
client_print(id,print_center,"[SH]Invisible Man: %d%s cloaked", rPercent, "%")
gIsInvisible[id] = rPercent
setInvisibility(id, alpha)
}
}
}
}
//----------------------------------------------------------------------------------------------
public invisman_damage(id)
{
if (!shModActive() || !gHasInvisPower[id] ) return
remInvisibility(id)
}
//----------------------------------------------------------------------------------------------
like invisMAN invisWOMAN should get visible, when the player's shooting... NOT when moving, this would be silly ^^
|
|