
King Karolus Servant
Posts: 2154
Joined: 29 Aug 2007, 22:00
KaM Skill Level: Veteran
Location: In his dark thunderstormy castle
Help!

I'm working on the script of TNL 7, and in that mission the player has to break through a barricade which consists of a large number of units. I'm looking for a way to script this objective and I found one, except that it's not working.
What my script should do is: search in a radius of 14 tiles around location (74, 67) for enemy units --> if there are none and both AI players have less soldiers than 5, you win.
What my script does: no idea, but you win as soon as both players have less than 5 soldiers. The other condition never turns true although it should turn true right at the start?
Here is the script itself:
- Code:
Units := States.PlayerGetAllUnits(0); UnitsEnemy := States.PlayerGetAllUnits(1); UnitsEnemy2 := States.PlayerGetAllUnits(2); for i := 0 to Length(Units) -1 do begin if (((States.UnitPositionX(Units[i]) > (PointOfDefenceX - 14)) and (States.UnitPositionX(Units[i]) < (PointOfDefenceX + 14))) and ((States.UnitPositionY(Units[i]) > (PointOfDefenceY - 14)) and (States.UnitPositionY(Units[i]) < (PointOfDefenceY - 14)))) then begin AttackIntruders := True; end; end; begin for j := 0 to Length(UnitsEnemy) -1 do if (((States.UnitPositionX(UnitsEnemy[j]) > (PointOfDefenceX - 14)) and (States.UnitPositionX(UnitsEnemy[j]) < (PointOfDefenceX + 14))) and ((States.UnitPositionY(UnitsEnemy[j]) > (PointOfDefenceY - 14)) and (States.UnitPositionY(UnitsEnemy[j]) < (PointOfDefenceY - 14)))) then BarricadeIntact := True else BarricadeIntact := False; end; begin for k := 0 to Length(UnitsEnemy2) -1 do if (((States.UnitPositionX(UnitsEnemy2[k]) > (PointOfDefenceX - 14)) and (States.UnitPositionX(UnitsEnemy2[k]) < (PointOfDefenceX + 14))) and ((States.UnitPositionY(UnitsEnemy2[k]) > (PointOfDefenceY - 14)) and (States.UnitPositionY(UnitsEnemy2[k]) < (PointOfDefenceY - 14)))) then Barricade2Intact := True else Barricade2Intact := False; end; if (BarricadeIntact = false) and (States.StatArmyCount(1) < 5) and (Barricade2Intact = false) and (States.StatArmyCount(2) < 5) then begin Actions.PlayerWin([0], False); end;
So I guess there is a problem with the condition since BarricadeIntact and Barricade2Intact never turn true. But what?

Edit: wait a second... If I set BarricadeIntact/Barricade2Intact as true on OnMissionStart, the same thing happens... So that must mean they are always false, no matter what? Or they are just being ignored in the last part of the script (if lala PlayerWin)?

