83 begin |
83 begin |
84 Targets.Count:= 0; |
84 Targets.Count:= 0; |
85 f:= 0; |
85 f:= 0; |
86 e:= 0; |
86 e:= 0; |
87 for t:= 0 to Pred(TeamsCount) do |
87 for t:= 0 to Pred(TeamsCount) do |
88 with TeamsArray[t]^ do |
88 with TeamsArray[t]^ do |
89 if not hasGone then |
89 if not hasGone then |
90 begin |
90 begin |
91 for i:= 0 to cMaxHHIndex do |
91 for i:= 0 to cMaxHHIndex do |
92 if (Hedgehogs[i].Gear <> nil) |
92 if (Hedgehogs[i].Gear <> nil) |
93 and (Hedgehogs[i].Gear <> ThinkingHH) then |
93 and (Hedgehogs[i].Gear <> ThinkingHH) then |
94 begin |
94 begin |
95 with Targets.ar[Targets.Count], Hedgehogs[i] do |
95 with Targets.ar[Targets.Count], Hedgehogs[i] do |
96 begin |
96 begin |
97 Point.X:= hwRound(Gear^.X); |
97 Point.X:= hwRound(Gear^.X); |
98 Point.Y:= hwRound(Gear^.Y); |
98 Point.Y:= hwRound(Gear^.Y); |
99 if Clan <> CurrentTeam^.Clan then |
99 if Clan <> CurrentTeam^.Clan then |
100 begin |
100 begin |
101 Score:= Gear^.Health; |
101 Score:= Gear^.Health; |
102 inc(e) |
102 inc(e) |
103 end else |
103 end else |
104 begin |
104 begin |
105 Score:= -Gear^.Health; |
105 Score:= -Gear^.Health; |
106 inc(f) |
106 inc(f) |
107 end |
107 end |
108 end; |
108 end; |
109 inc(Targets.Count) |
109 inc(Targets.Count) |
110 end; |
110 end; |
111 end; |
111 end; |
112 |
112 |
113 if e > f then friendlyfactor:= 300 + (e - f) * 30 |
113 if e > f then friendlyfactor:= 300 + (e - f) * 30 |
114 else friendlyfactor:= max(30, 300 - f * 80 div e) |
114 else friendlyfactor:= max(30, 300 - f * 80 div e) |
115 end; |
115 end; |
116 |
116 |
131 begin |
131 begin |
132 bonuses.Count:= 0; |
132 bonuses.Count:= 0; |
133 MyClan:= PHedgehog(ThinkingHH^.Hedgehog)^.Team^.Clan; |
133 MyClan:= PHedgehog(ThinkingHH^.Hedgehog)^.Team^.Clan; |
134 Gear:= GearsList; |
134 Gear:= GearsList; |
135 while Gear <> nil do |
135 while Gear <> nil do |
136 begin |
136 begin |
137 case Gear^.Kind of |
137 case Gear^.Kind of |
138 gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25); |
138 gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 33, 25); |
139 gtMine: if (Gear^.State and gstAttacking) = 0 then |
139 gtMine: if (Gear^.State and gstAttacking) = 0 then |
140 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50) |
140 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50) |
141 else |
141 else |
142 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on |
142 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on |
143 gtDynamite: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75); |
143 gtDynamite: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75); |
144 gtHedgehog: begin |
144 gtHedgehog: begin |
145 if Gear^.Damage >= Gear^.Health then |
145 if Gear^.Damage >= Gear^.Health then |
146 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25) |
146 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25) |
147 else |
147 else |
148 if isAfterAttack and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog) then |
148 if isAfterAttack and (ThinkingHH^.Hedgehog <> Gear^.Hedgehog) then |
149 if (MyClan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan) then |
149 if (MyClan = PHedgehog(Gear^.Hedgehog)^.Team^.Clan) then |
150 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -3) // hedgehog-friend |
150 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -3) // hedgehog-friend |
151 else |
151 else |
152 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3) |
152 AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, 3) |
153 end; |
153 end; |
154 end; |
154 end; |
155 Gear:= Gear^.NextGear |
155 Gear:= Gear^.NextGear |
156 end; |
156 end; |
157 if isAfterAttack and (KnownExplosion.Radius > 0) then |
157 if isAfterAttack and (KnownExplosion.Radius > 0) then |
158 with KnownExplosion do |
158 with KnownExplosion do |
159 AddBonus(X, Y, Radius + 10, -Radius); |
159 AddBonus(X, Y, Radius + 10, -Radius); |
160 end; |
160 end; |
161 |
161 |
170 var i, r: LongInt; |
170 var i, r: LongInt; |
171 rate: LongInt; |
171 rate: LongInt; |
172 begin |
172 begin |
173 rate:= 0; |
173 rate:= 0; |
174 for i:= 0 to Pred(bonuses.Count) do |
174 for i:= 0 to Pred(bonuses.Count) do |
175 with bonuses.ar[i] do |
175 with bonuses.ar[i] do |
176 begin |
176 begin |
177 r:= hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
177 r:= hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y))); |
178 if r < Radius then |
178 if r < Radius then |
179 inc(rate, Score * (Radius - r)) |
179 inc(rate, Score * (Radius - r)) |
180 end; |
180 end; |
181 RatePlace:= rate; |
181 RatePlace:= rate; |
182 end; |
182 end; |
183 |
183 |
184 // Wrapper to test various approaches. If it works reasonably, will just replace. |
184 // Wrapper to test various approaches. If it works reasonably, will just replace. |
185 // Right now, converting to hwFloat is a tad inefficient since the x/y were hwFloat to begin with... |
185 // Right now, converting to hwFloat is a tad inefficient since the x/y were hwFloat to begin with... |
186 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; |
186 function TestCollExcludingMe(Me: PGear; x, y, r: LongInt): boolean; |
465 else AIrndSign:= - num |
465 else AIrndSign:= - num |
466 end; |
466 end; |
467 |
467 |
468 procedure init_uAIMisc; |
468 procedure init_uAIMisc; |
469 begin |
469 begin |
470 friendlyfactor:= 300; |
470 friendlyfactor:= 300; |
471 KnownExplosion.X:= 0; |
471 KnownExplosion.X:= 0; |
472 KnownExplosion.Y:= 0; |
472 KnownExplosion.Y:= 0; |
473 KnownExplosion.Radius:= 0; |
473 KnownExplosion.Radius:= 0; |
474 end; |
474 end; |
475 |
475 |
476 procedure free_uAIMisc; |
476 procedure free_uAIMisc; |
477 begin |
477 begin |
478 |
478 |