# HG changeset patch # User unc0rr # Date 1393581316 -14400 # Node ID 0570d4b2218771e26627b42fffc4435f9080608c # Parent b994afa403260d6ab8f9af0e7d798e17499d127f AI doesn't skip till action on the map stops (mostly dedicated to highlander) + various small tweaks diff -r b994afa40326 -r 0570d4b22187 hedgewars/uAI.pas --- a/hedgewars/uAI.pas Thu Feb 27 12:48:27 2014 +0400 +++ b/hedgewars/uAI.pas Fri Feb 28 13:55:16 2014 +0400 @@ -415,7 +415,7 @@ switchCount:= HHHasAmmo(PGear(Me)^.Hedgehog^, amSwitch) else switchCount:= 0; -if ((Me^.State and gstAttacked) = 0) or isInMultiShoot then +if ((Me^.State and gstAttacked) = 0) or isInMultiShoot or bonuses.activity then if Targets.Count > 0 then begin // iterate over current team hedgehogs @@ -452,19 +452,23 @@ or BestActions.isWalkingToABetterPlace; if (StartTicks > GameTicks - 1500) and (not StopThinking) then - SDL_Delay(1000); + SDL_Delay(700); if (BestActions.Score < -1023) and (not BestActions.isWalkingToABetterPlace) then begin BestActions.Count:= 0; - AddAction(BestActions, aia_Skip, 0, 250, 0, 0); + + FillBonuses(false); + + if not bonuses.activity then + AddAction(BestActions, aia_Skip, 0, 250, 0, 0); end; end else SDL_Delay(100) else begin BackMe:= Me^; - i:= 12; + i:= 4; while (not StopThinking) and (BestActions.Count = 0) and (i > 0) do begin @@ -480,7 +484,7 @@ Actions.Pos:= 0; Actions.Score:= 0; Walk(@WalkMe, Actions); - dec(i); + if not bonuses.activity then dec(i); if not StopThinking then SDL_Delay(100) end diff -r b994afa40326 -r 0570d4b22187 hedgewars/uAIMisc.pas --- a/hedgewars/uAIMisc.pas Thu Feb 27 12:48:27 2014 +0400 +++ b/hedgewars/uAIMisc.pas Fri Feb 28 13:55:16 2014 +0400 @@ -55,7 +55,8 @@ Score: LongInt; end; -Tbonuses = record +TBonuses = record + activity: boolean; Count : Longword; ar : array[0..Pred(MAXBONUS)] of TBonus; end; @@ -92,7 +93,7 @@ var ThinkingHH: PGear; Targets: TTargets; - bonuses: Tbonuses; + bonuses: TBonuses; walkbonuses: Twalkbonuses; @@ -209,36 +210,70 @@ i: Longint; begin bonuses.Count:= 0; +bonuses.activity:= false; MyClan:= ThinkingHH^.Hedgehog^.Team^.Clan; Gear:= GearsList; while Gear <> nil do begin case Gear^.Kind of + gtGrenade + , gtClusterBomb + , gtGasBomb + , gtShell + , gtAirAttack + , gtMortar + , gtWatermelon + , gtDrill + , gtAirBomb + , gtCluster + , gtMelonPiece + , gtMolotov: bonuses.activity:= true; gtCase: AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y) + 3, 37, 25); gtFlame: if (Gear^.State and gsttmpFlag) <> 0 then AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 20, -50); // avoid mines unless they are very likely to be duds, or are duds. also avoid if they are about to blow - gtMine: + gtMine: begin + if (Gear^.State and gstMoving) <> 0 then bonuses.activity:= true; + if ((Gear^.State and gstAttacking) = 0) and (((cMineDudPercent < 90) and (Gear^.Health <> 0)) or (isAfterAttack and (Gear^.Health = 0) and (Gear^.Damage > 30))) then AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -50) else if (Gear^.State and gstAttacking) <> 0 then AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 100, -50); // mine is on + end; gtExplosives: - if isAfterAttack then - AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 75, -60 + Gear^.Health); + begin + //if (Gear^.State and gstMoving) <> 0 then bonuses.activity:= true; - gtSMine: + if isAfterAttack then + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 75, -60 + Gear^.Health); + end; + + gtSMine: begin + if (Gear^.State and (gstMoving or gstAttacking)) <> 0 then bonuses.activity:= true; + AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 50, -30); + end; gtDynamite: + begin + bonuses.activity:= true; AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 150, -75); + end; gtHedgehog: begin + if (ThinkingHH <> Gear) + and (((Gear^.State and (gstMoving or gstDrowning or gstHHDeath)) <> 0) + or (Gear^.Health = 0) + or (Gear^.Damage >= Gear^.Health)) + then begin + bonuses.activity:= true; + end; + if Gear^.Damage >= Gear^.Health then AddBonus(hwRound(Gear^.X), hwRound(Gear^.Y), 60, -25) else @@ -253,6 +288,7 @@ end; Gear:= Gear^.NextGear end; + if isAfterAttack and (KnownExplosion.Radius > 0) then with KnownExplosion do AddBonus(X, Y, Radius + 10, -Radius); diff -r b994afa40326 -r 0570d4b22187 hedgewars/uGearsHandlersMess.pas --- a/hedgewars/uGearsHandlersMess.pas Thu Feb 27 12:48:27 2014 +0400 +++ b/hedgewars/uGearsHandlersMess.pas Fri Feb 28 13:55:16 2014 +0400 @@ -1740,11 +1740,13 @@ PlaySound(sndRopeAttach); Gear^.dX:= _0; Gear^.dY:= _0; + Gear^.State:= Gear^.State and (not gstMoving); AddCI(Gear); end; end else begin + Gear^.State:= Gear^.State or gstMoving; DeleteCI(Gear); doStepFallingGear(Gear); AllInactive := false;