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

I tried a game with no lairs--and thus no lair units. The turns went by really, really fast. I'm not sure why the script is checking all lair units for enhancements (or whatever else), but that certainly looks like a good opportunity to cut turn time. If there's any need to run the script for them, maybe just do it when a lair actually spawns rampagers or when someone attacks it.
Reply

May I request ability to mod building/city/global enchantment (not only ore) to able to reduce unit training cost?
Reply

I get some feedback from Hadriex today which I think it is valid for both modding and vanilla CoM2.
1) Current global enchantment with stacking feature should be moddable, especially Divine Order, as they would stack like crazy and skewed the game beyond original design as they were design for 5 players game in mind. For Divine Order, this could be fixed with moddable value of both initial effect and stack effect. And for more universal stacking spell, I think number of same global enchantment in play should be limited, think about how several wizards try to manipulate same section of aether space to the limit and could not insert another copy of that global enchantment into aether anymore.
2) Hadriex suggests that there should be fatique period after disjunction that cause disjuncted global enchantment could not be recasted for a period of time (I think it should be introduced into lore of game as "aether fatique" that cause the section of aether that need to manipulate for global enchantment not able to be shaped into intend shape for a period of time) and period of time should depending on how much mana wizard who cast disjunction put into the spell. So global enchantment with high cost would naturally need longer period of time before recast the spell is possible.
3) I also want to request that equation for Dispel, Disenchant Area, Dispelling Wave, Disillusion, and Disjunction to be moddable.
Reply

Another possibility for reducing script-running time: keep track of which enhancements a wizard can cast, so that the script can just check those. I'm guessing that at present, every unit is checked for every possible spell. I think many of us end out games before VR spells, so we're slowing the turns down checking for things that won't ever happen. Why check for Ruler of Underworld on turn 5 for an all-Nature wizard's units?
Reply

(July 2nd, 2022, 02:29)Suppanut Wrote: 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?

It's a function so it should be "Iscombat()", I don't think writing it without () works.

Quote:I'm just guessing that the scripts are running for the lair monsters too
Lair monsters don't exist. They are created only when entering battle against them and are removed afterwards. They are just a pair of numbers in the lair data array outside that time.

Quote:When the AI is considering which unit to build, might it be running these scripts for each possible unit
No, it should only do it for units that are available for production.

Quote:I tried a game with no lairs--and thus no lair units. The turns went by really, really fast.
Of course they did, all the AI's had no targets to evaluate for potential attacks. This seems to indicate the time is consumed by AI decisions - simulating battle against every lair using every army that can reach it. That means it's not related to scripts. The other possibility is pathfinding - the AI also needs to check which lair is reachable by which unit which also takes time.

Quote:Why check for Ruler of Underworld on turn 5 for an all-Nature wizard's units?

Disregarding syntax,
"If WizardData.Enchantments[Unitowner,RulerofUNderworld]"
isn't any slower than
"if WizardData.KnownSpells[Unitowner,RulerofUNderworld]"

in fact it's literally the same time. You just check whether they know the spell instead of whether the spell is already cast. How would that save any time?
Reply

(July 3rd, 2022, 22:35)Seravy Wrote:
(July 2nd, 2022, 02:29)Suppanut Wrote: 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?

It's a function so it should be "Iscombat()", I don't think writing it without () works.

Quote:I'm just guessing that the scripts are running for the lair monsters too
Lair monsters don't exist. They are created only when entering battle against them and are removed afterwards. They are just a pair of numbers in the lair data array outside that time.

Quote:When the AI is considering which unit to build, might it be running these scripts for each possible unit
No, it should only do it for units that are available for production.

Quote:I tried a game with no lairs--and thus no lair units. The turns went by really, really fast.
Of course they did, all the AI's had no targets to evaluate for potential attacks. This seems to indicate the time is consumed by AI decisions - simulating battle against every lair using every army that can reach it. That means it's not related to scripts. The other possibility is pathfinding - the AI also needs to check which lair is reachable by which unit which also takes time.

Quote:Why check for Ruler of Underworld on turn 5 for an all-Nature wizard's units?

Disregarding syntax,
"If WizardData.Enchantments[Unitowner,RulerofUNderworld]"
isn't any slower than
"if WizardData.KnownSpells[Unitowner,RulerofUNderworld]"

