Are you, in fact, a pregnant lady who lives in the apartment next door to Superdeath's parents? - Commodore

Create an account  

 
Modding Discussion Thread

(June 27th, 2022, 18:25)Seravy Wrote: Added Giant Spider's ability as "Counter Immunity". Also made the generic settler unit ID moddable.
However there are still a lot of hardcoded AI unit IDs which idk what to do about so units shouldn't be sorted in the next version yet.
(Phoenix stall, reduced direct damage priority against specific low thread combat summons, leave walls strategy, preferred focus magic targets, etc)

Additional terrain requirement numbers will be in the next update.

"Phoenix stall", "reduced direct damage priority against specific low thread combat summons", "leave walls strategy", "preferred focus magic targets", etc....

I think all these hardcoded AI tactical flags should be moddable by able to assign these flag on any of unit ID either as part of units.ini or new file for assign those units IDs on AI tactical flags. With this, game would able to use new units in mod as good as they could use old units.
Reply

(June 28th, 2022, 04:01)Not4u Wrote: Seravy, can you please tell me, is it possible to mod current game version for:
- after every failed attempt to win battle in encounter (lair, node or tower), all their defenders are fully restored (even killed ones).
So if player or AI lose that battle, they need a new attempt from scratch. Basically, i want to try a game without a tactic, when player and AI spam encounters and, eventually, kill all defenders.

Not possible in the current one but should be possible in the coming update (1.4.4) as it adds an "end of combat" script.

You will need to code it with a script though, setting all dead units to alive status if the winner is the defender and the neutral player.
Reply

Quote:However there are still a lot of hardcoded AI unit IDs which idk what to do about so units shouldn't be sorted in the next version yet.
(Phoenix stall, reduced direct damage priority against specific low thread combat summons, leave walls strategy, preferred focus magic targets, etc)

Done that but more and more other stuff keeps being found.

Units with hardcoded rendering rules (Water elementals are always animated, sprites have their drawing axis different from the default), hardcoded game rules (Demon Lord can summon two types of demons, Golem has Resist Elements), Steam Cannon has non-default sound effect, etc, there is no end to it.

Sorry to say but being able to reorder the INI file isn't worth this much work right now. Spent 2 days on it already and it's not even halfway done.

I rather start testing the changes so we can have the new version out before the end of summer.
Reply

I now get some report that mod become slower and I suspect that it causes by unitcalc.cas and unitcalcpre.cas. I think about attempt to optimized the code I put into these files. I have some questions for this.

1) Does removal of overland and combat enchantment need to be done separately or I could set enchantment flag (with no ol or combat) to 0 to remove them both?
2) Should I split content between 2 files or I should minimized one of them? If I should minimized content in one of them, which one should I minimized?
3) Do "if" and "for/next" have effect on processing speed more than other code in this file? Should I minimized using of these conditions?
4) Are there any other conditions which I should avoid in these files for performance reason?
Reply

1. has to be separate.
2. doesn't matter
3. No, but loops run as many times as you set them up so that can be a lot.
Like a loop that runs 3 times is fast but one that runs 300 times is 100 times slower obviously.
4. nothing specific aside from loops and nested loops that run too many times.

Unit scripts are slow mainly because they have to be processed for every unit in the game separately and more than once per turn.

Unfortunately I've done everything I could to optimize the script engine so this is the best performance we can get. Interpreter type processing is naturally slower than complier type by a lot.
Reply

Thank you for clarification.
Reply

I was just wondering about the slowdown too. It doesn't seem to vary much with map size, and is high even in the first few turns, when there are few cities and units. I have a suggestion: if you can access the computer's time or cpu cycle count as a variable for the scripts, displaying that in the log file at various points would show where the time-consuming bits are. Then we can judge whether the benefits of that code are worth the slowdown. Some slowdowns might just be errors in variable choices in loops.
Reply

(June 28th, 2022, 04:58)Seravy Wrote:
(June 28th, 2022, 04:01)Not4u Wrote: Seravy, can you please tell me, is it possible to mod current game version for:
- after every failed attempt to win battle in encounter (lair, node or tower), all their defenders are fully restored (even killed ones).
So if player or AI lose that battle, they need a new attempt from scratch. Basically, i want to try a game without a tactic, when player and AI spam encounters and, eventually, kill all defenders.

Not possible in the current one but should be possible in the coming update (1.4.4) as it adds an "end of combat" script.

You will need to code it with a script though, setting all dead units to alive status if the winner is the defender and the neutral player.

In my case, maybe it possible somehow grant all neutral defenders a native (not dispellable) regeneration effect? So, for example, 8/9 initial defender units died through combat, but last got a win (all attackers died or flee) and after all units are again alive and at full hp. But with undead units in probably too complicate...
Reply

I try to nest combat only enchantment and combat enchantment effect with "ISCOMBAT" to optimize game speed then I encounter with this error.

   

here is what  code look like in that area

Code:
: New unit enchantment "Vampiricism", unit becomes undead and gain bloodsuck and create undead :
IF (GetEnchantmentFlag(U,EncVampiricism,0)>0) THEN {
SETENCHANTMENTFLAG U,EncUndead,ABase,1;
SETSTAT U,ACreateUndead,0,1;
SETSTAT U,ABloodsucker,0,1;
}


: Effect below suppose to trigger only during Combat :
IF (ISCOMBAT>0) THEN {
: Possession, Revenant, Vampiricism, and Creature Binding could removed purity :
IF (GETCOMBATENCHANTMENTFLAG(U,EncCreatureBinding,0)>0) THEN {
  SETENCHANTMENTFLAG U,EncPurity,1,0;
  SETCOMBATENCHANTMENTFLAG U,EncPurity,1,0;
  SETOLENCHANTMENTFLAG U,EncPurity,1,0;
}
......
......
......
}

code not end here but this is section that error point to

Why it trigger error? If I using it wrong, what is correct way for me to using this?


Attached Files
.zip   UnitCalc+Pre.zip (Size: 4.09 KB / Downloads: 0)
Reply

For the slow unit scripts, could you add another variable for 'number of enhancements'? Then the script can skip checking all possible enhancements if the unit doesn't have any. Likewise for cities: if the city has zero enhancements, skip the checks.

If a city or unit has 3 enhancements, you could loop through the list of possible enhancements, with them listed in order of frequency, so in many cases you'd loops though the list only a few times.

I'm just guessing that the scripts are running for the lair monsters too, each turn, which is why it's taking so long even in the early turns. Maybe store the tally of lair units right after lair populating, and begin the unit scripts for units past that number.

When the AI is considering which unit to build, might it be running these scripts for each possible unit--maybe even before it has the required buildings for the unit or knows the enhancement spells? I'm just trying to think of ways that it might be running lengthy loops unnecessarily.

It would help to have a way to not check for an enhancement until the wizard learns that spell, but I don't see an obvious way that's flexible enough (multiple realms, spells won't be learned in the same order each time) that reduces the number of decision checks, but maybe someone else will have a solution to that.
Reply



Forum Jump: