~ares-developers/ares/gd03

« back to all changes in this revision

Viewing changes to Ext/Infantry/Hooks.cpp

  • Committer: Renegade
  • Date: 2010-05-29 08:12:17 UTC
  • Revision ID: git-v1:0a1bb6321f04d723afe64d1b843dc87b4da783ec
Creating /trunk/src.

git-svn-id: svn://svn.renegadeprojects.com/ares/trunk@622 859b54a9-7a54-0410-aeb3-f8d2f1fa40fd

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <InfantryClass.h>
2
 
#include <BuildingClass.h>
3
 
#include <SpecificStructures.h>
4
 
#include "../Building/Body.h"
5
 
#include "../BuildingType/Body.h"
6
 
#include "../Techno/Body.h"
7
 
#include "Body.h"
8
 
#include "../Rules/Body.h"
9
 
#include <Misc/Actions.h>
10
 
 
11
 
// #664: Advanced Rubble - reconstruction part: Check
12
 
/*
13
 
A_FINE_HOOK(51E635, InfantryClass_GetCursorOverObject_EngineerOverFriendlyBuilding, 5)
14
 
{
15
 
        GET(BuildingClass *, Target, ESI);
16
 
        GET(InfantryClass *, pThis, EDI);
17
 
        FPUControl fp(R->get_EAX()); // (Target->GetHealthPercentage() == RulesClass::Instance->ConditionIdeal)
18
 
        switch(control) {
19
 
                case Rebuild:
20
 
                        // fall through - not decided about UI handling yet
21
 
                case DecideNormally:
22
 
                default:
23
 
                return fp.isEqual()
24
 
                 ? 0x51E63A
25
 
                 : 0x51E659
26
 
                ;
27
 
        }
28
 
}
29
 
*/
30
 
 
31
 
// #664: Advanced Rubble - reconstruction part: Reconstruction
32
 
DEFINE_HOOK(519FAF, InfantryClass_UpdatePosition_EngineerRepairsFriendly, 6)
33
 
{
34
 
        GET(InfantryClass *, pThis, ESI);
35
 
        GET(BuildingClass *, Target, EDI);
36
 
 
37
 
        BuildingExt::ExtData* TargetExtData = BuildingExt::ExtMap.Find(Target);
38
 
        BuildingTypeExt::ExtData* TargetTypeExtData = BuildingTypeExt::ExtMap.Find(Target->Type);
39
 
        bool do_normal_repair = true;
40
 
 
41
 
        if(TargetTypeExtData->RubbleIntact) {
42
 
                do_normal_repair = false;
43
 
                bool wasSelected = pThis->IsSelected;
44
 
                pThis->Remove();
45
 
                TargetExtData->RubbleYell(true);
46
 
                CellStruct Cell;
47
 
                pThis->GetMapCoords(&Cell);
48
 
                Target->KickOutUnit(pThis, &Cell);
49
 
                if(wasSelected) {
50
 
                        pThis->Select();
51
 
                }
52
 
        }
53
 
 
54
 
        return do_normal_repair ? 0 : 0x51A65D; //0x51A010 eats the Engineer, 0x51A65D hopefully does not
55
 
}
56
 
 
57
 
DEFINE_HOOK(51DF38, InfantryClass_Remove, A)
58
 
{
59
 
        GET(InfantryClass *, pThis, ESI);
60
 
        TechnoExt::ExtData* pData = TechnoExt::ExtMap.Find(pThis);
61
 
 
62
 
        if(BuildingClass *Garrison = pData->GarrisonedIn) {
63
 
                signed int idx = Garrison->Occupants.FindItemIndex(&pThis);
64
 
                if(idx == -1) {
65
 
                        Debug::Log("Infantry %s was garrisoned in building %s, but building didn't find it. WTF?", pThis->Type->ID, Garrison->Type->ID);
66
 
                } else {
67
 
                        Garrison->Occupants.RemoveItem(idx);
68
 
                }
69
 
        }
70
 
 
71
 
        pData->GarrisonedIn = NULL;
72
 
 
73
 
        return 0;
74
 
}
75
 
 
76
 
DEFINE_HOOK(51DFFD, InfantryClass_Put, 5)
77
 
{
78
 
        GET(InfantryClass *, pThis, EDI);
79
 
        TechnoExt::ExtData* pData = TechnoExt::ExtMap.Find(pThis);
80
 
        pData->GarrisonedIn = NULL;
81
 
 
82
 
        return 0;
83
 
}
84
 
 
85
 
DEFINE_HOOK(518434, InfantryClass_ReceiveDamage_SkipDeathAnim, 7)
86
 
{
87
 
        GET(InfantryClass *, pThis, ESI);
88
 
        GET_STACK(ObjectClass *, pAttacker, 0xE0);
89
 
//      InfantryExt::ExtData* trooperAres = InfantryExt::ExtMap.Find(pThis);
90
 
//      bool skipInfDeathAnim = false; // leaving this default in case this is expanded in the future
91
 
 
92
 
        // there is not InfantryExt ExtMap yet!
93
 
        // too much space would get wasted since there is only four bytes worth of data we need to store per object
94
 
        // so those four bytes get stashed in Techno Map instead. they will get their own map if there's ever enough data to warrant it
95
 
        TechnoExt::ExtData* pData = TechnoExt::ExtMap.Find(pThis);
96
 
 
97
 
        return pData->GarrisonedIn ? 0x5185F1 : 0;
98
 
}
99
 
 
100
 
// should correct issue #743
101
 
DEFINE_HOOK(51D799, InfantryClass_PlayAnim_WaterSound, 7)
102
 
{
103
 
        GET(InfantryClass *, I, ESI);
104
 
        return (I->Transporter || I->Type->MovementZone != mz_AmphibiousDestroyer)
105
 
                ? 0x51D8BF
106
 
                : 0x51D7A6
107
 
        ;
108
 
}
109
 
 
110
 
DEFINE_HOOK(51E5BB, InfantryClass_GetCursorOverObject_MultiEngineerA, 7) {
111
 
        // skip old logic's way to determine the cursor
112
 
        return 0x51E5D9;
113
 
}
114
 
 
115
 
DEFINE_HOOK(51E5E1, InfantryClass_GetCursorOverObject_MultiEngineerB, 7) {
116
 
        GET(BuildingClass *, pBld, ECX);
117
 
        eAction ret = InfantryExt::GetEngineerEnterEnemyBuildingAction(pBld);
118
 
 
119
 
        // use a dedicated cursor
120
 
        if(ret == act_Damage) {
121
 
                Actions::Set(RulesExt::Global()->EngineerDamageCursor);
122
 
        }
123
 
 
124
 
        //// return our action
125
 
        R->EAX(ret);
126
 
        return 0;
127
 
}
128
 
 
129
 
DEFINE_HOOK(519DB6, InfantryClass_UpdatePosition_MultiEngineer, 7) {
130
 
        GET(InfantryClass *, pEngi, ESI);
131
 
        GET(BuildingClass *, pBld, EDI);
132
 
 
133
 
        // damage or capture
134
 
        eAction action = InfantryExt::GetEngineerEnterEnemyBuildingAction(pBld);
135
 
        if(action == act_Damage) {
136
 
                int Damage = ceil(pBld->Type->Strength * RulesExt::Global()->EngineerDamage);
137
 
                pBld->ReceiveDamage(&Damage, 0, RulesClass::Global()->C4Warhead, pEngi, 1, 0, 0);
138
 
                return 0x51A010;
139
 
        } else {
140
 
                return 0x519EAA;
141
 
        }
142
 
}
 
 
b'\\ No newline at end of file'