float MountMg42::GetPriority() { if ( IsActive() || GetClient()->HasEntityFlag( ETQW_ENT_FLAG_MOUNTED ) ) return GetLastPriority(); BitFlag64 entFlags; GoalManager::Query qry( 0xe1a2b09c /* MOUNTMG42 */, GetClient() ); System::mInstance->mGoalManager->GetGoals( qry ); for ( uint32_t i = 0; i < qry.mList.size(); ++i ) { if ( BlackboardIsDelayed( qry.mList[ i ]->GetSerialNum() ) ) continue; GameEntity gunOwner = InterfaceFuncs::GetMountedPlayerOnMG42( GetClient(), qry.mList[ i ]->GetEntity() ); int gunHealth = InterfaceFuncs::GetGunHealth( GetClient(), qry.mList[ i ]->GetEntity() ); bool bBroken = InterfaceFuncs::IsMountableGunRepairable( GetClient(), qry.mList[ i ]->GetEntity() ); if ( bBroken ) continue; EntityInfo entInfo; if ( !IGame::GetEntityInfo( qry.mList[ i ]->GetEntity(), entInfo ) || !entInfo.mFlags.CheckFlag( ETQW_ENT_FLAG_ISMOUNTABLE ) ) continue; // Make sure nobody has it mounted. if ( ( !gunOwner.IsValid() || !GetClient()->IsAllied( gunOwner ) ) && ( gunHealth > 0 ) ) { mMapGoal = qry.mList[ i ]; break; } } return mMapGoal ? mMapGoal->GetPriorityForClient( GetClient() ) : 0.f; }
// function: GetDestroyableState // Return the state of the destroyable; exploded, not exploded, invalid. // // // Parameters: // // GameEntity // // Returns: // destroyable state static int GM_CDECL gmfGetDestroyableState( gmThread *a_thread ) { CHECK_THIS_BOT(); GM_CHECK_NUM_PARAMS( 1 ); GameEntity gameEnt; GM_CHECK_GAMEENTITY_FROM_PARAM( gameEnt, 0 ); if ( gameEnt.IsValid() ) a_thread->PushInt( InterfaceFuncs::IsDestroyable( native, gameEnt ) ); else a_thread->PushNull(); return GM_OK; }
void CallbackParameters::AddEntity( const char *_name, GameEntity _param ) { if ( !_param.IsValid() ) { AddNull( _name ); return; } CheckParameters(); mVariables[ mNumParameters ].SetEntity( _param.AsInt() ); #if(DEBUG_PARAMS) mDebugNames[.mNumParameters] = _name; #endif mNumParameters++; }
// function: GetMountedPlayerOnMG42 // Returns entity currently mounted on the given mg42 entity // // // Parameters: // // GameEntity // // Returns: // Entity of the owner static int gmfGetMountedPlayerOnMG42( gmThread *a_thread ) { CHECK_THIS_BOT(); GM_CHECK_NUM_PARAMS( 1 ); GameEntity gameEnt; GM_CHECK_GAMEENTITY_FROM_PARAM( gameEnt, 0 ); GameEntity owner = InterfaceFuncs::GetMountedPlayerOnMG42( native, gameEnt ); if ( owner.IsValid() ) { gmVariable v; v.SetEntity( owner.AsInt() ); a_thread->Push( v ); } else { a_thread->PushNull(); } return GM_OK; }
State::StateStatus MountMg42::Update( float fDt ) { if ( DidPathFail() ) { BlackboardDelay( 10.f, mMapGoal->GetSerialNum() ); return State_Finished; } if ( !mMapGoal->IsAvailable( GetClient()->GetTeam() ) ) return State_Finished; ////////////////////////////////////////////////////////////////////////// // Only fail if a friendly player is on this gun or gun has been destroyed in the meantime //int gunHealth = InterfaceFuncs::GetGunHealth(.mClient, mMG42Goal->GetEntity()); GameEntity mounter = InterfaceFuncs::GetMountedPlayerOnMG42( GetClient(), mMapGoal->GetEntity() ); if ( InterfaceFuncs::IsMountableGunRepairable( GetClient(), mMapGoal->GetEntity() ) || ( mounter.IsValid() && ( mounter != GetClient()->GetGameEntity() ) && GetClient()->IsAllied( mounter ) ) ) { return State_Finished; } ////////////////////////////////////////////////////////////////////////// if ( DidPathSucceed() ) { GetClient()->GetSteeringSystem()->SetTarget( mMapGoal->GetPosition() ); FINDSTATEIF( Aimer, GetRootState(), AddAimRequest( Priority::Medium, this, GetNameHash() ) ); if ( GetClient()->HasEntityFlag( ETQW_ENT_FLAG_MOUNTED ) ) { mTargetZone.Update( GetClient() ); if ( !mGotGunProperties ) { mGotGunProperties = true; _GetMG42Properties(); mAimPoint = mMapGoal->GetPosition() + mGunCenterArc * 512.f; } if ( mNextScanTime < IGame::GetTime() ) { mNextScanTime = IGame::GetTime() + (int)Mathf::IntervalRandom( 2000.0f, 7000.0f ); mScanDirection = (int)Mathf::IntervalRandom( 0.0f, (float)NUM_SCAN_TYPES ); // we're mounted, so lets look around mid view. mTargetZone.UpdateAimPosition(); } if ( mTargetZone.HasAim() ) mScanDirection = SCAN_ZONES; switch ( mScanDirection ) { case SCAN_DEFAULT: if ( mMapGoal->GetFacing() != Vector3f::ZERO ) { mAimPoint = mMG42Position + mMapGoal->GetFacing() * 1024.f; break; } case SCAN_MIDDLE: { mAimPoint = mMG42Position + mGunCenterArc * 1024.f; break; } case SCAN_LEFT: if ( mScanLeft != Vector3f::ZERO ) { mAimPoint = mMG42Position + mScanLeft * 1024.f; break; } case SCAN_RIGHT: if ( mScanRight != Vector3f::ZERO ) { mAimPoint = mMG42Position + mScanRight * 1024.f; break; } case SCAN_ZONES: { mAimPoint = mTargetZone.GetAimPosition(); break; } default: break; } } } return State_Busy; }