Prev: 37194 Up: Map Next: 37395
37233: Action: Attack
Attacks the current object, using strength and the combat byte. Reached through the action lists of 61 - "Nasty Goblin", 63 - "Thorin", 69 - "Hideous Goblin", 73 - "Horrible Goblin", 74 - "Mean Goblin", 75 - "Vicious Goblin" and 76 - "Disgusting Goblin" for action 15, dispatched by TriggerAction. Reached through the action table at ActionTable, dispatched by Turn_RunTheHandlerIfPresent.
Action_Attack 37233 CALL Action_TestTheSharedFlagBits Call Action_TestTheSharedFlagBits to test the shared flag bits.
37236 LD A,(46825) Read *46825.
37239 LD HL,619 Jump to Action_Attack_StoreTheWeapon with the token FIST if no object was named.
37242 CP 255
37244 JR Z,Action_Attack_StoreTheWeapon
37246 LD IX,(46858) Read *46858.
37250 LD L,(IX+8) Read the name token from the object record.
37253 LD H,(IX+9) Read the name token's high byte from the object record.
Action_Attack_StoreTheWeapon 37256 LD (46844),HL Store the weapon-name token at 46844.
37259 LD IX,(46860) Read *Pointer_CurrentCharacter.
37263 LD B,(IX+5) Read the strength from the object record.
37266 LD A,(46825) Read *46825.
37269 INC A Jump to Action_Attack_TakeThatLimitBack if the second object is 255.
37270 JR Z,Action_Attack_TakeThatLimitBack
37272 LD IY,(46858) Read *46858.
37276 LD A,(IY+0) Read the copy count of the object being attacked.
37279 DEC A Jump back to PrintMessage unless that object has one copy.
37280 LD HL,44895
37283 JP NZ,PrintMessage
37286 LD A,(IY+5) Read the attacked object's strength.
37289 ADD A,B Add the attacker's strength onto the attacked object's strength.
37290 JR NC,Action_Attack_KeepTheRollLimit Jump to Action_Attack_KeepTheRollLimit if the sum did not overflow.
37292 LD A,255 Cap the sum at 255.
Action_Attack_KeepTheRollLimit 37294 LD B,A Keep the sum in B as the roll limit.
Action_Attack_TakeThatLimitBack 37295 LD A,B Take that limit back into A.
37296 CALL Action_RollAgainstTen Call Action_RollAgainstTen to roll 10 against the attacker's limit.
37299 LD B,A Copy the result into B.
If the message is held back, the attack is not resolved.
37300 CALL ConditionSuppressTheMessage Call ConditionSuppressTheMessage. If the message is held back, the attack is not resolved.
37303 LD IX,(46856) Read *46856.
37307 LD A,(IX+6) Read the combat byte from the object record.
37310 CALL Action_RollAgainstTen Call Action_RollAgainstTen to roll 10 against the attacker's limit.
37313 CP B Jump back to PrintMessage if this roll is not below the first.
37314 LD HL,44880
37317 JP NC,PrintMessage
37320 LD C,A Keep this roll in C.
37321 ADD A,16 Add 16 to this roll (capped at 255) and jump to Action_Attack_PointAtTheCleaveMessage if the first roll is still higher.
37323 JR NC,Action_Attack_0
37325 LD A,255
Action_Attack_0 37327 CP B
37328 JR C,Action_Attack_PointAtTheCleaveMessage
37330 LD A,B Take the first roll back into A.
37331 SUB C Take this roll off the first.
37332 RLCA Double the difference.
37333 LD E,A Keep the doubled difference in E.
37334 LD D,0 The message-table offset's high byte is zero.
37336 LD IY,37414 Index the attack-message table at 37414.
37340 ADD IY,DE
37342 LD L,(IY+0) Read the low byte of the message address.
37345 LD H,(IY+1) Read the high byte of the message address.
37348 RRCA Shift the doubled difference back down.
37349 RRCA Shift it down again, undoing the double.
37350 LD B,A Keep that difference in B.
37351 CPL Complement A.
37352 ADD A,(IX+5) Add the current object's strength.
37355 JR NC,Action_Attack_TakeTheDifferenceBack Leave the strength unchanged if the damage would take it below zero.
37357 LD (IX+5),A Store the reduced strength.
Action_Attack_TakeTheDifferenceBack 37360 LD A,B Take the difference back into A.
37361 RRCA Shift the difference down once more.
37362 CPL Complement A.
37363 ADD A,(IX+6) Add the current object's combat byte.
37366 JR NC,Action_Attack_PrintTheMessage Leave the combat byte unchanged if the damage would take it below zero.
37368 LD (IX+6),A Store the reduced combat byte.
Action_Attack_PrintTheMessage 37371 JP PrintMessage Jump to PrintMessage to print the message at HL.
Action_Attack_PointAtTheCleaveMessage 37374 LD HL,44602 Point HL at 44602.
37377 CALL PrintMessage Call PrintMessage to print message.
37380 SET 3,(IX+7) Mark the object broken.
37384 LD A,(46824) Read *CurrentObject.
37387 CALL Turn_ThePlayerHasDied_0 Call Turn_ThePlayerHasDied_0. The player dies if no object is left.
37390 LD A,6 Pass 6 to the routine that names this object.
37392 JP Message_NameFromThisRecord Jump to Message_NameFromThisRecord to print the object's name.
Prev: 37194 Up: Map Next: 37395