As a French person I feel like it's my duty to explain strikes to you. - AdrienIer

Create an account  

 
Modding Discussion Thread

I want to give Hero [25] ("Unknown") 4 random spells (combat-castable) when they join the Wizard's army; is that possible?
Reply

(December 15th, 2023, 10:57)Settemio Wrote: I want to give Hero [25] ("Unknown") 4 random spells (combat-castable) when they join the Wizard's army; is that possible?

Four spells but no more can be written into a hero's spellbook in herodata.ini. For a random selection you would probably have to have this in a .CAS file. So I think it is not doable. With the latest patch you can give a unit, including a special hero, a random spell ability. For heroes this would have the small flaw that this could be overwritten by an item spell ability. But it is at least possible.
Reply

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.
Reply

(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;
------------------------------------------------------
Reply

Thank you. But would it not be easier if just using SetWizardData to record XYP of city with fortress of that wizard that run check after some event such as banish and spell of return?
Reply

(December 30th, 2023, 10:46)Suppanut Wrote: Thank you. But would it not be easier if just using SetWizardData to record XYP of city with fortress of that wizard that run check after some event such as banish and spell of return?

Yes. If you only need the fortress coordinates,  GetWizardData is sufficient, you can do the check at the start of the game or when a wizard returns with spell of return. Mine is more general for all cities (due to how I program certain racial mechanics).

IF you need to use it on an existing city, you can also do this on Load game.
Reply

Both me and Slinger try to remove Confusion by script at the end of combat to save the victim unit but by next combat that unit seem to stuck in wandering around mode, how could I fix this? Is this hardcoded I could not find change of ownership by script?
Reply

(January 27th, 2024, 19:02)Suppanut Wrote: Both me and Slinger try to remove Confusion by script at the end of combat to save the victim unit but by next combat that unit seem to stuck in wandering around mode, how could I fix this? Is this hardcoded I could not find change of ownership by script?

Try checking the base unit instead of the current one when detecting its owner in EndofCombat.CAS.

W=(GetStat(U,SOwner,0));    --->   W=(GetStat(U,SOwner,1));

Maybe that works?
Reply

(January 29th, 2024, 04:43)Slingers Wrote:
(January 27th, 2024, 19:02)Suppanut Wrote: Both me and Slinger try to remove Confusion by script at the end of combat to save the victim unit but by next combat that unit seem to stuck in wandering around mode, how could I fix this? Is this hardcoded I could not find change of ownership by script?

Try checking the base unit instead of the current one when detecting its owner in EndofCombat.CAS.

W=(GetStat(U,SOwner,0));    --->   W=(GetStat(U,SOwner,1));

Maybe that works?

I have checked, it is not about ownership, it seem to be about wandering around flag that it not get removed properly if combat end while unit has this flag on.
Reply

(January 29th, 2024, 09:08)Suppanut Wrote: I have checked, it is not about ownership, it seem to be about wandering around flag that it not get removed properly if combat end while unit has this flag on.

Which conditions need to be met, to get such a permanently confused unit? Which endtype/ state of confused unit/ winner or loser/ attacker or defender?

I haven't consciously come across this yet and couldn't reproduce it in a test.
Reply



Forum Jump: