Ares
Classes | Public Types | Static Public Member Functions | Static Public Attributes

SWTypeExt Class Reference

#include <src/Ext/SWType/Body.h>

List of all members.

Classes

class  ExtData

Public Types

typedef SuperWeaponTypeClass TT

Static Public Member Functions

static bool Launch (SuperClass *pThis, NewSWType *pData, CellStruct *pCoords, byte IsPlayer)
static void ClearChronoAnim (SuperClass *pThis)
static void CreateChronoAnim (SuperClass *pThis, CoordStruct *pCoords, AnimTypeClass *pAnimType)
static bool ChangeLighting (SuperClass *pThis)
static bool ChangeLighting (SuperWeaponTypeClass *pThis)

Static Public Attributes

static Container< SWTypeExtExtMap
static SuperWeaponTypeClass * CurrentSWType = NULL

Member Typedef Documentation

typedef SuperWeaponTypeClass SWTypeExt::TT

Member Function Documentation

bool SWTypeExt::ChangeLighting ( SuperClass *  pThis) [static]
                                                {
        if(pThis) {
                return ChangeLighting(pThis->Type);
        }
        return false;
}
bool SWTypeExt::ChangeLighting ( SuperWeaponTypeClass *  pThis) [static]
                                                          {
        if(pThis) {
                if(SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pThis)) {
                        return pData->ChangeLighting();
                }
        }
        return false;
}
void SWTypeExt::ClearChronoAnim ( SuperClass *  pThis) [static]
{
        DynamicVectorClass<SuperClass*>* pSupers = (DynamicVectorClass<SuperClass*>*)0xB0F5B8;

        if(pThis->Animation) {
                pThis->Animation->RemainingIterations = 0;
                pThis->Animation = NULL;
                int idx = pSupers->FindItemIndex(&pThis);
                if(idx != -1) {
                        pSupers->RemoveItem(idx);
                }
        }

        if(pThis->unknown_bool_6C) {
                int idx = pSupers->FindItemIndex(&pThis);
                if(idx != -1) {
                        pSupers->RemoveItem(idx);
                }
                pThis->unknown_bool_6C = false;
        }
}
void SWTypeExt::CreateChronoAnim ( SuperClass *  pThis,
CoordStruct *  pCoords,
AnimTypeClass *  pAnimType 
) [static]
{
        DynamicVectorClass<SuperClass*>* pSupers = (DynamicVectorClass<SuperClass*>*)0xB0F5B8;

        ClearChronoAnim(pThis);
        
        if(pAnimType && pCoords) {
                AnimClass* pAnim = NULL;
                GAME_ALLOC(AnimClass, pAnim, pAnimType, pCoords);
                if(pAnim) {
                        SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pThis->Type);
                        pAnim->Invisible = !pData->IsAnimVisible(pThis->Owner);
                        pThis->Animation = pAnim;
                        pSupers->AddItem(pThis);
                }
        }
}
bool SWTypeExt::Launch ( SuperClass *  pThis,
NewSWType pData,
CellStruct *  pCoords,
byte  IsPlayer 
) [static]
                                                                                            {
        if(SWTypeExt::ExtData *pData = SWTypeExt::ExtMap.Find(pThis->Type)) {

                // launch the SW, then play sounds and animations. if the SW isn't launched
                // nothing will be played.
                if(pSW->Launch(pThis, pCoords, IsPlayer)) {
                        SuperWeaponFlags::Value flags = pSW->Flags();

                        if(flags & SuperWeaponFlags::PostClick) {
                                // use the properties of the originally fired SW
                                if(HouseExt::ExtData *pExt = HouseExt::ExtMap.Find(pThis->Owner)) {
                                        if(pThis->Owner->Supers.ValidIndex(pExt->SWLastIndex)) {
                                                pThis = pThis->Owner->Supers.GetItem(pExt->SWLastIndex);
                                                pData = SWTypeExt::ExtMap.Find(pThis->Type);
                                        }
                                }
                        }

                        if(!Unsorted::MuteSWLaunches && (pData->EVA_Activated != -1) && !(flags & SuperWeaponFlags::NoEVA)) {
                                VoxClass::PlayIndex(pData->EVA_Activated);
                        }
                        
                        if(!(flags & SuperWeaponFlags::NoMoney)) {
                                int Money_Amount = pData->Money_Amount;
                                if(Money_Amount > 0) {
                                        DEBUGLOG("House %d gets %d credits\n", pThis->Owner->ArrayIndex, Money_Amount);
                                        pThis->Owner->GiveMoney(Money_Amount);
                                } else if(Money_Amount < 0) {
                                        DEBUGLOG("House %d loses %d credits\n", pThis->Owner->ArrayIndex, -Money_Amount);
                                        pThis->Owner->TakeMoney(-Money_Amount);
                                }
                        }

                        CellClass *pTarget = MapClass::Instance->GetCellAt(pCoords);

                        CoordStruct coords;
                        pTarget->GetCoordsWithBridge(&coords);

                        if((pData->SW_Anim.Get() != NULL) && !(flags & SuperWeaponFlags::NoAnim)) {
                                coords.Z += pData->SW_AnimHeight;
                                AnimClass *placeholder;
                                GAME_ALLOC(AnimClass, placeholder, pData->SW_Anim, &coords);
                                placeholder->Invisible = !pData->IsAnimVisible(pThis->Owner);
                        }

                        if((pData->SW_Sound != -1) && !(flags & SuperWeaponFlags::NoSound)) {
                                VocClass::PlayAt(pData->SW_Sound, &coords, NULL);
                        }

                        if(pData->SW_RadarEvent.Get() && !(flags & SuperWeaponFlags::NoEvent)) {
                                RadarEventClass::Create(RADAREVENT_SUPERWEAPONLAUNCHED, *pCoords);
                        }

                        if(pData->Message_Launch && !(flags & SuperWeaponFlags::NoMessage)) {
                                pData->PrintMessage(pData->Message_Launch, pThis->Owner);
                        }

                        // this sw has been fired. clean up.
                        int idxThis = pThis->Owner->Supers.FindItemIndex(&pThis);
                        if(IsPlayer && !(flags & SuperWeaponFlags::NoCleanup)) {
                                // what's this? we reset the selected SW only for the player on this
                                // computer, so others don't deselect it when firing simultaneously.
                                // and we only do this, if this type's index is the current one, because
                                // auto-firing might happen while the player still selects a target.
                                // PostClick SWs do have a different type index, so they need to be
                                // special cased, but they can't auto-fire anyhow.
                                if(pThis->Owner == HouseClass::Player) {
                                        if(idxThis == Unsorted::CurrentSWType || (flags & SuperWeaponFlags::PostClick)) {
                                                Unsorted::CurrentSWType = -1;
                                        }
                                }

                                // do not play ready sound. this thing just got off.
                                if(pData->EVA_Ready != -1) {
                                        VoxClass::SilenceIndex(pData->EVA_Ready);
                                }
                        }

                        if(HouseExt::ExtData *pExt = HouseExt::ExtMap.Find(pThis->Owner)) {
                                // post-click actions. AutoFire SWs cannot support this. Consider
                                // two Chronospheres auto-firing (the second may be launched manually).
                                // the ChronoWarp would chose the source selected last, because it
                                // would overwrite the previous (unfired) SW's index.
                                if(!(flags & SuperWeaponFlags::PostClick) && !pData->SW_AutoFire) {
                                        pExt->SWLastIndex = idxThis;
                                }
                        }
        
                        return true;
                }
        }

        return false;
}

Member Data Documentation

SuperWeaponTypeClass * SWTypeExt::CurrentSWType = NULL [static]

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