(December 30th, 2023, 07:31)Suppanut Wrote: Is is possible to detect XY and plane of fortress city? I think about implement corrupt based on distance from capital but I hit the wall here. I need to either able to detect geometric value (same one that using for cast combat spell) or just detect XYP of fortress city.
At bit extreme, but this would solve the issue. If you need to further optimize it, check only Current Ending Turn Wizard's cities. But only ensure, any changes to any cities affects only said Wizard in this case.
Use this at every overland turn to check and update when necessary.
CU = 0;
CMax = MAXCITY();
OTrigger = 0;
LOOP
{
CU = CU + 1;
: Checking City Overland Coordinates and Planes, if one city is found to have unupdated records, recheck entire map if necessary :
IF (GETCITYDATA(CU,CSOLCoordinates)=0) THEN
{
OTrigger = 1;
: Forced updating :
FOR P=1 TO 2;
FOR X=0 TO PLANESIZEX(P);
FOR Y=7 TO (PLANESIZEY(P)-7);
: City on tile found, update necessary records :
IF (CITYONTILE(P,X,Y)>0) THEN
{
CityID = CITYONTILE(P,X,Y);
: DEBUGLOG "X: " + STRS(X) + ", Y: " + STRS(Y) + ", Plane: " + STRS(P); :
: City with Null Records found, fill records :
IF (GETCITYDATA(CityID,CSOLCoordinates)=0) THEN
{
: Writes to a concatenated string :
Test$= "";
Test$= Test$+STRS(P+1)+STRS(P+10)+STRS(X+10);
Combine = VAL(Test$);
SETCITYDATA(CityID,CSOLCoordinates,VAL(Combine));
: DEBUGLOG "CSOLCoordinates: " + STRS(GETCITYDATA(CityID,CSOLCoordinates)); :
}
}
NEXT Y;
NEXT X;
NEXT P;
: Forced updating :
}
}ENDLP (CU = CMax) %OR (OTrigger=1);
To retrieve it try this.
: Function Call ReadCityVar to retrieve values :
Combine = GETCITYDATA(C,CSOLCoordinates);
CALL "ReadCityVar";
CSOLX = CityX;
CSOLY = CityY;
CSOLPlane = CityPlane;
Remember to set the helper function calls below.
------------------------------------------------------
Set at Master.CAS as a city global variable.
------------------------------------------------------
: City Variables :
CSOLCoordinates = 1; : 11010 Plane/Y Coord/X Coord :
------------------------------------------------------
Set below as header at the top of the file.
------------------------------------------------------
: Input/Output Variables for ReadCityVar :
Combine = 0;
CityX = 0;
CityY = 0;
------------------------------------------------------
------------------------------------------------------
Set below after a HALT, at the bottom of the file.
------------------------------------------------------
: ReadCityVar, Plane/Y/X 11010 :
!ReadCityVar!
CityX = 100*%F(Combine/100); : 11010 :
CityX = CityX - 10;
Combine = %I(Combine/100); : 110 :
CityY = 100*%F(Combine/100); : 110 :
CityY = CityY - 10;
CityPlane = %I(Combine/100); : 1 :
CityPlane = CityPlane - 1;
RETURN;
------------------------------------------------------