98 |
98 |
99 |
99 |
100 procedure TestAmmos(var Actions: TActions; Me: PGear; rareChecks: boolean); |
100 procedure TestAmmos(var Actions: TActions; Me: PGear; rareChecks: boolean); |
101 var BotLevel: Byte; |
101 var BotLevel: Byte; |
102 ap: TAttackParams; |
102 ap: TAttackParams; |
103 Score, i, t, n, dAngle: LongInt; |
103 Score, i, l, t, n, dAngle: LongInt; |
104 a, aa: TAmmoType; |
104 a, aa: TAmmoType; |
105 useThisActions: boolean; |
105 useThisActions, hasLowGrav: boolean; |
106 begin |
106 begin |
107 BotLevel:= Me^.Hedgehog^.BotLevel; |
107 BotLevel:= Me^.Hedgehog^.BotLevel; |
108 aiWindSpeed:= hwFloat2Float(cWindSpeed); |
108 aiWindSpeed:= hwFloat2Float(cWindSpeed); |
109 aiGravity:= cGravity; |
|
110 aiGravityf:= cGravityf; |
|
111 aiLaserSighting:= (cLaserSighting) or (HHHasAmmo(Me^.Hedgehog^, amLaserSight) > 0); |
109 aiLaserSighting:= (cLaserSighting) or (HHHasAmmo(Me^.Hedgehog^, amLaserSight) > 0); |
|
110 hasLowGrav:= HHHasAmmo(Me^.Hedgehog^, amLowGravity) > 0; |
112 useThisActions:= false; |
111 useThisActions:= false; |
113 Me^.AIHints:= Me^.AIHints and (not aihAmmosChanged); |
112 Me^.AIHints:= Me^.AIHints and (not aihAmmosChanged); |
114 |
113 |
|
114 for l:= 0 to 1 do // 0 = test with normal gravity. 1 = test with low gravity |
|
115 if (l = 0) or ((hasLowGrav) and (not cLowGravity)) then |
|
116 begin |
|
117 // simulate normal or low gravity |
|
118 if (l = 0) then |
|
119 begin |
|
120 aiGravity:= cGravity; |
|
121 aiGravityf:= cGravityf; |
|
122 end |
|
123 else if (l = 1) then |
|
124 begin |
|
125 // We calculate the values to better support scripts like Gravity. |
|
126 // This might have a slight inaccuracy, but none have been spotted in testing. |
|
127 aiGravity:= cGravity / _2; |
|
128 aiGravityf:= cGravityf / 2; |
|
129 end; |
115 for i:= 0 to Pred(Targets.Count) do |
130 for i:= 0 to Pred(Targets.Count) do |
116 if (Targets.ar[i].Score >= 0) and (not StopThinking) then |
131 if (Targets.ar[i].Score >= 0) and (not StopThinking) then |
117 begin |
132 begin |
118 with Me^.Hedgehog^ do |
133 with Me^.Hedgehog^ do |
119 a:= CurAmmoType; |
134 a:= CurAmmoType; |
121 SDL_delay(0); // hint to let the context switch run |
136 SDL_delay(0); // hint to let the context switch run |
122 repeat |
137 repeat |
123 if (CanUseAmmo[a]) |
138 if (CanUseAmmo[a]) |
124 and ((not rareChecks) or ((AmmoTests[a].flags and amtest_Rare) = 0)) |
139 and ((not rareChecks) or ((AmmoTests[a].flags and amtest_Rare) = 0)) |
125 and ((i = 0) or ((AmmoTests[a].flags and amtest_NoTarget) = 0)) |
140 and ((i = 0) or ((AmmoTests[a].flags and amtest_NoTarget) = 0)) |
|
141 and ((l = 0) or ((AmmoTests[a].flags and amtest_NoLowGravity) = 0)) |
126 then |
142 then |
127 begin |
143 begin |
128 {$HINTS OFF} |
144 {$HINTS OFF} |
129 Score:= AmmoTests[a].proc(Me, Targets.ar[i], BotLevel, ap, AmmoTests[a].flags); |
145 Score:= AmmoTests[a].proc(Me, Targets.ar[i], BotLevel, ap, AmmoTests[a].flags); |
130 {$HINTS ON} |
146 {$HINTS ON} |
155 end; |
171 end; |
156 if ((AmmoTests[a].flags and amtest_NoInvulnerable) = 0) and |
172 if ((AmmoTests[a].flags and amtest_NoInvulnerable) = 0) and |
157 (HHHasAmmo(Me^.Hedgehog^, amInvulnerable) > 0) and (Me^.Hedgehog^.Effects[heInvulnerable] = 0) then |
173 (HHHasAmmo(Me^.Hedgehog^, amInvulnerable) > 0) and (Me^.Hedgehog^.Effects[heInvulnerable] = 0) then |
158 begin |
174 begin |
159 AddAction(BestActions, aia_Weapon, Longword(amInvulnerable), 80, 0, 0); |
175 AddAction(BestActions, aia_Weapon, Longword(amInvulnerable), 80, 0, 0); |
|
176 AddAction(BestActions, aia_attack, aim_push, 10, 0, 0); |
|
177 AddAction(BestActions, aia_attack, aim_release, 10, 0, 0); |
|
178 end; |
|
179 if (l = 1) and (hasLowGrav) then |
|
180 begin |
|
181 AddAction(BestActions, aia_Weapon, Longword(amLowGravity), 80, 0, 0); |
160 AddAction(BestActions, aia_attack, aim_push, 10, 0, 0); |
182 AddAction(BestActions, aia_attack, aim_push, 10, 0, 0); |
161 AddAction(BestActions, aia_attack, aim_release, 10, 0, 0); |
183 AddAction(BestActions, aia_attack, aim_release, 10, 0, 0); |
162 end; |
184 end; |
163 if (HHHasAmmo(Me^.Hedgehog^, amExtraDamage) > 0) and (cDamageModifier <> _1_5) then |
185 if (HHHasAmmo(Me^.Hedgehog^, amExtraDamage) > 0) and (cDamageModifier <> _1_5) then |
164 begin |
186 begin |