home *** CD-ROM | disk | FTP | other *** search
/ Amiga Special: Spiele Hits / Hits-CD.iso / aminet / spiele / ammud1_1.lha / AmigaMUD / Src / Combat / fight.m < prev    next >
Text File  |  1997-06-19  |  51KB  |  1,917 lines

  1. /*
  2.  * Amiga MUD
  3.  *
  4.  * Copyright (c) 1997 by Chris Gray
  5.  */
  6.  
  7. /*
  8.  * fight.m - add player stats, fighting, etc. to the starter dungeon.
  9.  */
  10.  
  11. private tp_fight CreateTable()$
  12. use tp_fight
  13.  
  14. /*
  15.  * NOTE: there is a direct dependency on r_arrivals, to send killed
  16.  *    players there.
  17.  */
  18.  
  19. define t_fight STEPS_PER_REGAINED_HIT_POINT    25$
  20. define t_fight BLUTOS_AFTER_DYING        25$
  21. define t_fight RANDOM_MONSTER_LIFE        100$
  22. define t_fight FOREVER_LIFE            -1$
  23. define t_fight STANDARD_STRENGTH        5$
  24. define t_fight STANDARD_ACCURACY        5$
  25. define t_fight STANDARD_DAMAGE            5$
  26. define t_fight STANDARD_SPEED            5$
  27.  
  28. /* first, the new player properties. Note: these are all the effective values,
  29.    which may include modifications from armour, weapons, spells, etc. */
  30.  
  31. define t_fight p_pInited CreateBoolProp()$    /* player has been set up */
  32. define t_fight p_pFightTerse CreateBoolProp()$
  33. define t_fight p_pFightSuperTerse CreateBoolProp()$
  34. define t_fight p_pHitMax CreateIntProp()$    /* max hit points */
  35. define t_fight p_pHitNow CreateIntProp()$    /* current hit points */
  36. define t_fight p_pHitCount CreateIntProp()$    /* part count for healing */
  37. define t_fight p_pExperience CreateIntProp()$    /* experience */
  38. define t_fight p_pLevel CreateIntProp()$    /* current level */
  39. define t_fight p_pStrength CreateIntProp()$    /* strength */
  40. define t_fight p_pSpeed CreateIntProp()$    /* speed/dexterity */
  41. define t_fight p_pProtection CreateIntProp()$    /* current armour class */
  42. define t_fight p_pWeapon CreateThingProp()$    /* current weapon */
  43. define t_fight p_pShield CreateThingProp()$    /* current shield */
  44. define t_fight p_pArmour CreateThingProp()$    /* current armour */
  45. define t_fight p_pCurrentTarget CreateThingProp()$    /* current opponent */
  46. define t_fight p_pDieNotifyList CreateActionListProp()$
  47. define t_fight p_pNewMonster CreateThingProp()$ /* temp during creation */
  48. define t_fight p_pWieldChecker CreateActionProp()$     /* allow player check */
  49. define t_fight p_pTrackerList CreateThingListProp()$    /* list of trackers */
  50.  
  51. /* monster-only properties */
  52.  
  53. define t_fight p_mActions CreateStringProp()$    /* single string of actions */
  54. define t_fight p_mActionIndexes CreateIntListProp()$    /* indices of them */
  55. define t_fight p_mMovesUntilVanish CreateIntProp()$    /* when it leaves */
  56. define t_fight p_mSound CreateStringProp()$        /* name of sample */
  57. define t_fight p_mInitAction CreateActionProp()$    /* startup action */
  58. define t_fight p_mMoveAction CreateActionProp()$    /* step action */
  59. define t_fight p_mAfterMoveAction CreateActionProp()$    /* on enter new room */
  60. define t_fight p_mFightAction CreateActionProp()$    /* fight action */
  61. define t_fight p_mSpecialAction CreateActionProp()$    /* action to do */
  62. define t_fight p_mKillAction CreateActionProp()$    /* action on kill */
  63. define t_fight p_mCreateAction CreateActionProp()$    /* something new */
  64. define t_fight p_mArriveAction CreateActionProp()$    /* something comes */
  65. define t_fight p_mArrivedAction CreateActionProp()$    /* check new loc */
  66. define t_fight p_mExpired CreateBoolProp()$        /* it has "died" */
  67. define t_fight p_mBlocker CreateBoolProp()$        /* it can block */
  68. define t_fight p_mHunting CreateBoolProp()$        /* look for target */
  69. define t_fight p_mTrackerPath CreateIntListProp()$    /* path to target */
  70.  
  71. /* properties for weapons/shield/armour */
  72.  
  73. define t_fight p_oHitBonus CreateIntProp()$    /* hitpoints bonus */
  74. define t_fight p_oStrBonus CreateIntProp()$    /* strength bonus */
  75. define t_fight p_oSpeedBonus CreateIntProp()$    /* speed bonus */
  76. define t_fight p_oArmourProt CreateIntProp()$    /* armour protection bonus */
  77. define t_fight p_oShieldProt CreateIntProp()$    /* shield protection bonus */
  78. define t_fight p_oAccuracy CreateIntProp()$    /* base accuracy level */
  79. define t_fight p_oDamage CreateIntProp()$    /* base damage level */
  80. define t_fight p_oHealing CreateIntProp()$    /* strength of heal */
  81. define t_fight p_oWieldChecker CreateActionProp()$    /* when wield a weapon */
  82.  
  83. /* properties on rooms */
  84.  
  85. define t_fight p_rNoGenerateMonsters CreateBoolProp()$/* no new baddies */
  86. define t_fight p_rMonsterList CreateThingListProp()$  /* what might turn up */
  87. define t_fight p_rMonsterChance CreateIntListProp()$    /* diff per person */
  88. define t_fight p_rMonsterTotal CreateIntProp()$ /* total of the chances */
  89. define t_fight p_rKillAction CreateActionProp()$      /* when monster killed */
  90.  
  91. /* this is an ancestor of all generic monsters */
  92.  
  93. define t_fight GenericMonster CreateThing(nil)$
  94.  
  95. /*
  96.  * fighterDesc - return additional description for a fighter.
  97.  */
  98.  
  99. define tp_fight proc fighterDesc()string:
  100.     thing it, weapon, shield, armour;
  101.     string name, s, shieldName, armourName;
  102.  
  103.     it := It();
  104.     s := "";
  105.     name := Capitalize(CharacterNameS(it));
  106.     weapon := it@p_pWeapon;
  107.     shield := it@p_pShield;
  108.     if shield ~= nil then
  109.     shieldName := FormatName(shield@p_oName);
  110.     fi;
  111.     armour := it@p_pArmour;
  112.     if armour ~= nil then
  113.     armourName := FormatName(armour@p_oName);
  114.     fi;
  115.     if weapon = nil then
  116.     if shield = nil then
  117.         if armour ~= nil then
  118.         s := name + " is wearing " + armourName;
  119.         fi;
  120.     else
  121.         s := name + AAn(" is using", shieldName);
  122.         if armour ~= nil then
  123.         s := s + " and wearing " + armourName;
  124.         fi;
  125.     fi;
  126.     else
  127.     s := name + AAn(" is wielding", FormatName(weapon@p_oName));
  128.     if shield = nil then
  129.         if armour ~= nil then
  130.         s := s + " and wearing " + armourName;
  131.         fi;
  132.     else
  133.         if armour ~= nil then
  134.         s := s + AAn(", using", shieldName);
  135.         s := s + " and wearing " + armourName;
  136.         else
  137.         s := s + AAn(" and using", shieldName);
  138.         fi;
  139.     fi;
  140.     fi;
  141.     if s ~= "" then
  142.     s := " " + s + ".";
  143.     fi;
  144.     s
  145. corp;
  146.  
  147. /*
  148.  * AddFighterDesc - add the description about weapons, etc. to the list
  149.  *    of extra descriptions on the passed character, if it is not
  150.  *    already there.
  151.  */
  152.  
  153. define t_fight proc AddFighterDesc(thing theCharacter)void:
  154.     list action la;
  155.  
  156.     la := theCharacter@p_pDescMore;
  157.     if la = nil then
  158.     la := CreateActionList();
  159.     theCharacter@p_pDescMore := la;
  160.     fi;
  161.     if FindElement(la, fighterDesc) = -1 then
  162.     AddTail(la, fighterDesc);
  163.     fi;
  164. corp;
  165.  
  166. /*
  167.  * useItem - start using the given item.
  168.  */
  169.  
  170. define tp_fight proc useItem(thing th)void:
  171.     thing me;
  172.     list action la;
  173.  
  174.     me := Me();
  175.     me@p_pHitMax := me@p_pHitMax + th@p_oHitBonus;
  176.     me@p_pStrength := me@p_pStrength + th@p_oStrBonus;
  177.     me@p_pSpeed := me@p_pSpeed + th@p_oSpeedBonus;
  178.     me@p_pProtection := me@p_pProtection + th@p_oArmourProt + th@p_oShieldProt;
  179.     AddFighterDesc(me);
  180. corp;
  181.  
  182. /*
  183.  * unUseItem - stop using the given item.
  184.  */
  185.  
  186. define tp_fight proc unUseItem(thing th, theCharacter)void:
  187.  
  188.     theCharacter@p_pHitMax := theCharacter@p_pHitMax - th@p_oHitBonus;
  189.     theCharacter@p_pStrength := theCharacter@p_pStrength - th@p_oStrBonus;
  190.     theCharacter@p_pSpeed := theCharacter@p_pSpeed - th@p_oSpeedBonus;
  191.     theCharacter@p_pProtection := theCharacter@p_pProtection -
  192.     th@p_oArmourProt - th@p_oShieldProt;
  193. corp;
  194.  
  195. /* the wear/use/wield routines for armour/shields/weapons */
  196.  
  197. define tp_fight proc armourDrop(thing th)status:
  198.     thing theCharacter;
  199.  
  200.     theCharacter := th@p_oCarryer;
  201.     if theCharacter ~= nil then
  202.     unUseItem(th, theCharacter);
  203.     theCharacter -- p_pArmour;
  204.     th -- p_oUnGetChecker;
  205.     fi;
  206.     continue
  207. corp;
  208.  
  209. define tp_fight proc shieldDrop(thing th)status:
  210.     thing theCharacter;
  211.  
  212.     theCharacter := th@p_oCarryer;
  213.     if theCharacter ~= nil then
  214.     unUseItem(th, theCharacter);
  215.     theCharacter -- p_pShield;
  216.     th -- p_oUnGetChecker;
  217.     fi;
  218.     continue
  219. corp;
  220.  
  221. define tp_fight proc weaponDrop(thing th)status:
  222.     thing theCharacter;
  223.  
  224.     theCharacter := th@p_oCarryer;
  225.     if theCharacter ~= nil then
  226.     unUseItem(th, theCharacter);
  227.     theCharacter -- p_pWeapon;
  228.     th -- p_oUnGetChecker;
  229.     fi;
  230.     continue
  231. corp;
  232.  
  233. define tp_fight proc armourWear()status:
  234.     thing th, me, oldArmour;
  235.     string aName;
  236.  
  237.     th := It();
  238.     me := Me();
  239.     if me@p_pWeapon = th then
  240.     ignore weaponDrop(th);
  241.     fi;
  242.     if me@p_pShield = th then
  243.     ignore shieldDrop(th);
  244.     fi;
  245.     oldArmour := me@p_pArmour;
  246.     if oldArmour ~= nil then
  247.     unUseItem(oldArmour, me);
  248.     oldArmour -- p_oUnGetChecker;
  249.     fi;
  250.     useItem(th);
  251.     th@p_oUnGetChecker := armourDrop;
  252.     me@p_pArmour := th;
  253.     aName := FormatName(th@p_oN