in fact it's literally the same time. You just check whether they know the spell instead of whether the spell is already cast. How would that save any time?

Thank you for your guidance.
Reply

I was wondering just what the purpose of unitcalc was, and I guessed right: that it's the AI checking the exact combat strength of all potential targets.. Might there be a more fun (and faster) method? I haven't found that the AI's strategy is very effective, and it isn't dramatically less effective with unitcalc turned off. I've often had AI declare war, have their stacks dance around on their continent for many turns, then ask for peace ... all this consuming unicalc cycles. AI strategy can also be countered by moving some units around to change calculated garrison strength.

How about if when the AI declares war, it builds its best doomstack(s) at that time, chooses enemy cities based on population, distance, or some other such factors, and sends them off to attack, without recalculating every turn. When they get there, then do the strength calc and either use some spells to further buff units or zap the city, wait for reinforcements, choose a new (smaller) target, or just attack for the glory of it (and hopefully attrition for the enemy).

If that system leads to too many losses for the AIs, maybe the AI could get random combat 'subsidies' of some sort: individual unit buffs, battlefield buffs, free summons (like Pandora's Box). COM isn't meant to be one of those precise simulation wargames; a bit of unexpected behaviour might make the game more fun. You'd have to make more effort to maintain serious garrisons if instead of "stack of two warbears and an orcish bowman approaching, so my two halbardiers and three buffed bowmen is enough" their force might get holy bonus 1 and some extra orcish swordsmen when the combat actually starts.

I suppose that's well outside COM modding. If anyone thinks that changing the basics of AI strategy is worth discussing, maybe start a new thread? As it is, I don't see that precise calculations of enhanced unit strength is worth the longer turn time (on my fairly slow computer), so I'll just turn unit.calc off, since that's easy to do.
Reply

For checking whether a wizard actually knew the enchantment, I had in mind keeping a list of unit enchantments known for each wizard, and then looping just through those. If the wizard only knows "Holy Weapon" on turn 7, then unitcalc would only do 1 check. On turn 100, it might be several checks, but that's still shorter than the list of all spells in all realms; a list that will keep growing with additional mods and updates. It's moving some data processing from a 'runs many times per turn script' to a 'add another item to a list possibly once every several turns' part of the program. A data processing strategy that is 'good enough' initially, may end up a bad choice as the program evolves.
Reply

The purpose of unitcalc (the script) and the equivalent hardcoded function, is to apply effects onto the unit that are persistent.

For example a unit with Holy Weapon on it gets the +10% hit chance there. (in the hardcoded part)
A unit with a new custom spell that does the same buff, would get it in the unitcalc script.

This has nothing to do with the AI, it's required for the unit to have the stats it's supposed to have.
Whether the AI does or doesn't use that information later is irrelevant, it has to be correct in the first place to, for example, display it on the UI for the player when they look at that unit.

Unitcalc is run every time anything happens in the game that can add or remove any effect that changes the stats of the unit. This includes moving a unit to a different tile (Holy Bonus), casting or dispelling an enchantment, etc.
I've already narrowed this down as much as I could, for example moving the units will only do the calculations for the units that are on the two tiles where the moving unit started from and stopped at, or a Prayer cast in combat will only calculate the stats of units in combat.


Quote:chooses enemy cities based on population, distance, or some other such factors, and sends them off to attack, without recalculating every turn.

That's exactly how the base game before community patch worked and we all know how "good" that AI is.
It's not just the problem of bad play but also leads to drastic misplays, such as you conquer a city from an enemy player, and your ally then attacks that city because when they last processed it, it wasn't yours but the enemy's.

Quote:For checking whether a wizard actually knew the enchantment, I had in mind keeping a list of unit enchantments known for each wizard, and then looping just through those. If the wizard only knows "Holy Weapon" on turn 7, then unitcalc would only do 1 check.

It's not coded in a loop.
It's literally just one line of "If <enchantment> then add <stats>" for every enchantment that can modify stats.
Your suggestion is basically "if <knows enchantment> then [If <enchantment> then add <stats>] otherwise do nothing." which is more complex and not faster.
Reply

May I ask for ability to script counting number of enchantment spell copy own by caster? And also may I ask for ability to remember and count combat turn, something number of turns since curse get enchanted? and maybe counting of each wizard's cities?
Reply



Forum Jump: