Advertisement
Slowhand-VI

TUT: HEAL TEXT - USE DRUG

Jan 6th, 2016
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.37 KB | None | 0 0
  1. //  TODO TO INSTALL MODULE: Include utils_h.fos right after the following 2 lines.
  2. //  ----#include "_macros.fos"
  3. //  ----#include "MsgStr.h"
  4. #include "utils_h.fos"
  5.  
  6. //  TODO TO INSTALL MODULE: Also comment out, or better, delete the following 2 lines below:
  7. import void VerboseAction(Critter& cr, string& text) from "utils";
  8. import void VerboseAction(Critter& cr, Critter& target, string& text) from "utils";
  9. //  These 2 lines (above) are included in the utils_h.fos, so their import will be no longer needed.
  10.  
  11. ...
  12. void UseDrug(Critter& cr, Item& drug)   // Export
  13. {
  14.     uint pid = drug.GetProtoId();
  15.     SetDrug(cr, pid);
  16.     _SubItem(drug, 1);
  17.     //  TODO TO INSTALL MODULE: Replace starts here, only the empty hypo needle randomization stays, everything else is not needed.
  18.     if (pid == PID_STIMPAK || pid == PID_SUPER_STIMPAK)
  19.     {
  20.         //  A floating text about heal amount will be displayed after heal amount calculation.
  21.         if(cr.GetMapProtoId() != MAP_Arena)
  22.         {
  23.             if(Random(0, 1) == 0)
  24.                 cr.AddItem(PID_HYPODERMIC_NEEDLE, 1);
  25.         }
  26.     }
  27.     //  Replace ends here, the code below is the original.
  28.     else if(pid == PID_CIGARETTES)
  29.     {
  30.         VerboseAction(cr, "lights a cigarette");
  31.         cr.PlaySound("smoking.ogg", true);
  32.     }
  33. ...
  34.     else if(pid == PID_JET_ANTIDOTE)
  35.         VerboseAction(cr, "drinks drug antidote");
  36.  
  37.     // adventurers
  38.     //  Here the old healing powder text is deleted including the whole if else line..
  39.     else if(pid == PID_RAD_X)
  40.         VerboseAction(cr, "swallows rad-x");
  41. ....
  42. //IN FUCNTION: void UseDrugOn(Critter& cr, Critter& onCr, Item& drug)
  43. ....
  44.         _SubItem(drug, 1);
  45.         //  TODO TO INSTALL MODULE: Replace starts here, removed stuff for stimpack
  46.         if (pid == PID_STIMPAK || pid == PID_SUPER_STIMPAK)
  47.         {
  48.             if(cr.GetMapProtoId() != MAP_Arena)
  49.             {
  50.                 if(Random(0, 1) == 0)
  51.                     cr.AddItem(PID_HYPODERMIC_NEEDLE, 1);
  52.             }
  53.         }
  54.         //  replace ends here  
  55.         else if(pid == PID_RAD_X)
  56.             VerboseAction(cr, onCr, "uses rad-x on TARGET");
  57. ....
  58. //IN FUNCTION: uint ProcessDrug(Critter& cr, uint16 drugPid, uint& rate)
  59. ....
  60.                 else if(stat == ST_CURRENT_HP)
  61.                 {
  62.                     if(amount > 0 && cr.Trait[TRAIT_CHEM_RESISTANT] != 0)
  63.                         amount /= 2;
  64.                     //  TODO TO INSTALL MODULE: replace starts here: we calc the healed amount and use it a little bit later
  65.                     int healAmount = MIN(amount, cr.Stat[ST_MAX_LIFE] - cr.Stat[ST_CURRENT_HP]);
  66.                     cr.StatBase[ST_CURRENT_HP] = CLAMP(statVal + amount, -9999, cr.Stat[ST_MAX_LIFE]);
  67.                     if(amount < 0 && cr.Stat[ST_CURRENT_HP] < 0)
  68.                         cr.ToDead(Random(0, 1) == 0 ? ANIM2_DEAD_FRONT : ANIM2_DEAD_BACK, null);      // buggy, make macro for safety
  69.                     //  Show heal amount above head, but do not show 0 HP ticks form drugs. (Super Stimpacks)
  70.                     if (healAmount != 0)
  71.                     {
  72.                         FloatingHealTextByDrugPid(cr, healAmount, drugPid);
  73.                     }
  74.                     //  replace ends here: the code below is form original
  75.                 }
  76.                 else if(stat == ST_POISONING_LEVEL)
  77.                     AffectPoison(cr, amount);                                                         //
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement