AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with teleport smoke (https://forums.alliedmods.net/showthread.php?t=336204)

Arje 02-03-2022 15:46

Help with teleport smoke
 
Hi, my problem is I would like the smoke to be created normally if I don't have the "batman" power on.

at the moment, i only get the "smoke teleport" when i have "batman" on, but when i don't have it the smoke is not created as it would normally be

PHP Code:

#include <amxmod>
#include <superheromod>
#include <cstrike>
#include <fakemeta>

#define SMOKE_SCALE 30
#define SMOKE_FRAMERATE 12
#define SMOKE_GROUND_OFFSET 6

// GLOBAL VARIABLES
new gHeroID
new const gHeroName[] = "Batman"
new bool:gHasBatman[SH_MAXSLOTS+1]

// do not edit
new const g_sound_explosion[] = "weapons/sg_explode.wav"
new const g_classname_grenade[] = "grenade"

new const Float:g_sign[4][2] = {{1.01.0}, {1.0, -1.0}, {-1.0, -1.0}, {-1.01.0}}

new 
g_spriteid_steam1
new g_eventid_createsmoke

//----------------------------------------------------------------------------------------------
public plugin_init()
{
    
// FIRE THE EVENTS TO CREATE THIS SUPERHERO!
        
new pcvarLevel register_cvar("batman_level""0")
    
gHeroID sh_create_hero(gHeroNamepcvarLevel)
    
sh_set_hero_info(gHeroID"BatiCinturon.""Obten Armas, ademas de HP/AP - Compra balas!!")

    
// eventos del tp smoke
    
register_forward(FM_EmitSound"forward_emitsound")
    
register_forward(FM_PlaybackEvent"forward_playbackevent")
    
// we do not precaching, but retrieving the indexes
    
g_spriteid_steam1 engfunc(EngFunc_PrecacheModel"sprites/steam1.spr")
    
g_eventid_createsmoke engfunc(EngFunc_PrecacheEvent1"events/createsmoke.sc")
}
//-------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
public sh_hero_init(idheroIDmode)
{
    if ( 
gHeroID != heroID ) return

    switch(
mode) {
        case 
SH_HERO_ADD: {
            
gHasBatman[id] = true
            
        
}
        case 
SH_HERO_DROP: {
            
gHasBatman[id] = false
            
        
}
    }

    
sh_debug_message(id1"%s %s"gHeroNamemode "ADDED" "DROPPED")
}
//----------------------------------------------------------------------------------------------
public client_connect(id)
{
    
gHasBatman[id] = false
}
// - - - - - - - - - -- - TODO D ACA PARA ABAJO ES DLE TP SMOKE -------
//----------------------------------------------------------------------------------------------
public forward_emitsound(entchannel, const sound[]) 
{    
    if (!
equal(soundg_sound_explosion) || !is_grenade(ent))
        return 
FMRES_IGNORED

    
static idFloat:origin[3]
    
id pev(entpev_owner)
    
pev(entpev_originorigin)
    
engfunc(EngFunc_EmitSoundentCHAN_WEAPONg_sound_explosionVOL_NORMATTN_NORM0PITCH_NORM)
    
engfunc(EngFunc_RemoveEntityent)
    
origin[2] += SMOKE_GROUND_OFFSET
    create_smoke
(origin)
    
    if (
is_user_alive(id) && gHasBatman[id]) {
        static 
Float:mins[3], hull
        pev
(idpev_minsmins)
        
origin[2] -= mins[2] + SMOKE_GROUND_OFFSET
        hull 
pev(idpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN
        
if (is_hull_vacant(originhull))
            
engfunc(EngFunc_SetOriginidorigin)
        else { 
// close to a solid object, trying to find a vacant spot
            
static Float:vec[3]
            
vec[2] = origin[2]
            for (new 
isizeof g_sign; ++i) {
                
vec[0] = origin[0] - mins[0] * g_sign[i][0]
                
vec[1] = origin[1] - mins[1] * g_sign[i][1]
                if (
is_hull_vacant(vechull)) {
                    
engfunc(EngFunc_SetOriginidvec)
                    break
                }
            }
        }
    }

    return 
FMRES_SUPERCEDE
}

public 
forward_playbackevent(flagsinvokereventindex
{
    new 
id=read_data(2)
    
    if ( !
shModActive() || !is_user_alive(id) || !gHasBatman[id] ) 
        return 
FMRES_SUPERCEDE
    
    
// we do not need a large amount of smoke
    
if( gHasBatman[id] && eventindex == g_eventid_createsmoke)
        return 
FMRES_SUPERCEDE
            
    
return FMRES_IGNORED
}

bool:is_grenade(ent
{
    if (!
pev_valid(ent))
        return 
false

    
static classname[sizeof g_classname_grenade 1]
    
pev(entpev_classnameclassnamesizeof g_classname_grenade)
    if (
equal(classnameg_classname_grenade))
        return 
true

    
return false
}

create_smoke(const Float:origin[3]) 
{
    
// engfunc because origin are float
    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYorigin0)
    
write_byte(TE_SMOKE)
    
engfunc(EngFunc_WriteCoordorigin[0])
    
engfunc(EngFunc_WriteCoordorigin[1])
    
engfunc(EngFunc_WriteCoordorigin[2])
    
write_short(g_spriteid_steam1)
    
write_byte(SMOKE_SCALE)
    
write_byte(SMOKE_FRAMERATE)
    
message_end()
    
}

stock bool:is_hull_vacant(const Float:origin[3], hull
{
    new 
tr 0
    engfunc
(EngFunc_TraceHulloriginorigin0hull0tr)
    if (!
get_tr2(trTR_StartSolid) && !get_tr2(trTR_AllSolid) && get_tr2(trTR_InOpen))
        return 
true
    
    
return false




All times are GMT -4. The time now is 11:36.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.