Ares
|
#include <src/Ext/SWType/Body.h>
SWTypeExt::ExtData::ExtData | ( | const DWORD | Canary, |
TT *const | OwnerObject | ||
) | [inline] |
: Extension<TT>(Canary, OwnerObject), SpyPlane_TypeIndex (0), SpyPlane_Count (1), SpyPlane_Mission (mission_AttackAgain), Weather_CloudHeight (-1), Weather_ScatterCount (1), Nuke_PsiWarning (NULL), Sonar_Delay (0), SW_ActivationSound (-1), SW_ChargeToDrainRatio (&RulesClass::Instance->ChargeToDrainRatio), Money_Amount (0), Money_DrainAmount (0), Money_DrainDelay (0), EVA_Ready (-1), EVA_Activated (-1), EVA_Detected (-1), EVA_Impatient (-1), EVA_InsufficientFunds (-1), Message_ColorScheme (-1), Message_FirerColor (false), Lighting_Enabled (true), SW_Sound (-1), SW_Anim (NULL), SW_AnimHeight (0), SW_AnimVisibility (SuperWeaponAffectedHouse::All), SW_TypeCustom (false), SW_AutoFire (false), SW_ManualFire (true), SW_ShowCameo (true), SW_Unstoppable (false), SW_AffectsHouse (SuperWeaponAffectedHouse::All), SW_RequiresHouse (SuperWeaponAffectedHouse::None), SW_AffectsTarget (SuperWeaponTarget::All), SW_RequiresTarget (SuperWeaponTarget::None), SW_AITargetingType (SuperWeaponAITargetingMode::None), SW_FireToShroud (true), SW_RadarEvent (true), SW_WidthOrRange (-1), SW_Height (-1), HandledByNewSWType (-1), CameoPal(), SW_DeliverBuildups (false), SW_Damage(0) { *SidebarPCX = 0; *SW_PostDependent = 0; *Message_Detected = 0; *Message_Ready = 0; *Message_Launch = 0; *Message_Activate = 0; *Message_Abort = 0; *Message_InsufficientFunds = 0; *Text_Preparing = 0; *Text_Ready = 0; *Text_Hold = 0; *Text_Charging = 0; *Text_Active = 0; };
SWTypeExt::ExtData::~ExtData | ( | ) | [virtual] |
{ this->ParaDrop.clear(); for(int i=this->ParaDropPlanes.Count-1; i>=0; --i) { delete this->ParaDropPlanes.Items[i]; this->ParaDropPlanes.Items[i] = NULL; } };
bool SWTypeExt::ExtData::CanFireAt | ( | CellStruct * | pCoords | ) |
{ if(CellClass *pCell = MapClass::Instance->GetCellAt(pCoords)) { // check cell type if(!IsCellEligible(pCell, this->SW_RequiresTarget)) { return false; } // check for techno type match TechnoClass *pTechno = generic_cast<TechnoClass*>(pCell->GetContent()); if(pTechno && this->SW_RequiresHouse != SuperWeaponAffectedHouse::None) { if(!IsHouseAffected(HouseClass::Player, pTechno->Owner, this->SW_RequiresHouse)) { return false; } } if(!IsTechnoEligible(pTechno, this->SW_RequiresTarget)) { return false; } } // no restriction return true; }
bool SWTypeExt::ExtData::ChangeLighting | ( | ) |
{ if(this->Lighting_Enabled.Get()) { auto getValue = [](int value, int def) -> int { return (value < 0) ? def : value; }; ScenarioClass* scen = ScenarioClass::Instance; scen->AmbientTarget = getValue(this->Lighting_Ambient, scen->AmbientOriginal); int cG = 1000 * getValue(this->Lighting_Green, scen->Green) / 100; int cB = 1000 * getValue(this->Lighting_Blue, scen->Blue) / 100; int cR = 1000 * getValue(this->Lighting_Red, scen->Red) / 100; scen->RecalcLighting(cR, cG, cB, 1); return true; } return false; }
NewSWType * SWTypeExt::ExtData::GetNewSWType | ( | ) |
{ int TypeIdx = (this->HandledByNewSWType != -1 ? this->HandledByNewSWType : this->AttachedToObject->Type); RET_UNLESS(TypeIdx >= FIRST_SW_TYPE); if(NewSWType* pSW = NewSWType::GetNthItem(TypeIdx)) { return pSW; } return NULL; }
SuperWeaponAffectedHouse::Value SWTypeExt::ExtData::GetRelation | ( | HouseClass * | pFirer, |
HouseClass * | pHouse | ||
) | [static, private] |
{ // that's me! if(pFirer == pHouse) { return SuperWeaponAffectedHouse::Owner; } if(pFirer->IsAlliedWith(pHouse)) { // only friendly houses return SuperWeaponAffectedHouse::Allies; } // the bad guys return SuperWeaponAffectedHouse::Enemies; }
void SWTypeExt::ExtData::InitializeConstants | ( | TT * | pThis | ) | [virtual] |
{ if(!NewSWType::Array.Count) { NewSWType::Init(); } MouseCursor *Cursor = &this->SW_Cursor; Cursor->Frame = 53; // Attack Cursor->Count = 5; Cursor->Interval = 5; // test? Cursor->MiniFrame = 52; Cursor->MiniCount = 1; Cursor->HotX = hotspx_center; Cursor->HotY = hotspy_middle; Cursor = &this->SW_NoCursor; Cursor->Frame = 0; Cursor->Count = 1; Cursor->Interval = 5; Cursor->MiniFrame = 1; Cursor->MiniCount = 1; Cursor->HotX = hotspx_center; Cursor->HotY = hotspy_middle; AresCRT::strCopy(this->Text_Ready, "TXT_READY", 0x20); AresCRT::strCopy(this->Text_Hold, "TXT_HOLD", 0x20); AresCRT::strCopy(this->Text_Charging, "TXT_CHARGING", 0x20); AresCRT::strCopy(this->Text_Active, "TXT_FIRESTORM_ON", 0x20); EVA_InsufficientFunds = VoxClass::FindIndex("EVA_InsufficientFunds"); }
void SWTypeExt::ExtData::InitializeRuled | ( | TT * | pThis | ) | [virtual] |
{ }
virtual void SWTypeExt::ExtData::InvalidatePointer | ( | void * | ptr | ) | [inline, virtual] |
Implements Extension< TT >.
{ }
bool SWTypeExt::ExtData::IsAnimVisible | ( | HouseClass * | pFirer | ) |
{ SuperWeaponAffectedHouse::Value relation = GetRelation(pFirer, HouseClass::Player); return (this->SW_AnimVisibility & relation) == relation; }
bool SWTypeExt::ExtData::IsCellEligible | ( | CellClass * | pCell, |
SuperWeaponTarget::Value | allowed | ||
) | [private] |
{ if(allowed & SuperWeaponTarget::AllCells) { bool isWater = (pCell->LandType == lt_Water); if(isWater && !(allowed & SuperWeaponTarget::Water)) { // doesn't support water return false; } else if(!isWater && !(allowed & SuperWeaponTarget::Land)) { // doesn't support non-water return false; } } return true; }
bool SWTypeExt::ExtData::IsHouseAffected | ( | HouseClass * | pFirer, |
HouseClass * | pHouse | ||
) |
{ return IsHouseAffected(pFirer, pHouse, this->SW_AffectsHouse); }
bool SWTypeExt::ExtData::IsHouseAffected | ( | HouseClass * | pFirer, |
HouseClass * | pHouse, | ||
SuperWeaponAffectedHouse::Value | value | ||
) |
{ SuperWeaponAffectedHouse::Value relation = GetRelation(pFirer, pHouse); return (value & relation) == relation; }
bool SWTypeExt::ExtData::IsTechnoAffected | ( | TechnoClass * | pTechno | ) |
{ // check land and water cells if(!IsCellEligible(pTechno->GetCell(), this->SW_AffectsTarget)) { return false; } // check for specific techno type if(!IsTechnoEligible(pTechno, this->SW_AffectsTarget)) { return false; } // no restriction return true; }
bool SWTypeExt::ExtData::IsTechnoEligible | ( | TechnoClass * | pTechno, |
SuperWeaponTarget::Value | allowed | ||
) | [private] |
{ if(allowed & SuperWeaponTarget::AllContents) { if(pTechno) { eAbstractType abs_Techno = pTechno->WhatAmI(); if((abs_Techno == abs_Infantry) && !(allowed & SuperWeaponTarget::Infantry)) { return false; } else if(((abs_Techno == abs_Unit) || (abs_Techno == abs_Aircraft)) && !(allowed & SuperWeaponTarget::Unit)) { return false; } else if((abs_Techno == abs_Building) && !(allowed & SuperWeaponTarget::Building)) { return false; } } else { // is the target cell allowed to be empty? return (allowed & SuperWeaponTarget::NoContent) != 0; } } return true; }
void SWTypeExt::ExtData::LoadFromINIFile | ( | TT * | pThis, |
CCINIClass * | pINI | ||
) | [virtual] |
{ const char * section = pThis->get_ID(); if(!pINI->GetSection(section)) { return; } INI_EX exINI(pINI); // read general properties this->EVA_Ready.Read(&exINI, section, "EVA.Ready"); this->EVA_Activated.Read(&exINI, section, "EVA.Activated"); this->EVA_Detected.Read(&exINI, section, "EVA.Detected"); this->EVA_Impatient.Read(&exINI, section, "EVA.Impatient"); this->EVA_InsufficientFunds.Read(&exINI, section, "EVA.InsufficientFunds"); this->SW_FireToShroud.Read(&exINI, section, "SW.FireIntoShroud"); this->SW_AutoFire.Read(&exINI, section, "SW.AutoFire"); this->SW_ManualFire.Read(&exINI, section, "SW.ManualFire"); this->SW_RadarEvent.Read(&exINI, section, "SW.CreateRadarEvent"); this->SW_ShowCameo.Read(&exINI, section, "SW.ShowCameo"); this->SW_Unstoppable.Read(&exINI, section, "SW.Unstoppable"); this->Money_Amount.Read(&exINI, section, "Money.Amount"); this->Money_DrainAmount.Read(&exINI, section, "Money.DrainAmount"); this->Money_DrainDelay.Read(&exINI, section, "Money.DrainDelay"); this->SW_Sound.Read(&exINI, section, "SW.Sound"); this->SW_ActivationSound.Read(&exINI, section, "SW.ActivationSound"); this->SW_Anim.Parse(&exINI, section, "SW.Animation"); this->SW_AnimHeight.Read(&exINI, section, "SW.AnimationHeight"); this->SW_AnimVisibility.Read(&exINI, section, "SW.AnimationVisibility"); this->SW_AffectsHouse.Read(&exINI, section, "SW.AffectsHouse"); this->SW_AITargetingType.Read(&exINI, section, "SW.AITargeting"); this->SW_AffectsTarget.Read(&exINI, section, "SW.AffectsTarget"); this->SW_RequiresTarget.Read(&exINI, section, "SW.RequiresTarget"); this->SW_RequiresHouse.Read(&exINI, section, "SW.RequiresHouse"); this->SW_Deferment.Read(&exINI, section, "SW.Deferment"); this->SW_ChargeToDrainRatio.Read(&exINI, section, "SW.ChargeToDrainRatio"); this->SW_Cursor.Read(&exINI, section, "Cursor"); this->SW_NoCursor.Read(&exINI, section, "NoCursor"); this->SW_Warhead.Parse(&exINI, section, "SW.Warhead"); this->SW_Damage.Read(&exINI, section, "SW.Damage"); if(pINI->ReadString(section, "SW.Range", Ares::readDefval, Ares::readBuffer, Ares::readLength)) { char* p = strtok(Ares::readBuffer, Ares::readDelims); if(p && *p) { this->SW_WidthOrRange = (float)atof(p); this->SW_Height = -1; p = strtok(NULL, Ares::readDelims); if(p && *p) { this->SW_Height = atoi(p); } } } // lighting this->Lighting_Enabled.Read(&exINI, section, "Light.Enabled"); this->Lighting_Ambient.Read(&exINI, section, "Light.Ambient"); this->Lighting_Red.Read(&exINI, section, "Light.Red"); this->Lighting_Green.Read(&exINI, section, "Light.Green"); this->Lighting_Blue.Read(&exINI, section, "Light.Blue"); auto readString = [&](char* value, char* key) { if(pINI->ReadString(section, key, Ares::readDefval, Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(value, Ares::readBuffer, 0x20); } }; // messages and their properties this->Message_FirerColor.Read(&exINI, section, "Message.FirerColor"); if(pINI->ReadString(section, "Message.Color", Ares::readDefval, Ares::readBuffer, Ares::readLength)) { this->Message_ColorScheme = ColorScheme::FindIndex(Ares::readBuffer); if(!this->Message_ColorScheme) { Debug::INIParseFailed(section, "Message.Color", Ares::readBuffer, "Expected a valid color scheme name."); } } readString(this->Message_Detected, "Message.Detected"); readString(this->Message_Ready, "Message.Ready"); readString(this->Message_Launch, "Message.Launch"); readString(this->Message_Activate, "Message.Activate"); readString(this->Message_Abort, "Message.Abort"); readString(this->Message_InsufficientFunds, "Message.InsufficientFunds"); readString(this->Text_Preparing, "Text.Preparing"); readString(this->Text_Ready, "Text.Ready"); readString(this->Text_Hold, "Text.Hold"); readString(this->Text_Charging, "Text.Charging"); readString(this->Text_Active, "Text.Active"); // the fallback is handled in the PreDependent SW's code if(pINI->ReadString(section, "SW.PostDependent", Ares::readDefval, Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->SW_PostDependent, Ares::readBuffer, 0x18); } // find a NewSWType that handles this original one. int idxNewSWType = ((pThis->Type < FIRST_SW_TYPE) ? this->HandledByNewSWType : pThis->Type); // initialize the NewSWType that handles this SWType. int Type = idxNewSWType - FIRST_SW_TYPE; if(Type >= 0 && Type < NewSWType::Array.Count) { pThis->Action = this->LastAction; NewSWType *swt = NewSWType::GetNthItem(idxNewSWType); swt->LoadFromINI(this, pThis, pINI); this->LastAction = pThis->Action; // whatever the user does, we take care of the stupid tags. // there is no need to have them not hardcoded. SuperWeaponFlags::Value flags = swt->Flags(); pThis->PreClick = ((flags & SuperWeaponFlags::PreClick) != 0); pThis->PostClick = ((flags & SuperWeaponFlags::PostClick) != 0); pThis->PreDependent = -1; } this->CameoPal.LoadFromINI(pINI, pThis->ID, "SidebarPalette"); if(pINI->ReadString(section, "SidebarPCX", "", Ares::readBuffer, Ares::readLength)) { AresCRT::strCopy(this->SidebarPCX, Ares::readBuffer, 0x20); _strlwr_s(this->SidebarPCX, 0x20); if(!PCX::Instance->LoadFile(this->SidebarPCX)) { Debug::INIParseFailed(section, "SidebarPCX", this->SidebarPCX); } } }
void SWTypeExt::ExtData::LoadFromRulesFile | ( | TT * | pThis, |
CCINIClass * | pINI | ||
) | [virtual] |
{ const char * section = pThis->get_ID(); if(!pINI->GetSection(section)) { return; } INI_EX exINI(pINI); if(exINI.ReadString(section, "Action") && !_strcmpi(exINI.value(), "Custom")) { pThis->Action = SW_YES_CURSOR; } if(exINI.ReadString(section, "Type")) { int customType = NewSWType::FindIndex(exINI.value()); if(customType > -1) { pThis->Type = customType; } } // find a NewSWType that handles this original one. int idxNewSWType = -1; if(pThis->Type < FIRST_SW_TYPE) { this->HandledByNewSWType = NewSWType::FindHandler(pThis->Type); idxNewSWType = this->HandledByNewSWType; } else { idxNewSWType = pThis->Type; } // if this is handled by a NewSWType, initialize it. if(idxNewSWType != -1) { pThis->Action = SW_YES_CURSOR; if(NewSWType *swt = NewSWType::GetNthItem(idxNewSWType)) { swt->Initialize(this, pThis); } } this->LastAction = pThis->Action; }
void SWTypeExt::ExtData::PrintMessage | ( | char * | Message, |
HouseClass * | pFirer | ||
) |
{ if(!pMessage || !*pMessage) { return; } int color = ColorScheme::FindIndex("Gold"); if(this->Message_FirerColor.Get()) { // firer color if(pFirer) { color = pFirer->ColorSchemeIndex; } } else { if(this->Message_ColorScheme > -1) { // user defined color color = this->Message_ColorScheme; } else if(HouseClass::Player) { // default way: the current player's color color = HouseClass::Player->ColorSchemeIndex; } } // print the message const wchar_t* label = StringTable::LoadStringA(pMessage); if(label && *label) { MessageListClass::Instance->PrintMessage(label, color); } }
virtual size_t SWTypeExt::ExtData::Size | ( | ) | const [inline, virtual] |
Implements Extension< TT >.
{ return sizeof(*this); };
Valueable<AnimTypeClass *> SWTypeExt::ExtData::Chronosphere_BlastDest |
Valueable<AnimTypeClass *> SWTypeExt::ExtData::Chronosphere_BlastSrc |
Customizable<AnimTypeClass*> SWTypeExt::ExtData::Dominator_ControlAnim |
Customizable<AnimTypeClass*> SWTypeExt::ExtData::Dominator_FirstAnim |
Customizable<AnimTypeClass*> SWTypeExt::ExtData::Dominator_SecondAnim |
ValueableIdx<int, VoxClass> SWTypeExt::ExtData::EVA_Activated |
ValueableIdx<int, VoxClass> SWTypeExt::ExtData::EVA_Detected |
ValueableIdx<int, VoxClass> SWTypeExt::ExtData::EVA_Impatient |
ValueableIdx<int, VoxClass> SWTypeExt::ExtData::EVA_InsufficientFunds |
ValueableIdx<int, VoxClass> SWTypeExt::ExtData::EVA_Ready |
char SWTypeExt::ExtData::Message_Abort[0x20] |
char SWTypeExt::ExtData::Message_Activate[0x20] |
char SWTypeExt::ExtData::Message_Detected[0x20] |
char SWTypeExt::ExtData::Message_Launch[0x20] |
char SWTypeExt::ExtData::Message_Ready[0x20] |
Valueable<WeaponTypeClass*> SWTypeExt::ExtData::Nuke_Payload |
Valueable<AnimTypeClass*> SWTypeExt::ExtData::Nuke_PsiWarning |
Valueable<AnimTypeClass*> SWTypeExt::ExtData::Nuke_TakeOff |
hash_map<AbstractTypeClass*, DynamicVectorClass<ParadropPlane*> > SWTypeExt::ExtData::ParaDrop |
DynamicVectorClass<ParadropPlane*> SWTypeExt::ExtData::ParaDropPlanes |
char SWTypeExt::ExtData::SidebarPCX[0x20] |
ValueableIdx<int, MissionClass> SWTypeExt::ExtData::SpyPlane_Mission |
ValueableIdx<int, AircraftTypeClass> SWTypeExt::ExtData::SpyPlane_TypeIndex |
ValueableIdx<int, VocClass> SWTypeExt::ExtData::SW_ActivationSound |
Valueable<AnimTypeClass *> SWTypeExt::ExtData::SW_Anim |
Valueable<MouseCursor> SWTypeExt::ExtData::SW_Cursor |
DynamicVectorClass<TechnoTypeClass *> SWTypeExt::ExtData::SW_Deliverables |
Valueable<MouseCursor> SWTypeExt::ExtData::SW_NoCursor |
char SWTypeExt::ExtData::SW_PostDependent[0x18] |
ValueableIdx<int, VocClass> SWTypeExt::ExtData::SW_Sound |
Customizable<WarheadTypeClass *> SWTypeExt::ExtData::SW_Warhead |
char SWTypeExt::ExtData::Text_Active[0x20] |
char SWTypeExt::ExtData::Text_Charging[0x20] |
char SWTypeExt::ExtData::Text_Hold[0x20] |
char SWTypeExt::ExtData::Text_Preparing[0x20] |
char SWTypeExt::ExtData::Text_Ready[0x20] |
Valueable<AnimTypeClass*> SWTypeExt::ExtData::Weather_BoltExplosion |
TypeList<AnimTypeClass*> SWTypeExt::ExtData::Weather_Bolts |
TypeList<AnimTypeClass*> SWTypeExt::ExtData::Weather_Clouds |
TypeList<AnimTypeClass*> SWTypeExt::ExtData::Weather_Debris |
TypeList<int> SWTypeExt::ExtData::Weather_Sounds |