Advertisement
Guest User

nwn2 examine info script

a guest
Mar 23rd, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 5.12 KB | None | 0 0
  1. // 'gui_kl_updaterep'
  2. //
  3. // kevL's, 11.03.04
  4. // 12.04.27 - changed GetDistanceToObject() to GetDistanceBetween(), since
  5. //            the former was always using distance to mainPC instead of !ControlledChar.
  6. // 12.05.04 - GetDistanceBetween() thinks items in Inventory are in SE corner of map ...
  7. //            add explicit check to see if it's an inventory item.
  8. //          - changed all strings into constants.
  9.  
  10.  
  11. const string c_GREEN       = "<c=forestgreen>";
  12. const string c_DRED        = "<c=darkred>";
  13. const string c_BROWN       = "<c=saddlebrown>";
  14. const string c_DGREY       = "<c=#303030>";
  15.  
  16. const string c_PINK        = "<c=pink>";
  17. const string c_RED         = "<c=red>";
  18. const string c_SIENNA      = "<c=sienna>";
  19. const string c_OLIVE       = "<c=olive>";
  20. const string c_YELLOW      = "<c=yellow>";
  21. const string c_WHITE       = "<c=white>";
  22.  
  23. const string c_PERU        = "<c=peru>";
  24. const string c_DBLUE       = "<c=darkslateblue>";
  25. const string c_BISQUE      = "<c=bisque>";
  26.  
  27. const string c_END         = "</c>";
  28.  
  29. const string c_FRIENDLY    = "Friendly";
  30. const string c_HOSTILE     = "Hostile";
  31. const string c_NEUTRAL     = "Neutral";
  32.  
  33. const string c_SPACE       = " ";
  34. const string c_HP          = "hp";
  35. const string c_PERSONAL    = "Personal";
  36. const string c_CORPSE      = "Corpse";
  37. const string c_INVENTORY   = "Inventory";
  38. const string c_PARTY       = "Party";
  39. const string c_STORE       = "Store";
  40. const string c_M           = "m";
  41.  
  42. const string c_GUI_EXAMINE = "SCREEN_EXAMINE";
  43. const string c_kL_REP      = "kL_REPUTATION_INFO";
  44. const string c_kL_RANGE    = "kL_RANGE_INFO";
  45. const string c_kL_HITPOINT = "kL_HITPOINT_INFO";
  46.  
  47.  
  48. void main()
  49. {
  50.     object oPC = GetControlledCharacter(OBJECT_SELF);
  51.  
  52.     string sRep, sText, sPoint;
  53.  
  54.     if (!GetIsOverlandMap(GetArea(oPC)))
  55.     {
  56.         object oTarget = GetPlayerCurrentTarget(oPC);
  57.         if (GetIsObjectValid(oTarget))
  58.         {
  59.             string sColor;
  60.  
  61.             // determine reputation and hitpoints
  62.             if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
  63.             {
  64.                 int iRep;
  65.  
  66.                 int bPcParty = GetFactionEqual(oTarget, oPC);
  67.                 if (bPcParty)
  68.                 {
  69.                     iRep = 100;
  70.                 }
  71.                 else
  72.                 {
  73.                     iRep = GetReputation(oTarget, oPC);
  74.                 }
  75.  
  76.                 sRep = c_END + c_SPACE + c_DGREY + IntToString(iRep) + c_END;
  77.  
  78.                 if      (bPcParty || GetIsFriend(oTarget, oPC)) sRep = c_GREEN + c_FRIENDLY + sRep;
  79.                 else if (GetIsNeutral(oTarget, oPC))            sRep = c_BROWN + c_NEUTRAL  + sRep;
  80.                 else if (GetIsEnemy(oTarget, oPC))              sRep = c_DRED  + c_HOSTILE  + sRep;
  81.  
  82.                 int   iPoint = GetCurrentHitPoints(oTarget);
  83.                 float fPoint = IntToFloat(iPoint);
  84.                 if (fPoint < 0.f) fPoint = 0.f;
  85.  
  86.                 int   iPointTop = GetMaxHitPoints(oTarget);
  87.                 float fPointTop = IntToFloat(iPointTop);
  88.  
  89.                 float fRatio = fPoint / fPointTop;
  90.                 if      (fRatio <= 0.00f) sColor = c_PINK; // see Damagelevels.2da
  91.                 else if (fRatio <= 0.25f) sColor = c_RED;
  92.                 else if (fRatio <= 0.45f) sColor = c_SIENNA;
  93.                 else if (fRatio <= 0.76f) sColor = c_OLIVE;
  94.                 else if (fRatio <= 0.93f) sColor = c_YELLOW;
  95.                 else                      sColor = c_WHITE;
  96.  
  97.                 sPoint = sColor + IntToString(iPoint) + c_END + c_SPACE + c_DGREY + c_HP + c_END;
  98.             }
  99.  
  100.             // determine range and location
  101.             object oPossessor = GetItemPossessor(oTarget);
  102.             if (GetIsObjectValid(oPossessor))
  103.             {
  104.                 string sPossessor;
  105.                 int iType = GetObjectType(oPossessor);
  106.  
  107.                 if      (oPC == oPossessor)                sPossessor = c_PERSONAL;
  108.                 else if (iType == OBJECT_TYPE_CREATURE
  109.                       && GetIsDead(oPossessor))            sPossessor = c_CORPSE;
  110.                 else if (iType == OBJECT_TYPE_PLACEABLE)   sPossessor = c_INVENTORY;
  111.                 else if (GetFactionEqual(oPossessor, oPC)) sPossessor = c_PARTY;
  112.                 else                                       sPossessor = c_STORE;
  113.  
  114.                 sText = c_PERU + sPossessor + c_END;
  115.             }
  116.             else
  117.             {
  118.                 float  fRange = GetDistanceBetween(oTarget, oPC);
  119.                 string sRange = FloatToString(fRange, 3, 1);
  120.  
  121.                 if      (fRange <= 10.f) sColor = c_DRED;
  122.                 else if (fRange <= 20.f) sColor = c_BROWN;
  123.                 else if (fRange <= 40.f) sColor = c_GREEN;
  124.                 else if (fRange <  50.f) sColor = c_DBLUE;
  125.                 else                     sColor = c_BISQUE;
  126.  
  127.                 sText = sColor + sRange + c_SPACE + c_M + c_END;
  128.             }
  129.         }
  130.     }
  131.  
  132.     SetGUIObjectText(oPC, c_GUI_EXAMINE, c_kL_REP,      -1, sRep);
  133.     SetGUIObjectText(oPC, c_GUI_EXAMINE, c_kL_RANGE,    -1, sText);
  134.     SetGUIObjectText(oPC, c_GUI_EXAMINE, c_kL_HITPOINT, -1, sPoint);
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement