Ares
Public Member Functions

SW_GeneticMutator Class Reference

#include <src/Misc/SWTypes/GeneticMutator.h>

Inheritance diagram for SW_GeneticMutator:
NewSWType

List of all members.

Public Member Functions

 SW_GeneticMutator ()
virtual ~SW_GeneticMutator ()
virtual const char * GetTypeString ()
virtual void LoadFromINI (SWTypeExt::ExtData *pData, SuperWeaponTypeClass *pSW, CCINIClass *pINI)
virtual void Initialize (SWTypeExt::ExtData *pData, SuperWeaponTypeClass *pSW)
virtual bool Launch (SuperClass *pThis, CellStruct *pCoords, byte IsPlayer)
virtual bool HandlesType (int type)

Constructor & Destructor Documentation

SW_GeneticMutator::SW_GeneticMutator ( ) [inline]
                                    : NewSWType()
                        { };
virtual SW_GeneticMutator::~SW_GeneticMutator ( ) [inline, virtual]
                        { };

Member Function Documentation

virtual const char* SW_GeneticMutator::GetTypeString ( ) [inline, virtual]

Reimplemented from NewSWType.

                        { return NULL; }
bool SW_GeneticMutator::HandlesType ( int  type) [virtual]

Reimplemented from NewSWType.

{
        return (type == SuperWeaponType::GeneticMutator);
}
void SW_GeneticMutator::Initialize ( SWTypeExt::ExtData pData,
SuperWeaponTypeClass *  pSW 
) [virtual]

Reimplemented from NewSWType.

{
        // Defaults to Genetic Mutator values
        pData->SW_AnimHeight = 5;
        pData->SW_Anim = RulesClass::Instance->IonBlast;
        pData->SW_Sound = RulesClass::Instance->GeneticMutatorActivateSound;
        pData->SW_Damage = 10000;

        // defaults depend on MutateExplosion property
        pData->Mutate_Explosion = RulesClass::Instance->MutateExplosion;
        if(pData->Mutate_Explosion.Get()) {
                pData->SW_Warhead = &RulesClass::Instance->MutateExplosionWarhead;
                pData->SW_WidthOrRange = 5;
        } else {
                pData->SW_Warhead = &RulesClass::Instance->MutateWarhead;
                pData->SW_WidthOrRange = 3;
                pData->SW_Height = 3;
        }
                
        pData->Mutate_KillNatural = true;
        pData->Mutate_IgnoreCyborg = false;
        pData->Mutate_IgnoreNotHuman = false;

        pData->EVA_Detected = VoxClass::FindIndex("EVA_GeneticMutatorDetected");
        pData->EVA_Ready = VoxClass::FindIndex("EVA_GeneticMutatorReady");
        pData->EVA_Activated = VoxClass::FindIndex("EVA_GeneticMutatorActivated");
        
        pData->SW_AITargetingType = SuperWeaponAITargetingMode::GeneticMutator;
        pData->SW_Cursor = MouseCursor::First[MouseCursorType::GeneticMutator];
}
bool SW_GeneticMutator::Launch ( SuperClass *  pThis,
CellStruct *  pCoords,
byte  IsPlayer 
) [virtual]

Implements NewSWType.

{
        SuperWeaponTypeClass *pSW = pThis->Type;
        SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pSW);

        CoordStruct coords;
        CellClass *Cell = MapClass::Instance->GetCellAt(pCoords);
        Cell->GetCoordsWithBridge(&coords);
        
        if(pThis->IsCharged) {
                if(pData->Mutate_Explosion.Get()) {
                        // single shot using cellspread warhead
                        MapClass::DamageArea(&coords, pData->SW_Damage, NULL, pData->SW_Warhead, false, pThis->Owner);
                } else {
                        // ranged approach
                        auto Mutate = [&](ObjectClass* pObj) -> bool {
                                if(InfantryClass* pInf = specific_cast<InfantryClass*>(pObj)) {
                                        // is this thing affected at all?
                                        if(!pData->IsHouseAffected(pThis->Owner, pInf->Owner)) {
                                                return true;
                                        }

                                        if(!pData->IsTechnoAffected(pInf)) {
                                                // even if it makes little sense, we do this.
                                                // infantry handling is hardcoded and thus
                                                // this checks water and land cells.
                                                return true;
                                        }

                                        InfantryTypeClass* pType = pInf->Type;

                                        // quick ways out
                                        if(pType->Cyborg && pData->Mutate_IgnoreCyborg.Get()) {
                                                return true;
                                        }

                                        if(pType->NotHuman && pData->Mutate_IgnoreNotHuman.Get()) {
                                                return true;
                                        }

                                        // destroy or mutate
                                        int damage = pType->Strength;
                                        bool kill = (pType->Natural && pData->Mutate_KillNatural.Get());
                                        WarheadTypeClass* pWH = kill
                                                ? RulesClass::Instance->C4Warhead
                                                : pData->SW_Warhead;

                                        pInf->ReceiveDamage(&damage, 0, pWH, NULL, true, false, pThis->Owner);
                                }

                                return true;
                        };

                        // find everything in range and mutate it
                        if(Helpers::Alex::DistinctCollector<ObjectClass*> *items = new Helpers::Alex::DistinctCollector<ObjectClass*>()) {
                                Helpers::Alex::forEachObjectInRange(pCoords, pData->SW_WidthOrRange, pData->SW_Height, items->getCollector());
                                items->forEach(Mutate);
                                delete items;
                        }
                }
        }

        return true;
}
void SW_GeneticMutator::LoadFromINI ( SWTypeExt::ExtData pData,
SuperWeaponTypeClass *  pSW,
CCINIClass *  pINI 
) [virtual]

Reimplemented from NewSWType.

{
        const char * section = pSW->ID;

        if(!pINI->GetSection(section)) {
                return;
        }

        INI_EX exINI(pINI);
        pData->Mutate_Explosion.Read(&exINI, section, "Mutate.Explosion");
        pData->Mutate_IgnoreCyborg.Read(&exINI, section, "Mutate.IgnoreCyborg");
        pData->Mutate_IgnoreNotHuman.Read(&exINI, section, "Mutate.IgnoreNotHuman");
        pData->Mutate_KillNatural.Read(&exINI, section, "Mutate.KillNatural");

        // whatever happens, always target everything
        pData->SW_AffectsTarget = pData->SW_AffectsTarget.Get() | SuperWeaponTarget::AllTechnos;
}

The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines