Post 19 Dec 2014, 21:47 by Esthlos
Seeing how the latter is probably impossible
Which is sad...
That would be a pity, I think it looks really bad when units or buildings just appear out of nowhere...
First option is right, they're spawned when player 4 and 5 is defeated, because if player have them from start, they're almost all killed by enemy. I know it looks a bit odd, but this is now the only option how to save them all.
This makes serfs and laborers immortal until players 4 and 5 are defeated:
- Code:
var aCivQueue: array of Record aType, aOwner, aX, aY, aHunger, aDir: Integer; end;
procedure OnUnitWounded(aUnitID: Integer; AttackerID: Integer);
begin
if ( (States.PlayerDefeated(3) = False) OR (States.PlayerDefeated(4) = False) ) AND (States.UnitOwner(aUnitID) = 0) AND ( (States.UnitType(aUnitID) = 0) OR (States.UnitType(aUnitID) = 9) ) then begin
SetLength(aCivQueue, Length(aCivQueue)+1);
aCivQueue[Length(aCivQueue)-1].aType := States.UnitType(aUnitID);
aCivQueue[Length(aCivQueue)-1].aOwner := States.UnitOwner(aUnitID);
aCivQueue[Length(aCivQueue)-1].aX := States.UnitPositionX(aUnitID);
aCivQueue[Length(aCivQueue)-1].aY := States.UnitPositionY(aUnitID);
aCivQueue[Length(aCivQueue)-1].aHunger := States.UnitHunger(aUnitID);
aCivQueue[Length(aCivQueue)-1].aDir := States.UnitDirection(aUnitID);
Actions.UnitKill(aUnitID, True);
end;
end;
procedure OnUnitAfterDied(aType: Integer; aOwner: Integer; aX: Integer; aY: Integer);
var i: Integer;
var i2: Integer;
var iCount: Integer;
begin
if Length(aCivQueue) > 0 then begin
iCount := 0;
for i := 0 to Length(aCivQueue)-1 do if (aType = aCivQueue[i-iCount].aType) AND (aOwner = aCivQueue[i-iCount].aOwner) AND (aX = aCivQueue[i-iCount].aX) AND (aY = aCivQueue[i-iCount].aY) then begin
Actions.UnitHungerSet(Actions.GiveUnit(aCivQueue[i-iCount].aOwner, aCivQueue[i-iCount].aType, aCivQueue[i-iCount].aX, aCivQueue[i-iCount].aY, aCivQueue[i-iCount].aDir), aCivQueue[i-iCount].aHunger);
for i2 := i-iCount to Length(aCivQueue)-2 do aCivQueue[i2] := aCivQueue[i2+1];
iCount := iCount+1;
end;
if iCount > 0 then SetLength(aCivQueue, Length(aCivQueue)-iCount);
end;
end;
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"