Raised This Month: $32 Target: $400
 8% 

[Help]Reset func_train


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 04-09-2015 , 18:30   [Help]Reset func_train
Reply With Quote #1

Hi,
Please, tell me, how I can stop func_piaceofshit func_train(deactivate him);
I tried many ways, use all avaible offsets, try to find offsets, read HLSrc and find used pev.

PHP Code:
const m_activated 81
Invalid offset, value 0 everytime.

I reset all values, but I can't turn it off completely.
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 04-12-2015 at 15:19.
Hedgehog Fog is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 04-12-2015 , 15:19   Re: [Help]Reset func_train
Reply With Quote #2

Hey... Any ideas?
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities
Hedgehog Fog is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 04-14-2015 , 07:33   Re: [Help]Reset func_train
Reply With Quote #3

What do you exactly mean with 'deactivate'?
mottzi is offline
Send a message via MSN to mottzi
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 04-15-2015 , 00:49   Re: [Help]Reset func_train
Reply With Quote #4

mottzi
I mean stop func_train and return to the start position.

P.S: m_activated valid, but sometimes(in priority) activated train ruturn 0 as m_activated value.

Not working:

PHP Code:
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <hamsandwich>
 
#define PLUGIN "[ZI]func_pieceofshit"
#define VERSION "0.2"
#define AUTHOR "Zombie Invasion"
 
const m_pevCurrentTarget 79;
const 
m_activated 81;  
 
public 
plugin_init()
{
        
register_plugin(PLUGINVERSIONAUTHOR);
        
log_amx("%s %s by %s Loaded"PLUGINVERSIONAUTHOR);
        
register_clcmd("dbgtr""clcmd_dbgtr");
        
register_logevent("logevent_round_start"2"1=Round_Start");
}
 
public 
logevent_round_start()
{
        new 
ent 0;
        while((
ent engfunc(EngFunc_FindEntityByStringent"classname""func_train")) > 0)
                
ent_reset_train(ent);
}
 
stock ent_reset_train(ent)
{
        
clcmd_dbgtr(ent);
 
        
set_pev(entpev_velocity0);
        
set_pev(entpev_message0);
        
set_pev(entpev_enemy0);
        
set_pev(entpev_spawnflagsSF_TRAIN_WAIT_RETRIGGER);
        
set_pdata_int(entm_activated0);
        
set_pdata_string(entm_pevCurrentTarget""14);
       
        
clcmd_dbgtr(ent);
}
 
stock clcmd_dbgtr(ent)
{      
        new 
Float:velocity[3];
        static 
str[32];
       
        
pev(entpev_velocityvelocity);
        
log_amx("velocity: {%f %f %f}"velocity[0], velocity[1], velocity[2]);
        
pev(entpev_messagestrcharsmax(str));
        
log_amx("message: %s"str);
        
log_amx("enemy: %d"pev(entpev_enemy));
        
log_amx("spawnflags: %d"pev(entpev_spawnflags));
        
get_pdata_string(entm_pevCurrentTargetstrcharsmax(str), 14);
        
log_amx("m_pevCurrentTarget: %d"str);
       
        
hr();
}
 
stock hr()
{
        
log_amx("--------------------------------");

__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 04-15-2015 at 00:58.
Hedgehog Fog is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 04-15-2015 , 03:17   Re: [Help]Reset func_train
Reply With Quote #5

How about looping through all func_train entities in plugin_init, storing their origins in a global array and then reset the origin when you want it?
mottzi is offline
Send a message via MSN to mottzi
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 04-15-2015 , 03:56   Re: [Help]Reset func_train
Reply With Quote #6

I already try this method, I save pev_target to global array and set this value to pev_target. I try to emit engine DLLFunc_Think and HAM_CS_Restart after set the values.
Brush entity default origin is {0, 0, 0}. I need to find all and replace all values to default, but I don't know what values I need. Found values:
  • pev_nextthink - 0 by default
  • pev_velocity - g_vecZero by default
  • pev_target - key target value by default
  • pev_message - 0 by default
  • pev_enemy - 0 by default
  • pev_spawnflags - "pev_spawnflags | SF_TRAIN_WAIT_RETRIGGER" by default
  • m_pevCurrentTarget - 0 by default
  • m_activated - 0 by default
  • m_pfnThink - 0 by default
  • m_pfnCallWhenMoveDone - 0 by defa
  • m_vecFinalDest - g_vecZero by defa
  • m_vecFinalAngle - g_vecZero by default

PHP Code:
new const g_vecZero[3] = {000};

const 
m_pevCurrentTarget 79;
const 
m_activated 81;
const 
m_pfnThink 4;
const 
m_pfnCallWhenMoveDone 64;

new const 
m_vecFinalDest[3] = {65, ...};
new const 
m_vecFinalAngle[3] = {68, ...};

//I dont know how to use:
const m_hEnemy_serialnumber 85;
const 
m_hTargetEnt 86;
const 
m_hEnemy 84
From plats.cpp:
Quote:
PHP Code:
void CFuncTrain :: Use( CBaseEntity *pActivatorCBaseEntity *pCallerUSE_TYPE useTypefloat value )
{
    if ( 
pev->spawnflags SF_TRAIN_WAIT_RETRIGGER )
    {
        
// Move toward my target
        
pev->spawnflags &= ~SF_TRAIN_WAIT_RETRIGGER;
        
Next();
    }
    else
    {
        
pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER;
        
// Pop back to last target if it's available
        
if ( pev->enemy )
            
pev->target pev->enemy->v.targetname;
        
pev->nextthink 0;
        
pev->velocity g_vecZero;
        if ( 
pev->noiseStopMoving )
            
EMIT_SOUND (ENT(pev), CHAN_VOICE, (char*)STRING(pev->noiseStopMoving), m_volumeATTN_NORM);
    }
}

void CFuncTrain :: Waitvoid )
{
    
// Fire the pass target if there is one
    
if ( m_pevCurrentTarget->message )
    {
        
FireTargetsSTRING(m_pevCurrentTarget->message), thisthisUSE_TOGGLE);
        if ( 
FBitSetm_pevCurrentTarget->spawnflagsSF_CORNER_FIREONCE ) )
            
m_pevCurrentTarget->message 0;
    }
        
    
// need pointer to LAST target.
    
if ( FBitSet (m_pevCurrentTarget->spawnflags SF_TRAIN_WAIT_RETRIGGER ) || ( pev->spawnflags SF_TRAIN_WAIT_RETRIGGER ) )
    {
        
pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER;
        
// clear the sound channel.
        
if ( pev->noiseMovement )
            
STOP_SOUNDedict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) );
        if ( 
pev->noiseStopMoving )
            
EMIT_SOUND (ENT(pev), CHAN_VOICE, (char*)STRING(pev->noiseStopMoving), m_volumeATTN_NORM);
        
pev->nextthink 0;
        return;
    }
    
    
// ALERT ( at_console, "%f\n", m_flWait );

    
if (m_flWait != 0)
    {
// -1 wait will wait forever!        
        
pev->nextthink pev->ltime m_flWait;
        if ( 
pev->noiseMovement )
            
STOP_SOUNDedict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) );
        if ( 
pev->noiseStopMoving )
            
EMIT_SOUND (ENT(pev), CHAN_VOICE, (char*)STRING(pev->noiseStopMoving), m_volumeATTN_NORM);
        
SetThink( &CFuncTrain::Next );
    }
    else
    {
        
Next();// do it RIGHT now!
    
}
}


//
// Train next - path corner needs to change to next target 
//
void CFuncTrain :: Nextvoid )
{
    
CBaseEntity    *pTarg;

    
    
// now find our next target
    
pTarg GetNextTarget();

    if ( !
pTarg )
    {
        if ( 
pev->noiseMovement )
            
STOP_SOUNDedict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) );
        
// Play stop sound
        
if ( pev->noiseStopMoving )
            
EMIT_SOUND (ENT(pev), CHAN_VOICE, (char*)STRING(pev->noiseStopMoving), m_volumeATTN_NORM);
        return;
    }

    
// Save last target in case we need to find it again
    
pev->message pev->target;

    
pev->target pTarg->pev->target;
    
m_flWait pTarg->GetDelay();

    if ( 
m_pevCurrentTarget && m_pevCurrentTarget->speed != )
    {
// don't copy speed from target if it is 0 (uninitialized)
        
pev->speed m_pevCurrentTarget->speed;
        
ALERTat_aiconsole"Train %s speed to %4.2f\n"STRING(pev->targetname), pev->speed );
    }
    
m_pevCurrentTarget pTarg->pev;// keep track of this since path corners change our target for us.

    
pev->enemy pTarg->edict();//hack

    
if(FBitSet(m_pevCurrentTarget->spawnflagsSF_CORNER_TELEPORT))
    {
        
// Path corner has indicated a teleport to the next corner.
        
SetBits(pev->effectsEF_NOINTERP);
        
UTIL_SetOrigin(pevpTarg->pev->origin - (pev->mins pev->maxs)* 0.5);
        
Wait(); // Get on with doing the next path corner.
    
}
    else
    {
        
// Normal linear move.
        
        // CHANGED this from CHAN_VOICE to CHAN_STATIC around OEM beta time because trains should
        // use CHAN_STATIC for their movement sounds to prevent sound field problems.
        // this is not a hack or temporary fix, this is how things should be. (sjb).
        
if ( pev->noiseMovement )
            
STOP_SOUNDedict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) );
        if ( 
pev->noiseMovement )
            
EMIT_SOUND (ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMovement), m_volumeATTN_NORM);
        
ClearBits(pev->effectsEF_NOINTERP);
        
SetMoveDone( &CFuncTrain::Wait );
        
LinearMove (pTarg->pev->origin - (pev->mins pev->maxs)* 0.5pev->speed);
    }
}


void CFuncTrain :: Activatevoid )
{
    
// Not yet active, so teleport to first target
    
if ( !m_activated )
    {
        
m_activated TRUE;
        
entvars_t    *pevTarg VARSFIND_ENTITY_BY_TARGETNAME (NULLSTRING(pev->target) ) );
        
        
pev->target pevTarg->target;
        
m_pevCurrentTarget pevTarg;// keep track of this since path corners change our target for us.
    
        
UTIL_SetOrigin    (pevpevTarg->origin - (pev->mins pev->maxs) * 0.5 );
        
        if ( 
FStringNull(pev->targetname) )
        {    
// not triggered, so start immediately
            
pev->nextthink pev->ltime 0.1;
            
SetThink( &CFuncTrain::Next );
        }
        else
            
pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER;
    }
}

/*QUAKED func_train (0 .5 .8) ?
Trains are moving platforms that players can ride.
The targets origin specifies the min point of the train at each corner.
The train spawns at the first target it is pointing at.
If the train is the target of a button or trigger, it will not begin moving until activated.
speed    default 100
dmg        default    2
sounds
1) ratchet metal
*/

void CFuncTrain :: Spawnvoid )
{
    
Precache();
    if (
pev->speed == 0)
        
pev->speed 100;
    
    if ( 
FStringNull(pev->target) )
        
ALERT(at_console"FuncTrain with no target");
    
    if (
pev->dmg == 0)
        
pev->dmg 2;
    
    
pev->movetype MOVETYPE_PUSH;
    
    if ( 
FBitSet (pev->spawnflagsSF_TRACKTRAIN_PASSABLE) )
        
pev->solid        SOLID_NOT;
    else
        
pev->solid        SOLID_BSP;

    
SET_MODELENT(pev), STRING(pev->model) );
    
UTIL_SetSize (pevpev->minspev->maxs);
    
UTIL_SetOrigin(pevpev->origin);

    
m_activated FALSE;

    if ( 
m_volume == )
        
m_volume 0.85;
}


void CFuncTrain::Precachevoid )
{
    
CBasePlatTrain::Precache();

#if 0  // obsolete
    // otherwise use preset sound
    
switch (m_sounds)
    {
    case 
0:
        
pev->noise 0;
        
pev->noise1 0;
        break;

    case 
1:
        
PRECACHE_SOUND ("plats/train2.wav");
        
PRECACHE_SOUND ("plats/train1.wav");
        
pev->noise MAKE_STRING("plats/train2.wav");
        
pev->noise1 MAKE_STRING("plats/train1.wav");
        break;

    case 
2:
        
PRECACHE_SOUND ("plats/platmove1.wav");
        
PRECACHE_SOUND ("plats/platstop1.wav");
        
pev->noise MAKE_STRING("plats/platstop1.wav");
        
pev->noise1 MAKE_STRING("plats/platmove1.wav");
        break;
    }
#endif
}


void CFuncTrain::OverrideResetvoid )
{
    
CBaseEntity    *pTarg;

    
// Are we moving?
    
if ( pev->velocity != g_vecZero && pev->nextthink != )
    {
        
pev->target pev->message;
        
// now find our next target
        
pTarg GetNextTarget();
        if ( !
pTarg )
        {
            
pev->nextthink 0;
            
pev->velocity g_vecZero;
        }
        else    
// Keep moving for 0.1 secs, then find path_corner again and restart
        
{
            
SetThink( &CFuncTrain::Next );
            
pev->nextthink pev->ltime 0.1;
        }
    }

__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 04-15-2015 at 08:31.
Hedgehog Fog is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 04-15-2015 , 16:25   Re: [Help]Reset func_train
Reply With Quote #7

Have you tried simply looping through all func_train entities and calling Ham_CS_Restart?
__________________


Last edited by NiHiLaNTh; 04-15-2015 at 16:25.
NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 04-16-2015 , 02:31   Re: [Help]Reset func_train
Reply With Quote #8

Quote:
Originally Posted by NiHiLaNTh View Post
Have you tried simply looping through all func_train entities and calling Ham_CS_Restart?
Sure
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities
Hedgehog Fog is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-16-2015 , 03:13   Re: [Help]Reset func_train
Reply With Quote #9

It's what does the game, it calls Restart on new round. Restart for func_train will basically set the saved origin at spawn.
__________________
Arkshine is offline
Hedgehog Fog
Senior Member
Join Date: Jun 2010
Location: Ukraine
Old 04-16-2015 , 07:19   Re: [Help]Reset func_train
Reply With Quote #10

Yep. Any ideas how to reset func_train?
Reset pev_target, currentTarget, origin, set nextthink to 0, disable think by reset pfntThink value, set velocity, angles and dest to zero vec, set pev_enemy and pev_message to 0 value... What else?
__________________

❄️ CS Snow Wars - Mod based on snowballs fights
🧟 CS Zombie Panic - A port of HL Zombie Panic!
🎃 CS Halloween Mod - Completely new gamemode for Halloween Holidays
📦 AMXXPack - CLI and build system for amxx projects
🔧 Custom Entities API - API to register custom entities

Last edited by Hedgehog Fog; 04-16-2015 at 07:25.
Hedgehog Fog is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:21.


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