void Creature::SetPosition(float x, float y, float z, float o) { // Prevent crash when a bad coord is sent by the client. if (!SkyMistCore::IsValidMapCoord(x, y, z, o)) { sLog->outDebug(LOG_FILTER_UNITS, "Creature::SetPosition(%f, %f, %f) .. bad coordinates!", x, y, z); return; } GetMap()->CreatureRelocation(ToCreature(), x, y, z, o); if (IsVehicle()) GetVehicleKit(); // ->RelocatePassengers(); }
VOID CModelInfoSA::Request( bool bAndLoad, bool bWaitForLoad, bool bHighPriority ) { DEBUG_TRACE("VOID CModelInfoSA::Request( BOOL bAndLoad, BOOL bWaitForLoad )"); // don't bother loading it if it already is if ( IsLoaded () ) return; if ( m_dwModelID <= 288 && m_dwModelID != 7 && !pGame->GetModelInfo ( 7 )->IsLoaded () ) { // Skin 7 must be loaded in order for other skins to work. No, really. (#4010) pGame->GetModelInfo ( 7 )->Request ( bAndLoad, false ); } // Bikes can sometimes get stuck when loading unless the anim file is handled like what is does here // Don't change the code below unless you can test it (by recreating the problem it solves) if ( IsVehicle () ) { uint uiAnimFileIndex = GetAnimFileIndex (); if ( uiAnimFileIndex != 0xffffffff ) { uint uiAnimId = uiAnimFileIndex + 25575; CModelInfoSA* pAnim = static_cast < CModelInfoSA* > ( pGame->GetModelInfo ( uiAnimId ) ); if ( !pAnim ) LogEvent ( 505, "Model no anim", "", SString ( "%d (%d)", m_dwModelID, uiAnimId ) ); else if ( !pAnim->IsLoaded() ) { OutputDebugLine ( SString ( "[Models] Requesting anim file %d for model %d", uiAnimId, m_dwModelID ) ); pAnim->Sure2Load ( 0x16 ); } } } DWORD dwFlags; if ( bHighPriority ) dwFlags = 0x16; else dwFlags = 6; pGame->GetStreaming()->RequestModel(m_dwModelID, dwFlags); if(bAndLoad) { pGame->GetStreaming()->LoadAllRequestedModels(); if(bWaitForLoad) { Sure2Load ( dwFlags ); } } }
void TempSummon::InitStats(uint32 duration) { ASSERT(!IsPet()); m_timer = duration; m_lifetime = duration; if (m_type == TEMPSUMMON_MANUAL_DESPAWN) m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; Unit* owner = GetSummoner(); if (owner) { if (IsTrigger() && m_spells[0]) { setFaction(owner->getFaction()); SetLevel(owner->getLevel()); if (owner->GetTypeId() == TYPEID_PLAYER) m_ControlledByPlayer = true; } if (owner->GetTypeId() == TYPEID_PLAYER) m_CreatedByPlayer = true; } if (!m_Properties) return; if (owner) { if (uint32 slot = m_Properties->Slot) { if (owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID()) { Creature* oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]); if (oldSummon && oldSummon->IsSummon()) oldSummon->ToTempSummon()->UnSummon(); } owner->m_SummonSlot[slot] = GetGUID(); } } if (m_Properties->Faction) setFaction(m_Properties->Faction); else if (IsVehicle() && owner) // properties should be vehicle setFaction(owner->getFaction()); }
void CVehicleEntity::SetModel(DWORD dwModelHash) { // Get the model index from the model hash int iModelIndex = CCharacterManager::ModelHashToVehicleId(dwModelHash); // Do we have an invalid model index? if(iModelIndex == -1) { CLogFile::Printf("CClientVehicle::SetModel Failed (Invalid model hash)!"); return; } // Has the model not changed? if(m_pModelInfo->GetIndex() == iModelIndex) { CLogFile::Printf("CClientVehicle::SetModel Failed (Model change not needed)!"); return; } // Get the new model info auto pNewModelInfo = g_pCore->GetGame()->GetModelInfo(iModelIndex); // Is the new model info valid? if(!pNewModelInfo || !pNewModelInfo->IsValid() || !pNewModelInfo->IsVehicle()) { CLogFile::Printf("CClientVehicle::SetModel Failed (Invalid model)!"); return; } if(IsSpawned()) { // Stream ourselves out CLogFile::Printf("CClientVehicle::SetModel Stream Out Begin"); Destroy(); CLogFile::Printf("CClientVehicle::SetModel Stream Out Complete"); } // Set the new model info m_pModelInfo = pNewModelInfo; // Stream ourselves back in CLogFile::Printf("CClientVehicle::SetModel Stream In Begin"); Create(); CLogFile::Printf("CClientVehicle::SetModel Stream In Complete"); }
VOID CModelInfoSA::Request( EModelRequestType requestType, const char* szTag ) { DEBUG_TRACE("VOID CModelInfoSA::Request( BOOL bAndLoad, BOOL bWaitForLoad )"); // don't bother loading it if it already is if ( IsLoaded () ) return; if ( m_dwModelID <= 288 && m_dwModelID != 7 && !pGame->GetModelInfo ( 7 )->IsLoaded () ) { // Skin 7 must be loaded in order for other skins to work. No, really. (#4010) pGame->GetModelInfo ( 7 )->Request ( requestType, "Model 7" ); } // Bikes can sometimes get stuck when loading unless the anim file is handled like what is does here // Don't change the code below unless you can test it (by recreating the problem it solves) if ( IsVehicle () ) { uint uiAnimFileIndex = GetAnimFileIndex (); if ( uiAnimFileIndex != 0xffffffff ) { uint uiAnimId = uiAnimFileIndex + 25575; CModelInfoSA* pAnim = static_cast < CModelInfoSA* > ( pGame->GetModelInfo ( uiAnimId ) ); if ( !pAnim ) { if ( uiAnimId != 25714 ) LogEvent ( 505, "Model no anim", "", SString ( "%d (%d)", m_dwModelID, uiAnimId ) ); } else if ( !pAnim->IsLoaded() ) { OutputDebugLine ( SString ( "[Models] Requesting anim file %d for model %d", uiAnimId, m_dwModelID ) ); pAnim->Request ( requestType, szTag ); } } } if ( requestType == BLOCKING ) { pGame->GetStreaming()->RequestModel ( m_dwModelID, 0x16 ); pGame->GetStreaming()->LoadAllRequestedModels ( true, szTag ); if ( !IsLoaded() ) { // Try 3 more times, final time without high priority flag int iCount = 0; while ( iCount++ < 10 && !IsLoaded() ) { bool bOnlyPriorityModels = ( iCount < 3 || iCount & 1 ); pGame->GetStreaming()->LoadAllRequestedModels ( bOnlyPriorityModels, szTag ); } if ( !IsLoaded() ) { AddReportLog ( 6641, SString ( "Blocking load fail: %d (%s)", m_dwModelID, szTag ) ); LogEvent ( 641, "Blocking load fail", "", SString ( "%d (%s)", m_dwModelID, szTag ) ); dassert ( 0 ); } else { AddReportLog ( 6642, SString ( "Blocking load: %d (%s) (Took %d attempts)", m_dwModelID, szTag, iCount ) ); LogEvent ( 642, "Blocking load", "", SString ( "%d (%s) (Took %d attempts)", m_dwModelID, szTag, iCount ) ); } } } else { pGame->GetStreaming()->RequestModel ( m_dwModelID, 0x06 ); } }
void TempSummon::InitStats(uint32 duration) { ASSERT(!isPet()); m_timer = duration; m_lifetime = duration; if (m_type == TEMPSUMMON_MANUAL_DESPAWN) m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN; Unit* owner = GetSummoner(); if (owner && isTrigger() && m_spells[0]) { setFaction(owner->getFaction()); SetLevel(owner->getLevel()); if (owner->GetTypeId() == TYPEID_PLAYER) m_ControlledByPlayer = true; } if (!m_Properties) return; // Fix Force of Nature treants stats if (owner && owner->getClass() == CLASS_DRUID && owner->HasSpell(106737)) { float damage = 0.0f; switch (GetEntry()) { case ENTRY_TREANT_RESTO: case ENTRY_TREANT_BALANCE: SetMaxHealth(owner->CountPctFromMaxHealth(40)); break; case ENTRY_TREANT_GUARDIAN: SetMaxHealth(owner->CountPctFromMaxHealth(40)); // (Attack power / 14 * 2 * 0.75) * 0.2f damage = ((owner->GetTotalAttackPowerValue(BASE_ATTACK) / 14.0f) * 2.0f * 0.75f) * 0.2f; SetStatFloatValue(UNIT_FIELD_MINDAMAGE, damage); SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, damage); case ENTRY_TREANT_FERAL: SetMaxHealth(owner->CountPctFromMaxHealth(40)); // Attack power / 14 * 2 * 0.75 damage = (owner->GetTotalAttackPowerValue(BASE_ATTACK) / 14.0f) * 2.0f * 0.75f; SetStatFloatValue(UNIT_FIELD_MINDAMAGE, damage); SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, damage); default: break; } } if (owner) { if (uint32 slot = m_Properties->Slot) { if (owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID()) { Creature* oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]); if (oldSummon && oldSummon->IsSummon()) oldSummon->ToTempSummon()->UnSummon(); } owner->m_SummonSlot[slot] = GetGUID(); } } if (m_Properties->Faction) setFaction(m_Properties->Faction); else if (IsVehicle() && owner) // properties should be vehicle setFaction(owner->getFaction()); }
BOOLEAN StrategicRemoveMerc( SOLDIERTYPE *pSoldier ) { UINT8 ubHistoryCode=0; if ( gfInContractMenuFromRenewSequence ) { EndCurrentContractRenewal( ); } // ATE: Determine which HISTORY ENTRY to use... if ( pSoldier->ubLeaveHistoryCode == 0 ) { // Default use contract expired reason... pSoldier->ubLeaveHistoryCode = HISTORY_MERC_CONTRACT_EXPIRED; } ubHistoryCode = pSoldier->ubLeaveHistoryCode; //if the soldier is DEAD if( pSoldier->stats.bLife <= 0 ) { AddCharacterToDeadList( pSoldier ); } //else if the merc was fired else if( ubHistoryCode == HISTORY_MERC_FIRED || pSoldier->bAssignment == ASSIGNMENT_POW ) { AddCharacterToFiredList( pSoldier ); } //The merc is leaving for some other reason else { AddCharacterToOtherList( pSoldier ); } if( pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__NPC ) { SetupProfileInsertionDataForSoldier( pSoldier ); } if (IsVehicle(pSoldier)) { // for some reason, vehicles have their own idea of handling group ids RemovePlayerFromGroup(pVehicleList[ pSoldier->bVehicleID ].ubMovementGroup, pSoldier); } //remove him from the soldier structure if( pSoldier->bAssignment >= ON_DUTY ) { // is he/she in a mvt group, if so, remove and destroy the group if( pSoldier->ubGroupID ) { if ( pSoldier->bAssignment != VEHICLE ) { //Can only remove groups if they aren't persistant (not in a squad or vehicle) RemoveGroup( pSoldier->ubGroupID ); } else { // remove him from any existing merc slot he could be in RemoveMercSlot( pSoldier ); TakeSoldierOutOfVehicle( pSoldier ); } } } else { RemoveCharacterFromSquads( pSoldier ); } // if the merc is not dead if( gMercProfiles[ pSoldier->ubProfile ].bMercStatus != MERC_IS_DEAD ) { //Set the status to returning home ( delay the merc for rehire ) gMercProfiles[ pSoldier->ubProfile ].bMercStatus = MERC_RETURNING_HOME; // specify how long the merc will continue to be unavailable gMercProfiles[ pSoldier->ubProfile ].uiDayBecomesAvailable = 1 + Random(2); // 1-2 days HandleSoldierLeavingWithLowMorale( pSoldier ); HandleSoldierLeavingForAnotherContract( pSoldier ); } //add an entry in the history page for the firing/quiting of the merc // ATE: Don't do this if they are already dead! if ( !( pSoldier->flags.uiStatusFlags & SOLDIER_DEAD ) ) { AddHistoryToPlayersLog( ubHistoryCode, pSoldier->ubProfile, GetWorldTotalMin(), pSoldier->sSectorX, pSoldier->sSectorY ); } //if the merc was a POW, remember it becuase the merc cant show up in AIM or MERC anymore if( pSoldier->bAssignment == ASSIGNMENT_POW ) { gMercProfiles[ pSoldier->ubProfile ].bMercStatus = MERC_FIRED_AS_A_POW; } //else the merc CAN get his medical deposit back else { //Determine how much of a Medical deposit is going to be refunded to the player CalculateMedicalDepositRefund( pSoldier ); } //remove the merc from the tactical TacticalRemoveSoldier( pSoldier->ubID ); // Check if we should remove loaded world... CheckAndHandleUnloadingOfCurrentWorld(); if ( guiTacticalInterfaceFlags & INTERFACE_MAPSCREEN ) { ReBuildCharactersList( ); } fMapPanelDirty = TRUE; fTeamPanelDirty = TRUE; fCharacterInfoPanelDirty = TRUE; // stop time compression so player can react to the departure StopTimeCompression(); // WDS: This allows for replacing dead IMP mercs. See "BtnIMPBeginScreenDoneCallback" in "IMP Begin Screen.cpp" if( ( pSoldier->ubWhatKindOfMercAmI == MERC_TYPE__PLAYER_CHARACTER ) && ( gMercProfiles[ pSoldier->ubProfile ].bMercStatus == MERC_IS_DEAD ) ) { // Replace the name with an empty string wcsncpy( gMercProfiles[ pSoldier->ubProfile ].zName, L"", 1 ); } // ATE: update team panels.... UpdateTeamPanelAssignments( ); // And unpause the @#$@#$ interface UnLockPauseState(); UnPauseGame(); if (is_client) send_dismiss(pSoldier->ubID); return( TRUE ); }