Very nice, I made random changes to RACE_IMMUNITY.2da, and the code passed all tests.
I've moved on and added another type of RACE parameters: RACETERRAIN. Unfortunately, the code doesn't work well with RACETERRAIN, and values different than what I was expecting are returned. For SPWI504.spl, I was looking for [ S ]mall creatures that live on the [ L ]and, but returned values like 4 [DWARF], 5 [HALFLING], 6 [GNOME], 139 [MEPHIT], 141 [IMP], some of which are marked as [ N ]=NotAvailable/Varies, [ I ]nner Plane, [ O ]uter Plane.
I've amended all instances of these:
PATCH_IF (~%race_info%~ STRING_EQUAL_CASE ~RACESIZE~ || ~%race_info%~ STRING_EQUAL_CASE ~RACEFLY~ || ~%race_info%~ STRING_EQUAL_CASE ~RACETERRAIN~) BEGIN
And added this to the code:
// This determines what the native terrain is for races (from RACE.IDS). Some spells and effects are patched according to this 2da table, so they affect creatures based on their native terrain.
// The following letters mean different native terrains: N[one], A[stral plane], F[orest], I[nner-planar], L[and], O[uter-planar] S[ubterranian], U[nderwater]
ACTION_DEFINE_ASSOCIATIVE_ARRAY ~raceterrain~ BEGIN
1 => N
2 => N
3 => N
4 => N
5 => N
6 => N
7 => N
101 => L
102 => L
103 => L
104 => S
105 => L
106 => N
107 => F
108 => L
109 => F
110 => L
111 => N
112 => N
113 => L
115 => N
116 => F
117 => F
118 => F
119 => S
120 => F
121 => O
122 => N
123 => S
124 => S
125 => N
126 => N
127 => S
128 => F
129 => L
130 => S
131 => U
133 => L
134 => N
135 => U
136 => L
137 => L
138 => S
139 => I
140 => S
141 => O
142 => L
143 => L
144 => N
145 => I
146 => N
147 => I
148 => L
149 => S
150 => N
151 => L
152 => A
153 => O
154 => F
155 => N
156 => N
157 => N
158 => O
159 => O
201 => N
202 => N
203 => N
204 => N
205 => N
206 => N
207 => N
208 => N
209 => N
210 => N
211 => N
212 => N
213 => N
214 => N
215 => N
255 => N
END
My RACE_IMMUNITY.2da
AND(2) **** **** **** **** **** **** **** **** **** ****
SPWI402.spl 1-50 **** OPCODE=146_EFFECT=5 RACESIZE L RESOURCE=PROPC206_RESISTTYPE=3 **** **** **** ****
SPWI402.spl 1-50 **** OPCODE=146_EFFECT=5 RACEFLY N RESOURCE=PROPC206_RESISTTYPE=3 **** **** **** ****
AND(4) **** **** **** **** **** **** **** **** **** ****
SPWI504.spl 1-5 **** OPCODE=146_EFFECT=5 RACESIZE S RESOURCE=PROPC206_RESISTTYPE=3 **** **** **** ****
SPWI504.spl 1-5 Y OPCODE=146_EFFECT=5 RACETERRAIN L RESOURCE=PROPC206_RESISTTYPE=3 **** **** **** ****
SPWI616.spl 1-50 **** OPCODE=146_EFFECT=5 RACEFLY Y RESOURCE=PROPC206_RESISTTYPE=3 **** **** **** ****
SPWI616.spl 1-50 **** OPCODE=146_EFFECT=5 RACEFLY Y RESOURCE=PROPC206_RESISTTYPE=3 **** **** **** ****
Since you're pretty much writing this for me, I might as well post everything I have in mind for this code:
I'd like it to be able to handle other inputs: RACEINTELLECT (tells how smart creatures are in a single character not numbers), RACEMAKE (tells what stuff they are made of), CLASSSIZE, CLASSFLY, CLASSTERRAIN, CLASSINTELLECT, and CLASSMAKE. The CLASSxxx files are the equivalent of RACExxx files; the game makes heavy use of differentiating creatures according to class, and there might be times when I'd like to differentiate those creatures. The only restriction: rows that contain RACExxx and CLASSxxx inside an AND() cannot match. We are either dealing with Races or Classes, they cannot mix. I haven't written any of the CLASS files yet, so feel free to give yourself some dummy class arrays (or duplicate the race arrays).
Also, I'd like the macro to be able to deal with actual .IDS files in the game like this:
SPWI402.spl 1-50 **** OPCODE=146_EFFECT=5 GENERAL 3_UNDEAD_6 RESOURCE=PROPC206_RESISTTYPE=3 **** **** **** ****
AND(2) **** **** **** **** **** **** **** **** **** ****
SPWI402.spl 1-50 **** OPCODE=146_EFFECT=5 RACE 6_KOBOLD_3 RESOURCE=PROPC206_RESISTTYPE=3 **** **** **** ****
SPWI402.spl 1-50 **** OPCODE=146_EFFECT=5 RACEFLY Y_3 RESOURCE=PROPC206_RESISTTYPE=3 **** **** **** ****
The first row would look into the actual GENERAL.IDS and return the entry values based on the next column: It would return values 3 [DEAD], 4 [UNDEAD], and 6 [FROZEN]. I mixed numbers and strings in the input column on purpose, ideally, the code would take both.
The third row (counting AND() as a row) would return the races 3 [HALF_ELF], 6 [GNOME], and 112 [KOBOLD]. the fourth would return all flying creatures plus 3 [HALF_ELF]. But since they are inside an AND(), and there exist no flying gnomes or kobolds, the array would only return 3 [HALF_ELF].
If there would be support for all the other IDS files (EA, GENDER, SPECIFIC, ALIGNMENT, etc.) that would be awesome. I will not write any more input types (ie EAMAKE, EAINTELLECT, EAFLY) for the other types of IDS files, only for races and classes. If you intend to include more than just races, I request that a variable be set to some INT value for each time the row loops, so I know we are dealing with races, classes, gendertypes, etc.
Many thanks for all your help,
-Galactygon