SetupWishCore: fixed table lookup being out of bounds for the wisest pcs
[gemrb.git] / gemrb / core / Effect.h
blob718cb565793509c209d6924c728a5c9e2437c412
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2003 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 /**
22 * @file Effect.h
23 * Declares Effect class implementing spell and spell-like effects
24 * and related defines
27 #ifndef EFFECT_H
28 #define EFFECT_H
30 #include "ie_types.h"
32 #include "Region.h"
34 class Actor;
36 //local variables in creatures are stored in fake opcodes
37 #define FAKE_VARIABLE_OPCODE 187
38 #define FAKE_VARIABLE_MARKER 1
40 // Effect target types
41 #define FX_TARGET_UNKNOWN 0
42 #define FX_TARGET_SELF 1
43 #define FX_TARGET_PRESET 2
44 #define FX_TARGET_PARTY 3
45 #define FX_TARGET_ALL 4
46 #define FX_TARGET_ALL_BUT_PARTY 5
47 #define FX_TARGET_OWN_SIDE 6
48 #define FX_TARGET_OTHER_SIDE 7
49 #define FX_TARGET_ALL_BUT_SELF 8
50 #define FX_TARGET_ORIGINAL 9
52 // Effect duration/timing types
53 #define FX_DURATION_INSTANT_LIMITED 0
54 #define FX_DURATION_INSTANT_PERMANENT 1
55 #define FX_DURATION_INSTANT_WHILE_EQUIPPED 2
56 #define FX_DURATION_DELAY_LIMITED 3 //this contains a relative onset time (delay) also used as duration, transforms to 6 when applied
57 #define FX_DURATION_DELAY_PERMANENT 4 //this transforms to 9 (i guess)
58 #define FX_DURATION_DELAY_UNSAVED 5 //this transforms to 8
59 #define FX_DURATION_DELAY_LIMITED_PENDING 6 //this contains an absolute onset time and a duration
60 #define FX_DURATION_AFTER_EXPIRES 7 //this is a delayed non permanent effect (resolves to JUST_EXPIRED)
61 #define FX_DURATION_PERMANENT_UNSAVED 8
62 #define FX_DURATION_INSTANT_PERMANENT_AFTER_BONUSES 9//this is a special permanent
63 #define FX_DURATION_JUST_EXPIRED 10
64 #define MAX_TIMING_MODE 11
65 #define FX_DURATION_ABSOLUTE 0x1000
67 // Effect resistance types
68 #define FX_NO_RESIST_NO_DISPEL 0
69 #define FX_CAN_RESIST_CAN_DISPEL 1
70 //#define FX_CAN_RESIST_NO_DISPEL 2 //same as 0 (not resistable, not dispellable)
71 #define FX_NO_RESIST_CAN_DISPEL 3
72 #define FX_CAN_DISPEL 1
73 #define FX_CAN_RESIST 3
75 /**
76 * @class Effect
77 * Structure holding information about single spell or spell-like effect.
80 // the same as ITMFeature and SPLFeature
81 struct Effect {
82 ieDword Opcode;
83 ieDword Target;
84 ieDword Power;
85 ieDword Parameter1;
86 ieDword Parameter2;
87 ieWord TimingMode; //0x1000 -- no need of conversion
88 ieWord unknown2;
89 ieDword Resistance;
90 ieDword Duration;
91 ieWord Probability1;
92 ieWord Probability2;
93 //keep these four in one bunch, VariableName will
94 //spread across them
95 ieResRef Resource;
96 ieResRef Resource2; //vvc in a lot of effects
97 ieResRef Resource3;
98 ieResRef Resource4;
99 ieDword DiceThrown;
100 ieDword DiceSides;
101 ieDword SavingThrowType;
102 ieDword SavingThrowBonus;
103 ieWord IsVariable;
104 ieWord IsSaveForHalfDamage;
106 // EFF V2.0 fields:
107 ieDword PrimaryType; //school
108 ieDword Parameter3;
109 ieDword Parameter4;
110 ieDword PosX, PosY;
111 ieDword SourceType; //1-item, 2-spell
112 ieResRef Source;
113 ieDword SourceFlags;
114 ieDword Projectile; //9c
115 ieDwordSigned InventorySlot; //a0
116 //Original engine had a VariableName here, but it is stored in the resource fields
117 ieDword CasterLevel; //c4 in both
118 ieDword FirstApply; //c8 in bg2, cc in iwd2
119 ieDword SecondaryType;
120 ieDword SecondaryDelay; //still not sure about this
121 ieDword CasterID; //10c in bg2 (not saved?)
122 // These are not in the IE files, but are our precomputed values
123 ieDword random_value;
124 public:
125 //don't modify position in case it was already set
126 void SetPosition(const Point &p) {
127 if(PosX==0xffffffff && PosY==0xffffffff) {
128 PosX=p.x;
129 PosY=p.y;
134 // FIXME: what about area spells? They can have map & coordinates as target
135 //void AddEffect(Effect* fx, Actor* self, Actor* pretarget);
137 #endif // ! EFFECT_H