FF Diff Viewer

Comparing 2006 Base SDK to Fortress Forever 2.46

dlls/buttons.cpp

13141516171819
#include "vstdlib/strtools.h" #include "buttons.h" #include "eventqueue.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h"
1314151617181920212223242526272829
#include "vstdlib/strtools.h" #include "buttons.h" #include "eventqueue.h" #include "omnibot_interface.h" // --> Mirv: Temp test for triggers #include "ff_scriptman.h" //#include "ff_luaobject_wrapper.h" #include "ff_luacontext.h" // <-- Mirv: Temp test for triggers #undef MINMAX_H #include "minmax.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h"
260261262263264265
//----------------------------------------------------------------------------- int CBaseButton::OnTakeDamage( const CTakeDamageInfo &info ) { m_OnDamaged.FireOutput(m_hActivator, this); // dvsents2: remove obselete health keyvalue from func_button
270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
//----------------------------------------------------------------------------- int CBaseButton::OnTakeDamage( const CTakeDamageInfo &info ) { // check to see if the trepids allow this button to do what it wants to _scriptman.SetVar("info_damage", info.GetDamage()); _scriptman.SetVar("info_attacker", ENTINDEX(info.GetAttacker())); _scriptman.SetVar("info_classname", info.GetInflictor()?info.GetInflictor()->GetClassname():""); CBasePlayer *player = ToBasePlayer(info.GetInflictor()); if (player) { CBaseCombatWeapon *weapon = player->GetActiveWeapon(); if (weapon) _scriptman.SetVar("info_classname", weapon->GetName()); } // TODO: Update this to use .Push() to send the arguments instead of SetVar()ing globals CFFLuaSC hOnDamage; // if the :ondamage() function exists in Lua, let it decide if damage should be done if( _scriptman.RunPredicates_LUA(this, &hOnDamage, "ondamage" ) ) { // if the return value was false, then don't do damage if (!hOnDamage.GetBool()) return 0; } if (_scriptman.GetFloat("info_damage") <= 0.0) return 0; m_OnDamaged.FireOutput(m_hActivator, this); // dvsents2: remove obselete health keyvalue from func_button
479480481482483484485
// Ignore touches if button is moving, or pushed-in and waiting to auto-come-out. // UNDONE: Should this use ButtonResponseToTouch() too? if (m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN ) return; if (m_bLocked) {
514515516517518519520
// Ignore touches if button is moving, or pushed-in and waiting to auto-come-out. // UNDONE: Should this use ButtonResponseToTouch() too? if (m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN ) return; if (m_bLocked) {
497498499500501502
// if ( HasSpawnFlags(SF_BUTTON_TOGGLE)) { if ( m_sNoise != NULL_STRING ) { CPASAttenuationFilter filter( this );
532533534535536537538539540541542543544545546547548
// if ( HasSpawnFlags(SF_BUTTON_TOGGLE)) { // double check that it's allowed to toggle //CFFLuaObjectWrapper hAllowed; CFFLuaSC hAllowed( 1, pActivator ); if( _scriptman.RunPredicates_LUA( this, &hAllowed, "allowed" ) ) { if( !hAllowed.GetBool() ) { _scriptman.RunPredicates_LUA( this, &hAllowed, "onfailuse" ); return; } } if ( m_sNoise != NULL_STRING ) { CPASAttenuationFilter filter( this );
510511512513514515
EmitSound( filter, entindex(), ep ); } m_OnPressed.FireOutput(m_hActivator, this); ButtonReturn(); }
556557558559560561562563564
EmitSound( filter, entindex(), ep ); } _scriptman.RunPredicates_LUA( this, &hAllowed, "onuse" ); m_OnPressed.FireOutput(m_hActivator, this); ButtonReturn(); }
516517518519520521
} else { m_OnPressed.FireOutput(m_hActivator, this); ButtonActivate( ); }
565566567568569570571572573574575576577578579580581582583
} else { // check with entsys to make sure it is allowed to activate //CFFLuaObjectWrapper hAllowed; CFFLuaSC hAllowed( 1, pActivator ); if( _scriptman.RunPredicates_LUA( this, &hAllowed, "allowed" ) ) { if( !hAllowed.GetBool() ) { _scriptman.RunPredicates_LUA( this, &hAllowed, "onfailuse" ); return; } } _scriptman.RunPredicates_LUA( this, &hAllowed, "onuse" ); m_OnPressed.FireOutput(m_hActivator, this); ButtonActivate( ); }
561562563564565566
if ( !pOther->IsPlayer() ) return; m_hActivator = pOther; BUTTON_CODE code = ButtonResponseToTouch();
623624625626627628629630631632633634635636637638639
if ( !pOther->IsPlayer() ) return; //CFFLuaObjectWrapper hButtonTouch; CFFLuaSC hAllowed( 1, pOther ); if( _scriptman.RunPredicates_LUA( this, &hAllowed, "allowed" ) ) { if( !hAllowed.GetBool() ) { _scriptman.RunPredicates_LUA( this, &hAllowed, "onfailtouch" ); return; } } m_hActivator = pOther; BUTTON_CODE code = ButtonResponseToTouch();
575576577578579580
return; } // Temporarily disable the touch function, until movement is finished. SetTouch( NULL );
648649650651652653654655
return; } _scriptman.RunPredicates_LUA( this, &hAllowed, "ontouch" ); // Temporarily disable the touch function, until movement is finished. SetTouch( NULL );
644645646647648649
LinearMove( m_vecPosition2, m_flSpeed); else AngularMove( m_vecAngle2, m_flSpeed); }
719720721722723724725726727728729730731
LinearMove( m_vecPosition2, m_flSpeed); else AngularMove( m_vecAngle2, m_flSpeed); { // Omnibot notification const char *n = GetName(); if(!n) n = UTIL_VarArgs("button_%d",entindex()); Omnibot::omnibot_interface::Trigger(this,m_hActivator.Get(),n,"button_activate"); } }
750751752753754755
SetThink ( &CBaseButton::ButtonSpark ); SetNextThink( gpGlobals->curtime + 0.5f );// no hurry } }
832833834835836837838839840841842843844
SetThink ( &CBaseButton::ButtonSpark ); SetNextThink( gpGlobals->curtime + 0.5f );// no hurry } { // Omnibot notification const char *n = GetName(); if(!n) n = UTIL_VarArgs("button_%d",entindex()); Omnibot::omnibot_interface::Trigger(this,NULL,n,"button_reset"); } }
1482148314841485
void CMomentaryRotButton::Disable( void ) { m_bDisabled = true; }
1571157215731574
void CMomentaryRotButton::Disable( void ) { m_bDisabled = true; }