Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: Ext/AnimType/Body.cpp
- ===================================================================
- --- Ext/AnimType/Body.cpp (revision 1169)
- +++ Ext/AnimType/Body.cpp (working copy)
- @@ -80,7 +80,7 @@
- return 0;
- }
- -DEFINE_HOOK(427888, AnimTypeClass_DTOR, 5)
- +DEFINE_HOOK(428EA8, AnimTypeClass_SDDTOR, 5)
- {
- GET(AnimTypeClass*, pItem, ECX);
- Property changes on: Ext\Building\Hooks.Foundation.cpp
- ___________________________________________________________________
- Modified: svn:mergeinfo
- Merged /trunk/src/Ext/Building/Hooks.Foundation.cpp:r1168-1169
- Index: Ext/Techno/Body.cpp
- ===================================================================
- --- Ext/Techno/Body.cpp (revision 1169)
- +++ Ext/Techno/Body.cpp (working copy)
- @@ -435,6 +435,81 @@
- }
- }
- +void TechnoExt::TransferAttachedEffects(TechnoClass *From, TechnoClass *To) {
- + auto FromExt = TechnoExt::ExtMap.Find(From);
- + auto ToExt = TechnoExt::ExtMap.Find(To);
- + ToExt->AttachedEffects.Clear();
- + if (FromExt->AttachedEffects.Count != 0) {
- +
- + // while recreation itself isn't the best idea, less hassle and more reliable
- + // list gets intact in the end
- + for (int i=0; i<FromExt->AttachedEffects.Count; i++){
- + FromExt->AttachedEffects.GetItem(i)->Type->Attach(To, FromExt->AttachedEffects.GetItem(i)->ActualDuration);
- + FromExt->AttachedEffects.GetItem(i)->Destroy();
- + delete FromExt->AttachedEffects.GetItem(i);
- +
- + }
- + FromExt->AttachedEffects.Clear();
- + FromExt->AttachedTechnoEffect_isset=false;
- + TechnoExt::RecalculateStats(To);
- + }
- +
- +}
- +
- +/*! This function recalculates the stats modifiable by crates and update them (aimed for request #255)
- + \todo code that crate effects not get ignored
- + \author Graion Dilach
- + \date 2011-10-12
- +*/
- +
- +void TechnoExt::RecalculateStats(TechnoClass *pTechno){
- + auto pTechnoExt = TechnoExt::ExtMap.Find(pTechno);
- + double Firepower = 1, Armor = 1, Speed = 1; //if there's hooks for crate-stuff, they could be the base for this
- + bool Cloak = TechnoExt::CanICloakByDefault(pTechno);
- +
- + if (pTechnoExt->AttachedEffects.Count != -1 && pTechnoExt->AttachedEffects.Count != 0){ //QDB #666... -_-
- + for (int i=0; i < pTechnoExt->AttachedEffects.Count; i++){
- +
- + Firepower *= pTechnoExt->AttachedEffects.GetItem(i)->Type->FirepowerMultiplier;
- + Speed *= pTechnoExt->AttachedEffects.GetItem(i)->Type->SpeedMultiplier;
- + Armor *= pTechnoExt->AttachedEffects.GetItem(i)->Type->ArmorMultiplier;
- + Cloak = Cloak || pTechnoExt->AttachedEffects.GetItem(i)->Type->Cloakable;
- +
- + }
- + }
- +
- + pTechno->FirepowerMultiplier = Firepower;
- + pTechno->ArmorMultiplier = Armor;
- + pTechno->Cloakable = Cloak;
- +
- + if(FootClass *Foot = generic_cast<FootClass *>(pTechno)) {
- + Foot->SpeedMultiplier = Speed;
- + }
- +}
- +
- +/*! This function calculates that the unit wold be cloaked by default
- + \author Graion Dilach
- + \date 2011-10-16
- +*/
- +
- +
- +bool TechnoExt::CanICloakByDefault(TechnoClass *pTechno){
- + if (pTechno->GetTechnoType()->Cloakable){
- + return true;
- + }
- +
- + if (pTechno->Veterancy.IsVeteran() && pTechno->GetTechnoType()->VeteranAbilities.CLOAK){
- + return true;
- + }
- +
- + if (pTechno->Veterancy.IsElite() && (pTechno->GetTechnoType()->VeteranAbilities.CLOAK || pTechno->GetTechnoType()->EliteAbilities.CLOAK)){
- + return true;
- + }
- +
- + return false;
- +}
- +
- +
- bool TechnoExt::ExtData::IsDeactivated() const {
- return this->AttachedToObject->Deactivated;
- }
- Index: Ext/Techno/Body.h
- ===================================================================
- --- Ext/Techno/Body.h (revision 1169)
- +++ Ext/Techno/Body.h (working copy)
- @@ -58,6 +58,12 @@
- // issue #617 powered units
- PoweredUnitClass* PoweredUnit;
- + //#1573, #1623, #255 Stat-modifiers/ongoing animations
- + DynamicVectorClass <AttachEffectClass *> AttachedEffects;
- +
- + //boolean for #1623
- + bool AttachedTechnoEffect_isset;
- +
- ExtData(const DWORD Canary, TT* const OwnerObject) : Extension<TT>(Canary, OwnerObject),
- idxSlot_Wave (0),
- idxSlot_Beam (0),
- @@ -70,7 +76,8 @@
- EMPLastMission (mission_None),
- ShadowDrawnManually (false),
- RadarJam(NULL),
- - PoweredUnit(NULL)
- + PoweredUnit(NULL),
- + AttachedTechnoEffect_isset (false)
- {
- this->CloakSkipTimer.Stop();
- // hope this works with the timing - I assume it does, since Types should be created before derivates thereof
- @@ -102,6 +109,7 @@
- bool IsDeactivated() const;
- eAction GetDeactivatedAction(ObjectClass *Hovered = NULL) const;
- +
- };
- static Container<TechnoExt> ExtMap;
- @@ -125,7 +133,11 @@
- static void TransferMindControl(TechnoClass *From, TechnoClass *To);
- static void TransferIvanBomb(TechnoClass *From, TechnoClass *To);
- + static void TransferAttachedEffects(TechnoClass *From, TechnoClass *To);
- + static void RecalculateStats(TechnoClass *pTechno);
- + static bool CanICloakByDefault(TechnoClass *pTechno);
- +
- static void Destroy(TechnoClass* pTechno, TechnoClass* pKiller = NULL, HouseClass* pKillerHouse = NULL, WarheadTypeClass* pWarhead = NULL);
- /*
- static int SelectWeaponAgainst(TechnoClass *pThis, TechnoClass *pTarget);
- Index: Ext/Techno/Hooks.cpp
- ===================================================================
- --- Ext/Techno/Hooks.cpp (revision 1169)
- +++ Ext/Techno/Hooks.cpp (working copy)
- @@ -64,6 +64,33 @@
- pData->PoweredUnit->Update();
- }
- +
- + //#1573, #1623, #255 - updating attached effects
- + if (pData->AttachedEffects.Count) {
- + int j = pData->AttachedEffects.Count;
- + for (int i=pData->AttachedEffects.Count; i>0; --i) {
- + auto Effect = pData->AttachedEffects.GetItem(i-1);
- + --Effect->ActualDuration;
- + if(!Effect->ActualDuration) { //Bloody crashes - apparently if cloaked and attached, during delete it might crash.
- + Effect->Destroy();
- + if (Effect->Type->ID == Source->GetTechnoType()->ID) { //#1623, hardcodes Cumulative to false
- + pData->AttachedTechnoEffect_isset=false;
- + }
- + delete Effect;
- + pData->AttachedEffects.RemoveItem(i-1);
- + TechnoExt::RecalculateStats(Source); //and update the unit's properties
- + }
- +
- + }
- +
- + }
- +
- + //#1623 - generating AttachedEffect from Type
- + if (!!pTypeData->AttachedTechnoEffect.Duration && !pData->AttachedTechnoEffect_isset){
- + pTypeData->AttachedTechnoEffect.Attach(Source, pTypeData->AttachedTechnoEffect.Duration);
- + pData->AttachedTechnoEffect_isset=true;
- + }
- +
- return 0;
- }
- @@ -135,6 +162,7 @@
- }
- }
- +
- /* using 0x6F9E7C instead makes this function override the original game one's entirely -
- don't activate that unless you handle _everything_ originally handled by the game */
- return 0;
- @@ -739,5 +767,18 @@
- TechnoExt->PoweredUnit = NULL;
- }
- + //#1573, #1623, #255 attached effects
- + if (TechnoExt->AttachedEffects.Count){
- + for (int i=TechnoExt->AttachedEffects.Count; i>0; --i) {
- + //Debug::Log("[AttachEffect] Removing %d. item from %s\n", i-1, pThis->GetTechnoType()->ID);
- + TechnoExt->AttachedEffects.GetItem(i-1)->Destroy();
- + delete TechnoExt->AttachedEffects.GetItem(i-1);
- + }
- + //Debug::Log("[AttachEffect] Deleting array of %s\n", pThis->GetTechnoType()->ID);
- + TechnoExt->AttachedEffects.Clear();
- + TechnoExt->AttachedTechnoEffect_isset = false;
- + TechnoExt::RecalculateStats(pThis);
- + }
- +
- return 0;
- }
- Index: Ext/TechnoType/Body.cpp
- ===================================================================
- --- Ext/TechnoType/Body.cpp (revision 1169)
- +++ Ext/TechnoType/Body.cpp (working copy)
- @@ -304,6 +304,9 @@
- }
- }
- + //#1623 - AttachEffect on unit-creation
- + this->AttachedTechnoEffect.Read(&exINI, section);
- +
- // quick fix - remove after the rest of weapon selector code is done
- return;
- }
- Index: Ext/TechnoType/Body.h
- ===================================================================
- --- Ext/TechnoType/Body.h (revision 1169)
- +++ Ext/TechnoType/Body.h (working copy)
- @@ -9,7 +9,9 @@
- #include "../_Container.hpp"
- #include "../../Utilities/Template.h"
- #include "../../Utilities/Constructs.h"
- +#include "../../Misc/AttachEffect.h"
- +
- #include <bitset>
- class TechnoTypeExt
- @@ -116,6 +118,9 @@
- // issue #617
- DynamicVectorClass<BuildingTypeClass*> PoweredBy; //!< The buildingtype this unit is powered by or NULL.
- + //issue #1623
- + AttachEffectTypeClass AttachedTechnoEffect; //The AttachedEffect which should been on the Techno from the start.
- +
- ExtData(const DWORD Canary, TT* const OwnerObject) : Extension<TT>(Canary, OwnerObject),
- Survivors_PilotChance (NULL),
- Survivors_PassengerChance (NULL),
- @@ -162,7 +167,8 @@
- WaterImage (NULL),
- CanBeReversed (true),
- RadarJamRadius (0),
- - PassengerTurret (false)
- + PassengerTurret (false),
- + AttachedTechnoEffect()
- {
- this->Insignia.SetAll(NULL);
- *this->CameoPCX = *this->AltCameoPCX = 0;
- Index: Ext/WarheadType/Body.cpp
- ===================================================================
- --- Ext/WarheadType/Body.cpp (revision 1169)
- +++ Ext/WarheadType/Body.cpp (working copy)
- @@ -93,6 +93,8 @@
- this->KillDriver = pINI->ReadBool(section, "KillDriver", this->KillDriver);
- this->Malicious.Read(&exINI, section, "Malicious");
- +
- + this->AttachedEffect.Read(&exINI, section);
- };
- void Container<WarheadTypeExt>::InvalidatePointer(void *ptr) {
- @@ -445,6 +447,47 @@
- return false;
- }
- +//AttachedEffects, request #1573, #255
- +//copy-pasted from AlexB's applyIC
- +//since CellSpread effect is needed due to MO's proposed cloak SW (which is the reason why I was bugged with this), it has it.
- +//Graion Dilach, ~2011-10-14... I forgot the exact date :S
- +
- +void WarheadTypeExt::ExtData::applyAttachedEffect(CoordStruct *coords, HouseClass* Owner) {
- + if (!!this->AttachedEffect.Duration){
- + CellStruct cellCoords = MapClass::Instance->GetCellAt(coords)->MapCoords;
- + // set of affected objects. every object can be here only once.
- + DynamicVectorClass<TechnoClass*> *items = Helpers::Alex::getCellSpreadItems(coords,
- + this->AttachedToObject->CellSpread, true);
- +
- +
- +
- + // affect each object
- + for(int i=0; i<items->Count; ++i) {
- + if(TechnoClass *curTechno = items->GetItem(i)) {
- + // don't attach to dead
- + if(curTechno->InLimbo || !curTechno->IsAlive || !curTechno->Health) {
- + continue;
- + }
- +
- +
- + if(WarheadTypeExt::canWarheadAffectTarget(curTechno, Owner, this->AttachedToObject)) {
- + if(abs(this->Verses[curTechno->GetTechnoType()->Armor].Verses) < 0.001) {
- + continue;
- + }
- + this->AttachedEffect.Attach(curTechno, this->AttachedEffect.Duration);
- +
- + }
- +
- +
- + }
- + }
- + items->Clear();
- + delete items;
- +
- + }
- +
- +}
- +
- // =============================
- // container hooks
- Index: Ext/WarheadType/Body.h
- ===================================================================
- --- Ext/WarheadType/Body.h (revision 1169)
- +++ Ext/WarheadType/Body.h (working copy)
- @@ -19,6 +19,8 @@
- #include <Conversions.h>
- +#include "../../Misc/AttachEffect.h"
- +
- #include "../_Container.hpp"
- #include "../../Utilities/Template.h"
- @@ -75,6 +77,8 @@
- Valueable<bool> Malicious;
- + AttachEffectTypeClass AttachedEffect;
- +
- ExtData(const DWORD Canary, TT* const OwnerObject) : Extension<TT>(Canary, OwnerObject),
- MindControl_Permanent (false),
- Ripple_Radius (0),
- @@ -88,7 +92,8 @@
- InfDeathAnim (NULL),
- PreImpactAnim (-1),
- KillDriver (false),
- - Malicious (true)
- + Malicious (true),
- + AttachedEffect()
- {
- for(int i = 0; i < 11; ++i) {
- VersesData vs;
- @@ -112,6 +117,8 @@
- void applyEMP(CoordStruct *, TechnoClass *);
- bool applyPermaMC(CoordStruct *, HouseClass *, ObjectClass *);
- + void applyAttachedEffect(CoordStruct *, HouseClass *);
- +
- bool applyKillDriver(BulletClass *); // #733
- };
- @@ -146,6 +153,14 @@
- static void applyOccupantDamage(BulletClass *);
- static bool canWarheadAffectTarget(TechnoClass *, HouseClass *, WarheadTypeClass *);
- +
- + //static void applyAttachedEffect(WarheadTypeClass * pWH, CoordStruct* coords, TechnoClass * Source) {
- + static void applyAttachedEffect(WarheadTypeClass * pWH, CoordStruct* coords, HouseClass* Owner) {
- + if(auto pWHExt = WarheadTypeExt::ExtMap.Find(pWH)) {
- + // pWHExt->applyAttachedEffect(coords, Source);
- + pWHExt->applyAttachedEffect(coords, Owner);
- + }
- + }
- };
- typedef hash_map<IonBlastClass *, WarheadTypeExt::ExtData *> hash_ionExt;
- Index: Ext/WarheadType/Hooks.cpp
- ===================================================================
- --- Ext/WarheadType/Hooks.cpp (revision 1169)
- +++ Ext/WarheadType/Hooks.cpp (working copy)
- @@ -56,6 +56,8 @@
- pWHExt->applyEMP(&coords, Bullet->Owner);
- WarheadTypeExt::applyOccupantDamage(Bullet);
- pWHExt->applyKillDriver(Bullet);
- + pWHExt->applyAttachedEffect(&coords, OwnerHouse);
- +
- }
- /*
- Index: Misc/AttachEffect.cpp
- ===================================================================
- --- Misc/AttachEffect.cpp (revision 0)
- +++ Misc/AttachEffect.cpp (revision 0)
- @@ -0,0 +1,70 @@
- +#include "AttachEffect.h"
- +#include "../Ext/Techno/Body.h"
- +#include "../Ext/TechnoType/Body.h"
- +#include "../Ext/WarheadType/Body.h"
- +
- +/*
- +Attached Effects system
- +covering feature requests
- +#1573, #1623 and #255
- +
- +Graion Dilach, 2011-09-24+
- +Proper documentation gets done if proper code there is.
- +
- +In a nutshell:
- + relatively flexible way to interact with the unit's properties (as many as possible)
- + to create as many as possible interesting effects
- +
- +Todo: something with that crash in cloak contra animation - crap, Documentation and crates
- +To-to-to-todo: Get a disassembler to update the hook (44A03C, BuildingClass_Mi_Selling_ReestablishMindControl, 6)
- +within Bugfixes.cpp to be set before TechnoClass::Remove, killing all effects on the way
- +*/
- +
- +void AttachEffectTypeClass::Attach(TechnoClass* Target, int Duration) {
- + if (!Target) {return;}
- +
- + TechnoExt::ExtData *TargetExt = TechnoExt::ExtMap.Find(Target);
- +
- +
- + if (!this->Cumulative && TargetExt->AttachedEffects.Count > 0) {
- + for (int i=0; i < TargetExt->AttachedEffects.Count; i++) {
- + if (this->ID == TargetExt->AttachedEffects.GetItem(i)->Type->ID){
- + TargetExt->AttachedEffects.GetItem(i)->ActualDuration = TargetExt->AttachedEffects.GetItem(i)->Type->Duration;
- + return;
- + }
- + }
- + }
- +
- + // there goes the actual attaching
- + auto Attaching = new AttachEffectClass(this, Duration);
- + TargetExt->AttachedEffects.AddItem(Attaching);
- +
- +
- + // animation
- + if (!!this->AnimType) {
- + GAME_ALLOC(AnimClass, Attaching->Animation, this->AnimType, &Target->Location);
- + Attaching->Animation->SetOwnerObject(Target);
- + // inbefore void pointers, hardcode the iteration to infinitely looped
- + Attaching->Animation->RemainingIterations=-1;
- +
- + }
- +
- + // update the unit with the attached effect
- + TechnoExt::RecalculateStats(Target);
- +}
- +
- +//remove the effects from the unit
- +void AttachEffectClass::Destroy(){
- + if (this->Animation){
- + this->Animation->OwnerObject = NULL;
- + this->Animation->Invisible = true;
- + this->Animation->RemainingIterations = 0;
- + //TimeToDie deletes the animation in the following frame... combining it with Remove() crashes, UnInit() crashes, GAME_DEALLOC crashes. Niiice.
- + //While the above does the same and being the most elegant resolve.
- + this->Animation->Audio1.ShutUp(); //Report
- + this->Animation->Audio2.ShutUp();
- + this->Animation->Audio3.ShutUp();
- + this->Animation->Audio4.ShutUp();
- + this->Animation = NULL;
- + }
- +}
- \ No newline at end of file
- Index: Misc/AttachEffect.h
- ===================================================================
- --- Misc/AttachEffect.h (revision 0)
- +++ Misc/AttachEffect.h (revision 0)
- @@ -0,0 +1,72 @@
- +#ifndef ATTACHEFFECT_H_
- +#define ATTACHEFFECT_H_
- +
- +#include <vector>
- +#include <TechnoClass.h>
- +
- +#include "../Utilities/Template.h"
- +
- +
- +class AttachEffectTypeClass {
- +public:
- +
- + const char* ID;
- + Valueable<int> Duration;
- + Valueable<bool> Cumulative;
- +
- + //#1573, #1623 animations on units
- + Valueable<AnimTypeClass *> AnimType;
- +
- + //#255, crate stat modifiers on weapons
- + Valueable<double> FirepowerMultiplier;
- + Valueable<double> ArmorMultiplier;
- + Valueable<double> SpeedMultiplier;
- + Valueable<bool> Cloakable;
- +
- +
- + virtual void Attach(TechnoClass* Target, int Duration);
- +
- + AttachEffectTypeClass(){
- + this->Cumulative = false;
- + this->Duration = 0;
- + this->AnimType = NULL;
- + this->FirepowerMultiplier = 1;
- + this->ArmorMultiplier = 1;
- + this->SpeedMultiplier = 1;
- + this->Cloakable = false;
- +
- +
- + };
- +
- + void Read(INI_EX *exINI, const char * section) {
- +
- + this->ID = section;
- + this->Duration.Read(exINI, section, "AttachEffect.Duration");
- + this->Cumulative.Read(exINI, section, "AttachEffect.Cumulative");
- + this->AnimType.Parse(exINI, section, "AttachEffect.Animation");
- + this->FirepowerMultiplier.Read(exINI, section, "AttachEffect.FirepowerMultiplier");
- + this->ArmorMultiplier.Read(exINI, section, "AttachEffect.ArmorMultiplier");
- + this->SpeedMultiplier.Read(exINI, section, "AttachEffect.SpeedMultiplier");
- + this->Cloakable.Read(exINI, section, "AttachEffect.Cloakable");
- +
- +
- + }
- +};
- +
- +class AttachEffectClass {
- +public:
- + AttachEffectClass(AttachEffectTypeClass* AEType, int Timer){
- + this->Type = AEType;
- + this->ActualDuration = Timer;
- + this->Animation = NULL;
- + }
- +
- + AttachEffectTypeClass * Type;
- + AnimClass * Animation;
- + int ActualDuration;
- +
- + void Destroy();
- +};
- +
- +
- +#endif
- \ No newline at end of file
- Index: Misc/Bugfixes.cpp
- ===================================================================
- --- Misc/Bugfixes.cpp (revision 1169)
- +++ Misc/Bugfixes.cpp (working copy)
- @@ -913,6 +913,7 @@
- TechnoExt::TransferMindControl(pUnit, pStructure);
- TechnoExt::TransferIvanBomb(pUnit, pStructure);
- + TechnoExt::TransferAttachedEffects(pUnit, pStructure);
- pStructure->QueueMission(mission_Construction, 0);
- @@ -933,6 +934,7 @@
- TechnoExt::TransferMindControl(pStructure, pUnit);
- TechnoExt::TransferIvanBomb(pStructure, pUnit);
- + TechnoExt::TransferAttachedEffects(pStructure, pUnit);
- return 0;
- }
- Property changes on: Misc\Bugfixes.cpp
- ___________________________________________________________________
- Modified: svn:mergeinfo
- Merged /trunk/src/Misc/Bugfixes.cpp:r1168-1169
- Index: Misc/SWTypes/GenericWarhead.cpp
- ===================================================================
- --- Misc/SWTypes/GenericWarhead.cpp (revision 1169)
- +++ Misc/SWTypes/GenericWarhead.cpp (working copy)
- @@ -38,6 +38,7 @@
- }
- pWHExt->applyEMP(&coords, Firer);
- + pWHExt->applyAttachedEffect(&coords, pThis->Owner);
- if(!pWHExt->applyPermaMC(&coords, pThis->Owner, Cell->GetContent())) {
- MapClass::DamageArea(&coords, pData->SW_Damage, Firer, pData->SW_Warhead, 1, pThis->Owner);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement