//void CHangingLamp::Hit(float P,Fvector &dir, CObject* who,s16 element, // Fvector p_in_object_space, float impulse, ALife::EHitType hit_type) void CHangingLamp::Hit (SHit* pHDS) { SHit HDS = *pHDS; callback(GameObject::eHit)( lua_game_object(), HDS.power, HDS.dir, smart_cast<const CGameObject*>(HDS.who)->lua_game_object(), HDS.bone() ); #ifdef HLAMP_AFFECT_IMMUNITIES HDS.power = CHitImmunity::AffectHit(HDS.power,HDS.hit_type); inherited::Hit(pHDS); #endif BOOL bWasAlive = Alive () || light_render->get_active(); if(m_pPhysicsShell) m_pPhysicsShell->applyHit(pHDS->p_in_bone_space,pHDS->dir,pHDS->impulse,pHDS->boneID,pHDS->hit_type); if (!bWasAlive) return; if (pHDS->boneID==light_bone) SetHealth ( 0.f ); else { float damage = pHDS->damage() * 100.f; Msg("DEBUG: %s health = %.3f, damage = %.3f", Name_script(), GetHealth(), damage); SetHealth(GetHealth() - damage); } if (bWasAlive && (!Alive())) TurnOff (); }
bool CActorCondition::IsLimping() const { if(m_fPower< m_fLimpingPowerBegin || GetHealth() < m_fLimpingHealthBegin) m_bLimping = true; else if(m_fPower > m_fLimpingPowerEnd && GetHealth() > m_fLimpingHealthEnd) m_bLimping = false; return m_bLimping; }
//========================================================= // Calcula la nueva velocidad del jugador dependiendo del // peso de la arma. //========================================================= float CIN_Player::CalculateSpeed(CBaseCombatWeapon *pWeapon, float speed) { // No se especifico el arma, obtenerla automaticamente. if ( pWeapon == NULL ) pWeapon = GetActiveWeapon(); ConVarRef hl2_sprintspeed("hl2_sprintspeed"); ConVarRef hl2_walkspeed("hl2_walkspeed"); // Obtenemos la velocidad inicial. if ( speed == 0 && IsSprinting() ) speed = hl2_sprintspeed.GetFloat(); if ( speed == 0 && !IsSprinting() ) speed = hl2_walkspeed.GetFloat(); float newSpeed = speed; // Arma válida. if ( pWeapon ) { // Obtenemos el peso del arma. float weaponWeight = pWeapon->GetWpnData().m_WeaponWeight; // El arma es muy ligera, te da velocidad. if ( weaponWeight < 0 ) { weaponWeight = fabs(weaponWeight); newSpeed = newSpeed + weaponWeight; } else newSpeed = newSpeed - weaponWeight; } // Menos de 40% de salud. if ( GetHealth() <= 40 ) { // Disminuimos más velocidad entre menos salud tengamos. if ( GetHealth() <= 5 ) newSpeed = newSpeed - 10; else if ( GetHealth() <= 10 ) newSpeed = newSpeed - 5; else if ( GetHealth() <= 20 ) newSpeed = newSpeed - 3; else if ( GetHealth() <= 40 ) newSpeed = newSpeed - 2; } if ( newSpeed < 10 ) newSpeed = 10; return newSpeed; }
void Base::Update() { //update the health bar to display minion damage if (GetHealth() > 0) { m_HealthBar->setWidth(GetHealth()); } }
//----------------------------------------------------------------------------- // Purpose: Powerup has just started //----------------------------------------------------------------------------- void CBaseCombatCharacter::PowerupStart( int iPowerup, float flAmount, CBaseEntity *pAttacker, CDamageModifier *pDamageModifier ) { Assert( iPowerup >= 0 && iPowerup < MAX_POWERUPS ); switch( iPowerup ) { case POWERUP_BOOST: { // Players can be boosted over their max int iMaxBoostedHealth; if ( IsPlayer() ) { iMaxBoostedHealth = GetMaxHealth() + GetMaxHealth() / 2; } else { iMaxBoostedHealth = GetMaxHealth(); } // Can we boost health further? if ( GetHealth() < iMaxBoostedHealth ) { int maxHealthToAdd = iMaxBoostedHealth - GetHealth(); // It uses floating point in here so it doesn't lose the fractional healing part on small frame times. float flHealthToAdd = flAmount + m_flFractionalBoost; int nHealthToAdd = (int)flHealthToAdd; m_flFractionalBoost = flHealthToAdd - nHealthToAdd; if ( nHealthToAdd ) { int nHealthAdded = min( nHealthToAdd, maxHealthToAdd ); if ( IsPlayer() ) { ((CBaseTFPlayer*)this)->TakeHealthBoost( nHealthAdded, GetMaxHealth(), 25 ); } else { TakeHealth( nHealthAdded, DMG_GENERIC ); } TFStats()->IncrementPlayerStat( pAttacker, TF_PLAYER_STAT_HEALTH_GIVEN, nHealthAdded ); } } } break; case POWERUP_EMP: { // EMP removes adrenalin rush SetPowerup( POWERUP_RUSH, false ); } break; default: break; } }
void CBurnBot::TakeDamage(IBaseObject* _pIn) { if (_pIn->GetID() == OBJ_TURRET) { SetHealth(GetHealth() - ((CTurret*)_pIn)->GetDamage()); SetWasHit(true); } if(((CBullet*)_pIn)->GetType() == SPECIALBULLET) SetHealth(0.0f); else SetHealth(GetHealth() - ((CBullet*)_pIn)->GetDamage()); SetWasHit(true); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- BuildingHudAlert_t C_BaseObject::GetBuildingAlertLevel( void ) { float flHealthPercent = GetHealth() / GetMaxHealth(); BuildingHudAlert_t alertLevel = BUILDING_HUD_ALERT_NONE; if ( HasSapper() ) { alertLevel = BUILDING_HUD_ALERT_SAPPER; } else if ( !IsBuilding() && flHealthPercent < 0.33 ) { alertLevel = BUILDING_HUD_ALERT_VERY_LOW_HEALTH; } else if ( !IsBuilding() && flHealthPercent < 0.66 ) { alertLevel = BUILDING_HUD_ALERT_LOW_HEALTH; } BuildingHudAlert_t iFakeAlert = (BuildingHudAlert_t)cl_obj_fake_alert.GetInt(); if ( iFakeAlert > BUILDING_HUD_ALERT_NONE && iFakeAlert < MAX_BUILDING_HUD_ALERT_LEVEL ) { alertLevel = iFakeAlert; } return alertLevel; }
void cCreeper::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) { super::Tick(a_Dt, a_Chunk); if (!IsTicking()) { // The base class tick destroyed us return; } if (((GetTarget() == nullptr) || !TargetIsInRange()) && !m_BurnedWithFlintAndSteel) { if (m_bIsBlowing) { m_ExplodingTimer = 0; m_bIsBlowing = false; m_World->BroadcastEntityMetadata(*this); } } else { if (m_bIsBlowing) { m_ExplodingTimer += 1; } if ((m_ExplodingTimer == 30) && (GetHealth() > 0.0)) // only explode when not already dead { m_World->DoExplosionAt((m_bIsCharged ? 5 : 3), GetPosX(), GetPosY(), GetPosZ(), false, esMonster, this); Destroy(); // Just in case we aren't killed by the explosion } } }
void CSDKPlayer::CheatImpulseCommands( int iImpulse ) { if ( iImpulse != 101 ) { BaseClass::CheatImpulseCommands( iImpulse ); return ; } gEvilImpulse101 = true; EquipSuit(); GiveNamedItem( "weapon_mp5" ); GiveNamedItem( "weapon_grenade" ); GiveNamedItem( "weapon_shotgun" ); // Give the player everything! GiveAmmo( 90, AMMO_BULLETS ); GiveAmmo( 3, AMMO_GRENADE ); if ( GetHealth() < 100 ) { TakeHealth( 25, DMG_GENERIC ); } gEvilImpulse101 = false; }
bool Entity::IsValid() { if( !GetPointer() ) return false; if( !GetBoneMatrix() ) return false; if( !GetTeamNum() ) return false; if( IsDead() ) return false; if( IsDormant() ) return false; if( GetOrigin().IsZero() ) return false; if( GetHealth() < 1 ) return false; return true; }
CGrunt::CGrunt(float fHealthScale) : CEnemy(20) { CEntity::m_eType = ENT_ENEMY; SetEnemyType(Grunt); AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Walk_Animation.xml"); AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Death_Animation.xml"); AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Attack_Animation.xml"); AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Flinch_Animation.xml"); AnimationManager::GetInstance()->LoadAnimationFile("config/Grunt_Knocked_Down_Animation.xml"); GetAnimInfo()->SetAnimationName("Grunt_Walk_Animation"); SetBaseAnimations(ENT_ENEMY); punching = false; cooldown = 0.0f; SetHealth((int)(GetHealth()*(1.0f + fHealthScale))); SetIdleAnim("Grunt_Walk_Animation"); m_bFlipped = false; m_fMoveAway = 0.0f; m_bEvadeUp = false; m_fPosXOld = 0.0f; m_fPosYOld = 0.0f; m_fUpdateOldPos = 0.0f; m_nExpPts = 50; CSGD_EventSystem::GetInstance()->RegisterClient("New_Player", this); CSGD_EventSystem::GetInstance()->RegisterClient("ModifyHealth", this); CSGD_EventSystem::GetInstance()->RegisterClient("Self Destruct", this); }
void CClientVehicle::Serialize(CBitStream * pBitStream) { // Write the vehicle position CVector3 vecPosition; GetPosition(vecPosition); pBitStream->Write(vecPosition); // Write the vehicle rotation CVector3 vecRotation; GetRotation(vecRotation); pBitStream->Write(vecRotation); // Write the vehicle move speed CVector3 vecMoveSpeed; GetMoveSpeed(vecMoveSpeed); pBitStream->Write(vecMoveSpeed); // Write the vehicle turn speed CVector3 vecTurnSpeed; GetTurnSpeed(vecTurnSpeed); pBitStream->Write(vecTurnSpeed); // Write the vehicle health pBitStream->Write(GetHealth()); }
void Bullet::Update(float fDeltaTime) { if (GetActive()) { Vector2 position = GetPosition(); Vector2 velocity = GetVelocity(); position += velocity * fDeltaTime; SetPosition(position); RecalculateAABB(); GameObject* other = nullptr; bool collision = CollisionManager::GetSingleton()->IsColliding(this, &other); if (collision && other->GetCollisionLayer() == ECOLLISIONLAYER_ALL) { other->SetHealth(GetHealth() - 30); SetActive(false); } Engine::GetSingleton()->GetSpriteBatch()->GetViewRect(&minX, &minY, &maxX, &maxY); if (position.x > maxX) SetActive(false); else if (position.x < minX) SetActive(false); else if (position.y > maxY) SetActive(false); else if (position.y < minY) SetActive(false); } return; }
int CSDKPlayer::OnTakeDamage( const CTakeDamageInfo &info ) { CTakeDamageInfo inputInfoCopy( info ); // If you shoot yourself, make it hurt but push you less if ( inputInfoCopy.GetAttacker() == this && inputInfoCopy.GetDamageType() == DMG_BULLET ) { inputInfoCopy.ScaleDamage( 5.0f ); inputInfoCopy.ScaleDamageForce( 0.05f ); } int ret = BaseClass::OnTakeDamage( inputInfoCopy ); m_DmgOrigin = info.GetDamagePosition(); #ifdef PLAYER_IGNORE_FALLDAMAGE // ignore fall damage if instructed to do so by input if ( ( info.GetDamageType() & DMG_FALL ) ) { inputInfoCopy.SetDamage(0.0f); return 0; } #endif #ifdef PLAYER_HEALTH_REGEN if ( GetHealth() < 100 ) { m_fTimeLastHurt = gpGlobals->curtime; } #endif return ret; }
void CLocalPlayer::SendOnFootData() { RakNet::BitStream PlayerBitStream_send; PlayerBitStream_send.Write((MessageID)ID_SEND_PLAYER_DATA); PlayerBitStream_send.Write(NetworkManager->playerid); PlayerBitStream_send.Write(GetType()); PlayerBitStream_send.Write(GetModel()); PlayerBitStream_send.Write(GetHealth()); PlayerBitStream_send.Write(GetArmour()); PlayerBitStream_send.Write(GetCoords().x); PlayerBitStream_send.Write(GetCoords().y); PlayerBitStream_send.Write(GetCoords().z); PlayerBitStream_send.Write(GetHeading()); PlayerBitStream_send.Write(GetQuaternion().fX); PlayerBitStream_send.Write(GetQuaternion().fY); PlayerBitStream_send.Write(GetQuaternion().fZ); PlayerBitStream_send.Write(GetQuaternion().fW); PlayerBitStream_send.Write(AI::GET_PED_DESIRED_MOVE_BLEND_RATIO(playerPed)); PlayerBitStream_send.Write(GetVelocity().x); PlayerBitStream_send.Write(GetVelocity().y); PlayerBitStream_send.Write(GetVelocity().z); PlayerBitStream_send.Write(LocalPlayer->GetVehicle()); PlayerBitStream_send.Write(time(0)); NetworkManager->client->Send(&PlayerBitStream_send, MEDIUM_PRIORITY, RELIABLE_ORDERED, 0, RakNet::UNASSIGNED_SYSTEM_ADDRESS, true); }
//----------------------------------------------------------------------------- // Purpose: Player has waved his crosshair over this entity. Display appropriate hints. //----------------------------------------------------------------------------- void C_BaseObject::DisplayHintTo( C_BasePlayer *pPlayer ) { bool bHintPlayed = false; C_TFPlayer *pTFPlayer = ToTFPlayer(pPlayer); if ( InSameTeam( pPlayer ) ) { // We're looking at a friendly object. if ( HasSapper() ) { bHintPlayed = pPlayer->HintMessage( HINT_OBJECT_HAS_SAPPER, true, true ); } if ( pTFPlayer->IsPlayerClass( TF_CLASS_ENGINEER ) ) { // I'm an engineer. // If I'm looking at a constructing object, let me know I can help build it (but not // if I built it myself, since I've already got that hint from the wrench). if ( !bHintPlayed && IsBuilding() && GetBuilder() != pTFPlayer ) { bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_USE_WRENCH_ONOTHER, false, true ); } // If it's damaged, I can repair it if ( !bHintPlayed && !IsBuilding() && GetHealth() < GetMaxHealth() ) { bHintPlayed = pPlayer->HintMessage( HINT_ENGINEER_REPAIR_OBJECT, false, true ); } } } }
void Creature::RegenerateHealth() { uint32 curValue = GetHealth(); uint32 maxValue = GetMaxHealth(); if (curValue >= maxValue) return; float HealthIncreaseRate = sWorld.getRate(RATE_HEALTH); float Spirit = GetStat(STAT_SPIRIT); if( HealthIncreaseRate <= 0 ) HealthIncreaseRate = 1; uint32 addvalue = 0; if(isPet()) { if( GetPower(POWER_MANA) > 0 ) addvalue = uint32(Spirit * 0.25 * HealthIncreaseRate); else addvalue = uint32(Spirit * 0.80 * HealthIncreaseRate); } else addvalue = maxValue/3; ModifyHealth(addvalue); }
void CLocalPlayer::SendPassengerSync( void ) { // Are we not connected to the network? if( !pCore->GetNetworkModule()->IsConnected() ) return; // Are we dead? if( IsDead() ) return; // Get the vehicle instance CNetworkVehicle * pVehicle = pCore->GetVehicleManager()->GetFromGameGUID( GetPlayerPed()->GetCurrentVehicle()->m_dwGUID ); // Did we fail to find the vehicle? if( !pVehicle ) return; // Construct a new bitstream RakNet::BitStream pBitStream; // Construct a new passenger sync data structure InPassengerSync passengerSync; // Get the player health passengerSync.m_fHealth = GetHealth (); // Get the player selected weapon passengerSync.m_dwSelectedWeapon = GetSelectedWeapon (); // Write the sync structure to the bitstream pBitStream.Write( (char *)&passengerSync, sizeof(InPassengerSync) ); // Send the bitstream to the server pCore->GetNetworkModule()->Call( RPC_PASSENGER_SYNC, &pBitStream, LOW_PRIORITY, UNRELIABLE_SEQUENCED, true ); }
void C_ASW_Alien::ClientThink() { BaseClass::ClientThink(); // asw temp fix demo playback //ASWUpdateClientSideAnimation(); m_vecLastRenderedPos = WorldSpaceCenter(); m_vecAutoTargetRadiusPos = GetLocalAutoTargetRadiusPos(); if ( GetHealth() > 0 && m_bElectroStunned && m_fNextElectroStunEffect <= gpGlobals->curtime) { // apply electro stun effect HACK_GETLOCALPLAYER_GUARD( "C_ASW_Alien::ClientThink FX_ElectroStun" ); FX_ElectroStun(this); m_fNextElectroStunEffect = gpGlobals->curtime + RandomFloat( 0.3, 1.0 ); //Msg( "%f - ElectroStunEffect\n", gpGlobals->curtime ); } UpdateFireEmitters(); C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer(); if ( pPlayer && pPlayer->IsSniperScopeActive() ) { m_GlowObject.SetRenderFlags( true, true ); } else { m_GlowObject.SetRenderFlags( false, false ); } }
int CASW_Simple_Alien::OnTakeDamage( const CTakeDamageInfo &info ) { // don't get hurt if our attacker is our friend if (info.GetAttacker() && info.GetAttacker()->Classify() != CLASS_NONE) { // Proper way to check, but BCC default relationship array is private :/ //Disposition_t disp = CBaseCombatCharacter::m_DefaultRelationship[Classify()][info.GetAttacker()->Classify()].disposition; //if (disp == D_LI) //return 0; // Hacky way to stop simple aliens getting hurt by other Infested aliens Class_T c = info.GetAttacker()->Classify(); if ( IsAlienClass( c ) ) return 0; } if (asw_debug_alien_damage.GetBool()) { Msg("%d %s hurt by %f dmg\n", entindex(), GetClassname(), info.GetDamage()); } int iDamage = BaseClass::OnTakeDamage(info); if (iDamage > 0 && GetHealth() > 0) { PainSound(info); } return iDamage; }
void CTurtle::Update(float fElapsedTime) { m_vAnimations[m_nCurrAnimation].Update(fElapsedTime); if(GetExperience() >= (100 * GetLevel())) { CBattleMap::GetInstance()->PlaySFX(CAssets::GetInstance()->aBMcowabungaSnd); SetExperience(0/*GetExperience()-(100* GetLevel())*/); SetLevel(GetLevel() + 1); SetHealthMax((int)((float)GetMaxHealth() * 1.25f)); SetHealth((int)((float)GetMaxHealth())); SetBaseAP(GetBaseAP()+2); SetStrength( (int)( (float)GetStrength() * 1.2f ) ); SetDefense( (int) ( (float)GetDefense() * 1.2f ) ); SetAccuracy( (int) ( (float)GetAccuracy() * 1.2f ) ); SetSpeed( (int) ( (float)GetSpeed() * 1.2f ) ); } if( GetHealth() <= 0) { if(GetAlive() == true) { CBattleMap::GetInstance()->DecrementNumChars(); CBattleMap::GetInstance()->DecrementNumTurtles(); CBattleMap::GetInstance()->SetTurtleDead(); SetAlive(false); if(GetCurrAnimNum() != 9) SetCurrAnim(9); SetPosZ(0.9f); } } }
void AMech_RPGCharacter::Tick(float DeltaTime) { Super::Tick(DeltaTime); if (!isDead) { GetCharacterMovement()->MaxWalkSpeed = speed * speedModifier; if (GetHealth() < GetMaxHealth()) { float regen = !inCombat ? GetMaxHealth() * 0.15 : healthRegen; health += regen * DeltaTime; GetFloatingStats()->UpdateHealthBar(); if (GetCharacterStats() != nullptr) { GetCharacterStats()->UpdateHealthBar(); } } if (stats->GetUserWidgetObject() != nullptr && stats->GetUserWidgetObject() != nullptr) { if (mIsChildOf(GetController(), AMech_RPGPlayerController::StaticClass()) && GetTopDownCamera() != nullptr) { UMiscLibrary::SetCameraRot(FRotator(-GetTopDownCamera()->GetComponentRotation().Pitch, UMiscLibrary::GetWidgetYaw(GetTopDownCamera()) + 90, 0)); GetStats()->SetWorldRotation(UMiscLibrary::GetCameraRot()); } else if (GetStats() != nullptr) { GetStats()->SetWorldRotation(UMiscLibrary::GetCameraRot()); } } } CLAMP(health, GetMaxHealth(), 0); }
int32 Unit::ModifyHealth(int32 val) { int32 gain = 0; if (val == 0) return 0; int32 curHealth = (int32)GetHealth(); int32 newHealth = val + curHealth; if (newHealth <= 0) { SetHealth(0); return -curHealth; } int32 maxHealth = (int32)GetMaxHealth(); if (newHealth < maxHealth) { SetHealth(newHealth); gain = newHealth - curHealth; } else if (curHealth != maxHealth) { SetHealth(maxHealth); gain = maxHealth - curHealth; } return gain; }
void PrintEnemies(Enemies enemies) { Unit enemy; char stringEnemyClass[11]; char stringRetaliates[13]; POINT enemyLocation; for (int i = 0; i < enemies.count; ++i) { enemy = *enemies.enemy[i].unit; UnitClassName(GetUnitClass(enemy), stringEnemyClass); if (enemies.enemy[i].canRetaliate) { strcpy(stringRetaliates, "(Retaliates)"); } else { strcpy(stringRetaliates, ""); } enemyLocation = GetLocation(enemy); printf("%d. %s (%d,%d) | Health %d/%d %s\n", 1+i, stringEnemyClass, enemyLocation.X, enemyLocation.Y, GetHealth(enemy), GetMaximumHealth(enemy), stringRetaliates ); } }
//----------------------------------------------------------------------------- // Purpose: Draw any debug text overlays // Output : Current text offset from the top //----------------------------------------------------------------------------- int CBreakable::DrawDebugTextOverlays(void) { int text_offset = BaseClass::DrawDebugTextOverlays(); if (m_debugOverlays & OVERLAY_TEXT_BIT) { if ( GetMaxHealth() ) { char tempstr[512]; Q_snprintf(tempstr,sizeof(tempstr),"Health: %i",GetHealth()); EntityText(text_offset,tempstr,0); text_offset++; } if ( m_iszBasePropData != NULL_STRING ) { char tempstr[512]; Q_snprintf(tempstr, sizeof(tempstr),"Base PropData: %s", STRING(m_iszBasePropData) ); EntityText( text_offset, tempstr, 0); text_offset++; } } return text_offset; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int CPhysBox::OnTakeDamage( const CTakeDamageInfo &info ) { // note: if motion is disabled, OnTakeDamage can't apply physics force int ret = BaseClass::OnTakeDamage( info ); // Check our health against the threshold: if( m_damageToEnableMotion > 0 && GetHealth() < m_damageToEnableMotion ) { // only do this once m_damageToEnableMotion = 0; IPhysicsObject *pPhysicsObject = VPhysicsGetObject(); if ( pPhysicsObject != NULL ) { pPhysicsObject->Wake(); pPhysicsObject->EnableMotion( true ); VPhysicsTakeDamage( info ); } } if ( info.GetInflictor() ) { m_OnDamaged.FireOutput( info.GetAttacker(), this ); } return ret; }
void Agent::Search() //Orange { searching = true; int mouseX, mouseY; Input::GetSingleton()->GetMouseXY(&mouseX, &mouseY); float fDist = GetDistanceFromTarget((float)mouseX, (float)mouseY); // Actuation Wander(180, 60, 60); // Transition if (searchTimer > 3) { searching = false; searchTimer = 0; SetColour(Colour::Green); } if (fDist < m_nSightRange) { searching = false; searchTimer = 0; SetColour(Colour::Red); } if (GetHealth() <= 50) { searching = false; searchTimer = 0; SetColour(Colour::Blue); } }
void cSlime::KilledBy(TakeDamageInfo & a_TDI) { if (GetHealth() > 0) { return; } if (m_Size != 1) { cFastRandom Random; int SpawnAmount = 2 + Random.NextInt(3); for (int i = 0; i < SpawnAmount; ++i) { double AddX = (i % 2 - 0.5) * m_Size / 4.0; double AddZ = (i / 2 - 0.5) * m_Size / 4.0; cSlime * NewSlime = new cSlime(m_Size / 2); NewSlime->SetPosition(GetPosX() + AddX, GetPosY() + 0.5, GetPosZ() + AddZ); NewSlime->SetYaw(Random.NextFloat(1.0f) * 360.0f); m_World->SpawnMobFinalize(NewSlime); } } super::KilledBy(a_TDI); }
void Agent::Patrol() //Green { int mouseX; int mouseY; int j = 0; Input::GetSingleton()->GetMouseXY(&mouseX, &mouseY); float fDist = GetDistanceFromTarget((float)mouseX, (float)mouseY); if (GetDistanceFromTarget(m_path[m_nCurrentDst].x, m_path[m_nCurrentDst].y) < 15.f) { m_nCurrentDst++; m_nCurrentDst %= 4; } vec2 nodePos = { m_path[m_nCurrentDst].x, m_path[m_nCurrentDst].y }; vec2 agentPos = { GetPositionX(), GetPositionY() }; vec2 posDiff = nodePos - agentPos; vec2 accel = (nodePos - agentPos).normal() * 5; m_movementInfo.m_accelerationX = accel.x; m_movementInfo.m_accelerationY = accel.y; if (fDist < m_nSightRange) SetColour(Colour::Red); if (GetHealth() <= 50) SetColour(Colour::Blue); }
void CNPC_Zombine::RunTask( const Task_t *pTask ) { switch ( pTask->iTask ) { case TASK_WAIT_FOR_MOVEMENT_STEP: case TASK_WAIT_FOR_MOVEMENT: { BaseClass::RunTask( pTask ); if ( IsOnFire() && IsSprinting() ) { StopSprint(); } //Only do this if I have an enemy if ( GetEnemy() ) { if ( AllowedToSprint() == true ) { Sprint( ( GetHealth() <= GetMaxHealth() * 0.5f ) ); return; } if ( HasGrenade() ) { if ( IsSprinting() ) { GetNavigator()->SetMovementActivity( (Activity)ACT_ZOMBINE_GRENADE_RUN ); } else { GetNavigator()->SetMovementActivity( (Activity)ACT_ZOMBINE_GRENADE_WALK ); } return; } if ( GetNavigator()->GetMovementActivity() != ACT_WALK ) { if ( IsSprinting() == false ) { GetNavigator()->SetMovementActivity( ACT_WALK ); } } } else { GetNavigator()->SetMovementActivity( ACT_WALK ); } break; } default: { BaseClass::RunTask( pTask ); break; } } }