
King Karolus Servant
Posts: 2154
Joined: 29 Aug 2007, 22:00
KaM Skill Level: Veteran
Location: In his dark thunderstormy castle
Re: New Dynamic Script Ideas
Edit: Uknown identifyer 'Sqr'
King Karolus Servant
Posts: 2154
Joined: 29 Aug 2007, 22:00
KaM Skill Level: Veteran
Location: In his dark thunderstormy castle
Posts: 3822
Joined: 16 Sep 2007, 22:00
KaM Skill Level: Skilled
ICQ: 269127056
Website: http://lewin.hodgman.id.au
Yahoo Messenger: lewinlewinhodgman
Location: Australia
function ClosestUnit(aPlayer, X, Y: Integer): Integer;
var
Units: array of Integer;
i, BestDistanceSqr, ThisDistanceSqr, DX, DY: Integer;
begin
Result := -1;
Units := States.PlayerGetAllUnits(aPlayer);
for i:=0 to Length(Units)-1 do
begin
DX := X-States.UnitPositionX(Units[i]);
DY := Y-States.UnitPositionY(Units[i]);
//Using squares is more efficient than square roots and gives exactly the same result (Pythagoras)
ThisDistanceSqr := (DX*DX) + (DY*DY);
if (Result = -1) or (ThisDistanceSqr < BestDistanceSqr) then
begin
BestDistanceSqr := ThisDistanceSqr;
Result := Units[i];
end;
end;
end;
I desperately need AITownDefense and AIAgressiveness![]()
Posts: 3822
Joined: 16 Sep 2007, 22:00
KaM Skill Level: Skilled
ICQ: 269127056
Website: http://lewin.hodgman.id.au
Yahoo Messenger: lewinlewinhodgman
Location: Australia
New state:
GroupAtDefPos(PlayerID, X, Y)
New action:
AddDefPos(PlayerID, UnitType, X, Y, facing direction, defence radius, frontline: boolean)
And maybe a unique "GroupOrderAttack" action with the following parametres: GroupID (attacker), Target (1-closest building, 2-closest unit), From (1-center screen, 2-army), Combo: Boolean (true: repeating the attack until all possible targets are down, so they don't retreat). It would be nearly the same as we can set in the MapEd, but it would make it easier and would reduce the mistake factor imo (you can set whichever troops should attack, so you don't have to rely on those backline troops, would require "GroupAtDefPos" though).
Sleep(ticks)
Actions.HouseWareSubtract(id, ware type, amount) or HouseSetWareAmount(id, ware type, amount)
Return to “Ideas / Suggestions”
Users browsing this forum: No registered users and 1 guest
Powered by phpBB® Forum Software © phpBB Group Designed by ST Software |
![]() |