User Tools

Site Tools


user:loggy:castingai

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
user:loggy:castingai [2021/06/30 03:00]
loggy
user:loggy:castingai [2023/02/24 19:01] (current)
loggy fairly important note those self buffing resists
Line 6: Line 6:
  
 The battlefield location array seems to be stored with offsets of %%((coord2 * 200) + coord 1) * 0x20%% The battlefield location array seems to be stored with offsets of %%((coord2 * 200) + coord 1) * 0x20%%
 +Or is it?
 +
 +When looking for specific units in squares, it's instead %%(index, 0-7 inclusive + ((coord2 * 200) + coord1) * 8)%%
  
  
Line 25: Line 28:
   * 4, cause fear type 1 [1]   * 4, cause fear type 1 [1]
   * 7, poison damage [1]   * 7, poison damage [1]
-  * 8, remove fatigue? [0]+  * 8, remove fatigue? [-1]
   * 9, undocumented   * 9, undocumented
-  * 10, bless/buff type 1 [0]+  * 10, bless/buff type 1 [-1]
   * 11, cause affliction [1]   * 11, cause affliction [1]
-  * 13, heal [0+  * 13, heal [-1
-  * 23, buff type 2 [0]+  * 23, buff type 2 [-1]
   * 24, damage x3 vs demon/undead [1]   * 24, damage x3 vs demon/undead [1]
   * 28, enslave [1]   * 28, enslave [1]
Line 97: Line 100:
     * If the spell is more than lingering 4, multiply the score by 3. If it is lingering 2 or 3, multiply by 2 instead.     * If the spell is more than lingering 4, multiply the score by 3. If it is lingering 2 or 3, multiply by 2 instead.
     * If the score is greater than zero:     * If the score is greater than zero:
-      * Calculate a new score: ((closed d120 + 40) * old score) / 100, rounded down. If this value is less than 10, set it to be 10.+      * Calculate a new score: %%((closed d120 + 40) * old score) / 100, rounded down. If this value is less than 10, set it to be 10.%%
       * Some stuff I don't understand that cares about the spell range       * Some stuff I don't understand that cares about the spell range
       * If the spell effect was 126 (call horror), the score is set to d10 exploding or the actual score, whichever is lower.       * If the spell effect was 126 (call horror), the score is set to d10 exploding or the actual score, whichever is lower.
Line 125: Line 128:
     * Any other enchantment, only 1.     * Any other enchantment, only 1.
   * Other types of spells:   * Other types of spells:
 +      * If the spell's AoE is 601+ [smaller % aoe is not handled correctly]:
 +        * Add up spellunitscores for all units on the field
 +        * Add an exploding d10 to this and use it as the final score
       * If the spell is self target only, just consider the caster.       * If the spell is self target only, just consider the caster.
       * Work out how many units the effect could usefully target (check every square, add up the number of targets in them), depending on whether it is offensive (look at enemies) or nonoffensive (look at friends). Make a copy of this value called the "reduced number of targets"       * Work out how many units the effect could usefully target (check every square, add up the number of targets in them), depending on whether it is offensive (look at enemies) or nonoffensive (look at friends). Make a copy of this value called the "reduced number of targets"
Line 132: Line 138:
       * If reduced squares is 12+: if min(300, reduced squares) <= closed d300 + 9, check this square. [there is a (squares-9)/300 chance to skip any given square]       * If reduced squares is 12+: if min(300, reduced squares) <= closed d300 + 9, check this square. [there is a (squares-9)/300 chance to skip any given square]
       * If the square being considered is out of range, skip it.       * If the square being considered is out of range, skip it.
-      * Calc some values based on range, aoe, and precision +      * Calc some values based on range, aoe, and precision
-      * +        * If the spell's AoE is 11+ OR (number of effects is 16+ AND the distance from the caster is 5 or less): 
 +          * square spread = 2 
 +          * accurate square weight = (max(1, aoe) * number of effects * 200)/26 
 +          * inaccurate square weight = (max(1, aoe) * number of effects * 100)/26 
 +        * If the spell's AoE is 0 or 1, OR the spell's number of effects is 1: [This means that fists of iron will always fall into this category, and should always account for friendly fire] 
 +          * square spread = 1 
 +          * accurate square weight = max(1, aoe) * number of effects * 20 
 +          * inaccurate square weight = max(1, aoe) * number of effects * 10 
 +        * If the final precision is 90+ OR the distance being aimed at is less than (final prec/3): 
 +          * square spread = 0 
 +          * accurate square weight = 100 
 +          * inaccurate square weight = 0 
 +        * If the distance being aimed is less than (final prec/2): 
 +          * square spread = 1 
 +          * accurate square weight = 36 
 +          * inaccurate square weight = 8 
 +        * All other cases: 
 +          * square spread = 1 
 +          * accurate square weight = 68 
 +          * inaccurate square weight = 4 
 +      * Check a square of tiles containing units. This square is made up of the picked square, plus (square spread) tiles in each cardinal direction [a square with side lengths (2 * square spread) + 1]. For each square within the big square: 
 +        * Sum the unit scores of the things in that square. 
 +        * If there was more than one thing in the square, and the spell affects only 1 person, divide the summed score by the number of units in the square 
 +        * If the square struck was the originally picked square at the centre of the square spread (and not the extra ones around it), add (this square's score * accurate square weight) to the spell score at this location. Otherwise, add (this square's score * inaccurate square weight) to the spell score. 
 +      * If the total score from all the squares is greater than 0: 
 +        * score = max(1, -5 + closed d10 + (score / 100)) [This divides the weighting multiplied scores from the above by 100 regardless of which spread/weightings were selected] 
 +        * If the spell is being aimed less than 10 squares from the caster, and the spell is an offensive effect number (effects that returned 1 on the list somewhere above) 
 +          * score = max(1, (score * 10)/max(2, distance from caster)) 
 +        * Otherwise: 
 +          * If the spell's (NOT FINAL) precision is less than 20: 
 +            * score = max(1, (score * 10)/max(10, distance from caster)) 
 +          * Other cases: 
 +            * score = max(1, (score * 15)/max(15, distance from caster)) 
 +      * Compare the final score casting the spell at this position to the based saved one. If it's better, take this as the new best. 
 +    * Regardless of your spell's aoe or how you arrived at your score up to this point, if it is greater than zero: 
 +      * score = %%max(1, (open d10 + ((open d40 + 80) * score)/100 - 5)%%
   * Calculate a final score: (score * 100) / (fatigue from cast, not including encumbrance + 90) and round down.   * Calculate a final score: (score * 100) / (fatigue from cast, not including encumbrance + 90) and round down.
   * If over 75 fatigue and casting a reinvigoration spell (effect 8 only):   * If over 75 fatigue and casting a reinvigoration spell (effect 8 only):
Line 165: Line 206:
   * If combat round 2+, this is always 1.   * If combat round 2+, this is always 1.
   * In assassination, this is 2 - round   * In assassination, this is 2 - round
-  * In other cases, this is (2 - round)+  * In other cases, this is (2 - round)*2
  
 Self buff bias is 2 if the caster is the spell's target AND it is before round 2, otherwise it is 1 Self buff bias is 2 if the caster is the spell's target AND it is before round 2, otherwise it is 1
Line 239: Line 280:
   * Otherwise, add (1 - victim's prot)   * Otherwise, add (1 - victim's prot)
  
-If the current damage value is greater than (victim'max hp + 5), set it to that value [shouldn't this be current hp instead?]+If the current damage value is greater than (victim chassis max hp + 5), set it to that value [shouldn't this be current hp instead?]
  
 If the spell offers either (or both) an easy or hard MR check: If the spell offers either (or both) an easy or hard MR check:
Line 245: Line 286:
   * If the spell offers an easy mr check, consider victim's mr as 4 higher.   * If the spell offers an easy mr check, consider victim's mr as 4 higher.
   * If the spell does not offer a normal MR check, and (user's pen bonus + 8) <= (victim's MR + 4), multiply damage by 2/3. [shouldn't this be banded like regular MR? This means that easy MR soul slay will be preferred to normal soul slay vs high MR targets...]   * If the spell does not offer a normal MR check, and (user's pen bonus + 8) <= (victim's MR + 4), multiply damage by 2/3. [shouldn't this be banded like regular MR? This means that easy MR soul slay will be preferred to normal soul slay vs high MR targets...]
-  * If the spell offers a normal MR check: +  * If the spell offers a normal MR check, do the first one that applies
-    * if (mr > pen bonus + 8), do nothing to damage +    * if (mr >pen bonus + 23), divide damage by 24 
-    * if (mr pen bonus + 11), multiply damage by 2/3 +    * if (mr >= pen bonus + 20), divide damage by 12 
-    * if (mr pen bonus + 14), divide damage by 2 +    * if (mr >= pen bonus + 17), divide damage by 6 
-    * if (mr pen bonus + 17), divide damage by 6 +    * if (mr >= pen bonus + 14), divide damage by 3 
-    * if (mr pen bonus + 20), divide damage by 12 +    * if (mr >= pen bonus + 11), divide damage by 2 
-    * if (mr pen bonus + 23), divide damage by 24+    * if (mr >= pen bonus + 8), multiply damage by 2/3 
 +    * Otherwise, do nothing to damage
  
 If MR check for half damage, multiply damage by 2/3 [shouldn't this be banded?] If MR check for half damage, multiply damage by 2/3 [shouldn't this be banded?]
Line 257: Line 299:
 If spell is defence negate OR (is not AoE and does not ignore shields), multiply damage by 2/3 [couldn't these be split and done a bit better?] If spell is defence negate OR (is not AoE and does not ignore shields), multiply damage by 2/3 [couldn't these be split and done a bit better?]
  
-Look up the victim's chassis' strength score, and subtract 10 from it. If the result is less than 1, consider it to be 1. This is going to be used for some effects later.+Look up the victim's chassis' strength score, and subtract 10 from it, and add the spell's damage. If the result is less than 1, consider it to be 1. This is the "strength value" going to be used for some effects later.
  
 If the effect is buff type 1: If the effect is buff type 1:
Line 364: Line 406:
     * score = max(10, 20 - victim's current HP/2) * friendly bias * self buff bias * early buff bias     * score = max(10, 20 - victim's current HP/2) * friendly bias * self buff bias * early buff bias
   * If the spell confers invuln 25:   * If the spell confers invuln 25:
-    * If the recipient's prot < 22, score = max(45000, victim current HP * friendly bias * self buff bias * early buff bias * 50) [max is intended here!]+    * If the recipient's prot < 22, score = min(45000, victim current HP * friendly bias * self buff bias * early buff bias * 50)
     * Otherwise, score = friendly bias     * Otherwise, score = friendly bias
   * If the spell confers invuln 15 and does not confer invuln 25:   * If the spell confers invuln 15 and does not confer invuln 25:
-    * If the recipient's prot < 12, score = max(45000, victim current HP * friendly bias * self buff bias * early buff bias * 50) [max is intended here!]+    * If the recipient's prot < 12, score = min(45000, victim current HP * friendly bias * self buff bias * early buff bias * 50) 
     * Otherwise, score = friendly bias     * Otherwise, score = friendly bias
   * If the spell confers invuln 15 to wolves only, and neither of the two above invuln effects, and the victim is a wolf:   * If the spell confers invuln 15 to wolves only, and neither of the two above invuln effects, and the victim is a wolf:
-    * If the recipient's prot < 13, score = max(45000, victim current HP * friendly bias * self buff bias * early buff bias * 50) [max is intended here!]+    * If the recipient's prot < 13, score = min(45000, victim current HP * friendly bias * self buff bias * early buff bias * 50) 
     * Otherwise, score = friendly bias     * Otherwise, score = friendly bias
   * If the spell confers power of the spheres:   * If the spell confers power of the spheres:
Line 401: Line 443:
     * score = current HP * friendly bias * early buff bias * 5     * score = current HP * friendly bias * early buff bias * 5
   * If the spell confers swiftness, and the recipient is not immobile:   * If the spell confers swiftness, and the recipient is not immobile:
-    * score = ((current HP + 1)*friendly bias * early buff bias)/2+    * score = %%((current HP + 1)*friendly bias * early buff bias)/2%%
   * If the spell confers hell power:   * If the spell confers hell power:
     * score = current HP * friendly bias * early buff bias     * score = current HP * friendly bias * early buff bias
Line 488: Line 530:
     * score = (current HP * - friendly bias * 3)/2     * score = (current HP * - friendly bias * 3)/2
  
-... [more spell effects go here] \\+For the following effects
 +  * 2 damage 
 +  * 24 x3 vs undead or demons 
 +  * 73 x2 vs magic beings 
 +  * 96 shatter damage 
 +  * 99 petrify 
 +  * 105 disbelieve dmg 
 +  * 107 x2 vs demon 
 +  * 109 capped dmg 
 +  * 124 undocumented 
 +  * 134 chain lightning 
 +  * 142 salt damage 
 + 
 +score = strength value * - friendly bias * 10
  
 +  * For unlife damage or unlife damage x2 vs magic beings:
 +    * score = strength value * - friendly bias * 10
 +    * If the victim is not inanimate and not undead, add 25
 +  * For magic duel:
 +    * score = min(10, strength value) * - friendly bias
 +  * For drain life:
 +    * score = caster's fatigue + (strength value * - friendly bias * 10) + max(0, 10 * (caster's max hp - caster's current hp))
 +  * For fear:
 +    * If the victim is already routed, score 0
 +    * Otherwise, score = strength value * - friendly bias * 5
 +  * For poison HP damage and capped poison damage:
 +    * score = strength value * - friendly bias * -8
 +  * For fatigue damage:
 +    * score = (strength value * - friendly bias * victim max HP)/10, rounded down
 +  * For interrupt damage:
 +    * If the victim has no magic skill, score 0 [mundane commanders casting spells via items will not be targeted]
 +    * score = (victim's max HP * (strength value + 25) * - friendly bias) / 32
 +  * For weakening spells:
 +    * score = (9 - victim's max HP * friendly bias * strength value)/10 [friendly bias is negative when aimed at enemies]
 +  * For spells that directly add age:
 +    * score = (19 - victim's max HP * friendly bias * strength value)/20) [friendly bias is negative when aimed at enemies]
 +  * For paralyze damage:
 +    * If the victim is already paralyzed for 10+ ticks, OR (strength value/2) is less than paralysis ticks:
 +      * score = 2
 +    * otherwise, score = (victim current HP * - friendly bias * strength value)/4
 +  * For stun/fascination:
 +    * If the victim is stun immune, score 0
 +    * If the victim is stunned for 2000-4999 ticks, score = 2
 +    * If the victim is stunned for 5000+ ticks, score = 0
 +    * Otherwise, score = victim current HP * - friendly bias * 2
 +  * For effects 500-599 (capped add unit effect) inclusive:
 +    * If the victim does not have the effect already:
 +      * If the spell confers damage reversal, score = victim current HP * friendly bias * 15
 +      * If the spell confers desiccation, score = victim current HP * - friendly bias * 2
 +      * If the spell confers anything else, score = 1
 +    * If the victim has the effect already at some magnitude **[NOTE: this checks TOTAL magnitude already, not what is in slots, which means that a unit that has 10 FR will refuse to put +10FR into their slots with these spells, despite the fact units will happily use the +5 buff until 20+]**:
 +      * If the spell is trying to add less magnitude than the effect has already, score = 0
 +      * If the spell confers damage reversal, score = victim current HP * friendly bias * 10
 +      * If the spell confers desiccation, score = victim current HP * - friendly bias
 +      * If the spell confers anything else, score = 1
 +  * For effects 600-699 (uncapped add unit effect) inclusive:
 +    * If the spell horror marks:
 +      * score = victim current HP * - friendly bias
 +    * If the spell applies encase in ice, and the target's encase in ice value is less than 100:
 +      * score = max(2, victim prot - 17) * victim current HP * - friendly bias
 +      * If the victim already has any amount of encase in ice, score = above score / (encase in ice value / 20 + 2)
 +    * Any other case scores 0
 +  * For stream of life:
 +    * score = victim current HP * - friendly bias * 7
 +  * For enslave and charm:
 +    * If the victim cannot be charmed, score = 0
 +    * score = strength value * - friendly bias * 20
 +  * For polymorph:
 +    * score = max(1, strength value - 5) * - friendly bias * 10
 +  * For plane banishment:
 +    * If the victim has no void sanity and there is a source of astral fetters on the battlefield, score = 0
 +    * Otherwise, score = victim current HP *  - friendly bias * 100
 +  * For healing spells:
 +    * score = victim's missing hp * friendly bias * 10
 +  * For fatigue removal spells:
 +    * score = (min(strength score, target's fatigue) * friendly bias)/2
 +  * For the unused temp morale boost effect:
 +    * If the recipient isn't routed:
 +      * score = (5 - recipient's current fear morale modifier * friendly bias)
 +  * For returning:
 +    * If some (TODO: what is this - looks like being in other planes) criteria, you get 0. Otherwise, 1.
 +  * For blink:
 +    * score = 1
 +  * For either kind of armour damage spells:
 +    * TODO as with rust, insufficient current knowledge of how items and armor are handled
 +  * Any other effects score 0
  
 If the final score > 3, the victim is an enemy of the caster, and is immobilized, divide final score by 2. If the final score > 3, the victim is an enemy of the caster, and is immobilized, divide final score by 2.
user/loggy/castingai.1625022006.txt.gz · Last modified: 2021/06/30 03:00 by loggy