Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 'gui_kl_updaterep'
- //
- // kevL's, 11.03.04
- // 12.04.27 - changed GetDistanceToObject() to GetDistanceBetween(), since
- // the former was always using distance to mainPC instead of !ControlledChar.
- // 12.05.04 - GetDistanceBetween() thinks items in Inventory are in SE corner of map ...
- // add explicit check to see if it's an inventory item.
- // - changed all strings into constants.
- const string c_GREEN = "<c=forestgreen>";
- const string c_DRED = "<c=darkred>";
- const string c_BROWN = "<c=saddlebrown>";
- const string c_DGREY = "<c=#303030>";
- const string c_PINK = "<c=pink>";
- const string c_RED = "<c=red>";
- const string c_SIENNA = "<c=sienna>";
- const string c_OLIVE = "<c=olive>";
- const string c_YELLOW = "<c=yellow>";
- const string c_WHITE = "<c=white>";
- const string c_PERU = "<c=peru>";
- const string c_DBLUE = "<c=darkslateblue>";
- const string c_BISQUE = "<c=bisque>";
- const string c_END = "</c>";
- const string c_FRIENDLY = "Friendly";
- const string c_HOSTILE = "Hostile";
- const string c_NEUTRAL = "Neutral";
- const string c_SPACE = " ";
- const string c_HP = "hp";
- const string c_PERSONAL = "Personal";
- const string c_CORPSE = "Corpse";
- const string c_INVENTORY = "Inventory";
- const string c_PARTY = "Party";
- const string c_STORE = "Store";
- const string c_M = "m";
- const string c_GUI_EXAMINE = "SCREEN_EXAMINE";
- const string c_kL_REP = "kL_REPUTATION_INFO";
- const string c_kL_RANGE = "kL_RANGE_INFO";
- const string c_kL_HITPOINT = "kL_HITPOINT_INFO";
- void main()
- {
- object oPC = GetControlledCharacter(OBJECT_SELF);
- string sRep, sText, sPoint;
- if (!GetIsOverlandMap(GetArea(oPC)))
- {
- object oTarget = GetPlayerCurrentTarget(oPC);
- if (GetIsObjectValid(oTarget))
- {
- string sColor;
- // determine reputation and hitpoints
- if (GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
- {
- int iRep;
- int bPcParty = GetFactionEqual(oTarget, oPC);
- if (bPcParty)
- {
- iRep = 100;
- }
- else
- {
- iRep = GetReputation(oTarget, oPC);
- }
- sRep = c_END + c_SPACE + c_DGREY + IntToString(iRep) + c_END;
- if (bPcParty || GetIsFriend(oTarget, oPC)) sRep = c_GREEN + c_FRIENDLY + sRep;
- else if (GetIsNeutral(oTarget, oPC)) sRep = c_BROWN + c_NEUTRAL + sRep;
- else if (GetIsEnemy(oTarget, oPC)) sRep = c_DRED + c_HOSTILE + sRep;
- int iPoint = GetCurrentHitPoints(oTarget);
- float fPoint = IntToFloat(iPoint);
- if (fPoint < 0.f) fPoint = 0.f;
- int iPointTop = GetMaxHitPoints(oTarget);
- float fPointTop = IntToFloat(iPointTop);
- float fRatio = fPoint / fPointTop;
- if (fRatio <= 0.00f) sColor = c_PINK; // see Damagelevels.2da
- else if (fRatio <= 0.25f) sColor = c_RED;
- else if (fRatio <= 0.45f) sColor = c_SIENNA;
- else if (fRatio <= 0.76f) sColor = c_OLIVE;
- else if (fRatio <= 0.93f) sColor = c_YELLOW;
- else sColor = c_WHITE;
- sPoint = sColor + IntToString(iPoint) + c_END + c_SPACE + c_DGREY + c_HP + c_END;
- }
- // determine range and location
- object oPossessor = GetItemPossessor(oTarget);
- if (GetIsObjectValid(oPossessor))
- {
- string sPossessor;
- int iType = GetObjectType(oPossessor);
- if (oPC == oPossessor) sPossessor = c_PERSONAL;
- else if (iType == OBJECT_TYPE_CREATURE
- && GetIsDead(oPossessor)) sPossessor = c_CORPSE;
- else if (iType == OBJECT_TYPE_PLACEABLE) sPossessor = c_INVENTORY;
- else if (GetFactionEqual(oPossessor, oPC)) sPossessor = c_PARTY;
- else sPossessor = c_STORE;
- sText = c_PERU + sPossessor + c_END;
- }
- else
- {
- float fRange = GetDistanceBetween(oTarget, oPC);
- string sRange = FloatToString(fRange, 3, 1);
- if (fRange <= 10.f) sColor = c_DRED;
- else if (fRange <= 20.f) sColor = c_BROWN;
- else if (fRange <= 40.f) sColor = c_GREEN;
- else if (fRange < 50.f) sColor = c_DBLUE;
- else sColor = c_BISQUE;
- sText = sColor + sRange + c_SPACE + c_M + c_END;
- }
- }
- }
- SetGUIObjectText(oPC, c_GUI_EXAMINE, c_kL_REP, -1, sRep);
- SetGUIObjectText(oPC, c_GUI_EXAMINE, c_kL_RANGE, -1, sText);
- SetGUIObjectText(oPC, c_GUI_EXAMINE, c_kL_HITPOINT, -1, sPoint);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement