Prev: 92BE Up: Map Next: 937B
92F9: Calculate the casting chance of the current spell.
CHAN_C 92F9 LD A,(CURSP) Add CURSP - 1 to address of spells_table 7 times to get address of current spell entry.
92FC LD IX,spells_table
9300 LD D,$00
9302 DEC A
9303 LD E,A
9304 LD B,$07
spell_add_loop 9306 ADD IX,DE
9308 DJNZ spell_add_loop
930A LD (current_spell_pointer),IX Store address in current_spell_pointer.
930E LD A,(IX+$03) Load Chaos/Law value from spell data and store in spell_chaos_law.
9311 LD (spell_chaos_law),A
9314 LD A,(CH_LAW) If CH_LAW is not zero jump to not_neutral.
9317 OR A
9318 JR NZ,not_neutral
not_aligned 931A LD HL,(current_spell_pointer) Copy chance value from spell data into casting_chance and jump to add_ability.
931D INC HL
931E LD A,(HL)
931F LD (casting_chance),A
9322 JR add_ability
not_neutral 9324 JP M,chaotic If CH_LAW is negative jump to chaotic.
9327 LD E,A Copy value (lawfulness) into E
9328 LD A,(spell_chaos_law) If spell_chaos_law is less than or equal to zero jump to not_aligned.
932B OR A
932C JR Z,not_aligned
932E JP M,not_aligned
9331 LD A,(IX+$01) Divide lawfulness by 4 and add chance value from spell data.
9334 SRL E
9336 SRL E
9338 ADD A,E
9339 LD (casting_chance),A Store in casting_chance and jump to add_ability.
933C JR add_ability
chaotic 933E NEG Convert to positive value (chaos) and copy into E.
9340 LD E,A
9341 LD A,(spell_chaos_law) If spell_chaos_law is greater than or equal to zero jump to not_aligned.
9344 OR A
9345 JP P,not_aligned
9348 LD A,(IX+$01) Divide lawfulness by 4, add chance value from spell data, and store in casting_chance.
934B SRL E
934D SRL E
934F ADD A,E
9350 LD (casting_chance),A
add_ability 9353 LD A,(current_player) Get ability attribute from current wizard.
9356 ADD A,$29
9358 LD D,A
9359 LD E,$15
935B CALL GETCHR
935E LD HL,casting_chance Add to value in casting_chance.
9361 ADD A,(HL)
9362 LD (casting_chance),A
9365 LD A,(casting_chance) If casting_chance is not 0 to 9 clear it.
9368 OR A
9369 CP $0A
936B JP M,less_than_ten
936E LD A,$09
less_than_ten 9370 CP $00
9372 JP P,greater_equal_zero
9375 LD A,$00
greater_equal_zero 9377 LD (casting_chance),A
937A RET Return.
Prev: 92BE Up: Map Next: 937B