Created
July 22, 2016 14:22
-
-
Save anonymous/be154008845580219982adc33db9279a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import void InitCritterInfo() from "client_critter_info"; | |
import bool ToggleHealthInfo() from "client_critter_info"; | |
import bool TogglePlayerNames() from "client_critter_info"; | |
import bool ToggleNpcNames() from "client_critter_info"; | |
bool start() | |
{ | |
// add this into start() | |
InitCritterInfo(); | |
SetParameterChangeBehaviour( ST_CURRENT_HP, "client_critter_info@CritterHealthActivity" ); | |
SetParameterChangeBehaviour( ST_MAX_LIFE, "client_critter_info@CritterHealthActivity" ); | |
return true; | |
} | |
import void CrittersUpdate() from "client_critter_info"; | |
bool key_down( uint8 key, string& keyText ) | |
{ | |
// shortcuts available only for main game screen | |
if ( GUI_GetActiveScreen() == CLIENT_MAIN_SCREEN_GAME ) | |
{ | |
if(key == DIK_F6) { // internal handled | |
Message("ShowPlayerNames: " + (TogglePlayerNames() ? "on" : "off")); | |
CrittersUpdate(); | |
} | |
if(key == DIK_F7) { // internal handled | |
Message("ShowNpcNames: " + (ToggleNpcNames() ? "on" : "off")); | |
CrittersUpdate(); | |
} | |
if(key == DIK_F9) { | |
Message("ShowHealthInfo: " + (ToggleHealthInfo() ? "on" : "off")); | |
CrittersUpdate(); | |
} | |
} | |
return GUI_KeyDown( key, keyText ); | |
} | |
import string @GetMouseOverText() from "client_critter_info"; | |
string@ MouseOverText; | |
void render_iface( uint layer ) | |
{ | |
if( layer == 2 ) | |
{ | |
GUI_Render( true ); | |
} | |
else if( layer == 3 ) | |
{ | |
DrawChosenTabs(); | |
GUI_Render( false ); | |
// add this into render_iface() | |
@MouseOverText = @GetMouseOverText(); | |
if(valid(MouseOverText) && GUI_GetActiveScreen() == CLIENT_MAIN_SCREEN_GAME ) | |
{ | |
string@[] lines = split(MouseOverText, "\n"); | |
DrawText(MouseOverText, __MouseX + 10, __MouseY - 10 * lines.length(), 200, lines.length() * 10, COLOR_WHITE, FONT_FALLOUT, FT_BORDERED); | |
} | |
} | |
else if( layer == 100 && __GmapActive ) {} | |
} | |
import void CritterUpdate( CritterCl@ critter ) from "client_critter_info"; | |
// ////////////////////////////////////////////////////////////////////////////////////////////////// | |
// Called on something critter in/out game. | |
void critter_in( CritterCl& cr ) | |
{ | |
// add this into critter_in() | |
CritterUpdate(cr); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef __CLIENT | |
#include "_client_defines.fos" | |
#include "client_gui_h.fos" | |
#include "_macros.fos" | |
#include "_msgstr.fos" | |
#define ADMIN_NAME "anton" | |
#define _IsAdmin # (name) ( name == ADMIN_NAME ) | |
import int GUI_GetActiveScreen() from "client_gui"; | |
string@ MouseOverText; | |
bool ShowHealthInfo = true; | |
bool ShowNpcName = false; | |
bool ShowPlayerNames = true; | |
void InitCritterInfo() // import | |
{ | |
CritterInfoOverMouse MouseMove; | |
GUI_AddScreenElement( CLIENT_MAIN_SCREEN_GAME ) | |
.CallbackMouseMove( MouseMove ); | |
} | |
bool ToggleHealthInfo() // import | |
{ | |
return ShowHealthInfo = !ShowHealthInfo; | |
} | |
bool TogglePlayerNames() // import | |
{ | |
return ShowPlayerNames = !ShowPlayerNames; | |
} | |
bool ToggleNpcNames() // import | |
{ | |
return ShowNpcName = !ShowNpcName; | |
} | |
void CrittersUpdate() { | |
CritterCl@ chosen = GetChosen(); | |
if( !valid(chosen) ) | |
return; | |
bool awareness = chosen.Perk[PE_AWARENESS] != 0; | |
CritterCl@[] critters; | |
GetCritters(0, FIND_ALL, critters); | |
if( !valid(critters) ) | |
return; | |
if( !(critters.length() > 0) ) | |
return; | |
for ( uint i = 0; i < critters.length(); i++ ) | |
{ | |
CritterCl@ critter = critters[i]; | |
if( !valid(critter) ) | |
return; | |
GetOnHeadStr( critter, awareness ); | |
} | |
} | |
void CritterUpdate( CritterCl@ critter ) { | |
CritterCl@ chosen = GetChosen(); | |
if( !valid(chosen) ) | |
return; | |
bool awareness = chosen.Perk[PE_AWARENESS] != 0; | |
GetOnHeadStr( critter, awareness ); | |
} | |
void CritterHealthActivity( CritterCl& critter, uint, int ) { | |
//Log("CRUPDATE "+critter.Id); | |
CritterCl@ chosen = GetChosen(); | |
if( !valid(chosen) ) | |
return; | |
bool awareness = chosen.Perk[PE_AWARENESS] != 0; | |
GetOnHeadStr( critter, awareness); | |
} | |
void GetOnHeadStr(CritterCl@ critter, bool awareness) | |
{ | |
if ( critter.IsPlayer() ) { | |
if( _IsAdmin( critter.Name ) ) { | |
critter.NameOnHead = "|" + COLOR_RED + " " + "[GM]\n"; | |
critter.NameOnHead += ShowPlayerNames ? "|" + COLOR_CRITTER_NAME + " " + critter.Name : ""; | |
} | |
else | |
critter.NameOnHead = ShowPlayerNames ? "|" + COLOR_CRITTER_NAME + " " + critter.Name : ""; | |
//if( critter.Param[INCOGNITO] != 0 ) //name is visible only if critter is not in incognito mode | |
// critter.NameOnHead = ""; | |
} | |
// need retreive the name from GAME TEXT... | |
if ( critter.IsNpc() ) { | |
critter.NameOnHead = ShowNpcName ? "|" + COLOR_CRITTER_NAME + " " + GetMsgStr( TEXTMSG_DLG, STR_NPC_PROTO_NAME(critter.Pid) ) : ""; | |
} | |
if( ShowHealthInfo ) { | |
if( !critter.IsDead() ) { | |
critter.NameOnHead += "\n"; | |
int hp_proc = critter.Stat[ ST_CURRENT_HP ] * 100 / critter.Stat[ ST_MAX_LIFE ]; | |
if( critter.IsDead() ) | |
critter.NameOnHead += "|" + COLOR_GRAY + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 0 ) ); | |
else if( hp_proc < 34 ) | |
critter.NameOnHead += "|" + COLOR_RED + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 1 ) ); | |
else if( hp_proc < 67 ) | |
critter.NameOnHead += "|" + COLOR_ORANGE + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 2 ) ); | |
else if( hp_proc < 100 ) | |
critter.NameOnHead += "|" + COLOR_DGREEN + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 3 ) ); | |
else { | |
// if awareness... here | |
critter.NameOnHead += "|" + COLOR_GREEN + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 4 ) ); | |
} | |
} | |
else { | |
if(!critter.IsPlayer()) { | |
critter.Name = ""; | |
} | |
} | |
} | |
return; | |
} | |
//////////////////////////////////////////////////////////////////////////////// | |
// MOUSE | |
string@ GetMouseOverText() // import | |
{ | |
return MouseOverText; | |
} | |
class CritterInfoOverMouse : IGUIElementCallbackMouseMove { | |
void OnMouseMove(int x, int y) | |
{ | |
if( GUI_GetActiveScreen() != CLIENT_MAIN_SCREEN_GAME ) | |
return; | |
CritterCl@ chosen = GetChosen(); | |
CritterCl@ critter = GetMonitorCritter(x, y); | |
if(!valid(chosen) || !valid(critter)) { | |
@MouseOverText = null; | |
return; | |
} | |
string str; | |
// works only if nothing is shown onhead | |
if(critter.IsNpc() && !ShowNpcName || critter.IsPlayer() && !ShowPlayerNames) | |
{ | |
uint color = critter.IsChosen() ? COLOR_WHITE : COLOR_LGRAY; | |
if(critter.IsNpc()) | |
color = COLOR_YELLOW; | |
// if(!critter.IsChosen() && critter.Param[PVP_TEAM] != 0) | |
// { | |
// if(valid(chosen) && chosen.Param[PVP_TEAM] != 0) | |
// color = chosen.Param[PVP_TEAM] == critter.Param[PVP_TEAM] ? COLOR_GREEN : COLOR_RED; | |
// } | |
str += "|"+color + " " + GetMsgStr( TEXTMSG_DLG, STR_NPC_PROTO_NAME(critter.Pid) ); | |
} | |
// works all the time | |
// health | |
bool awareness = chosen.Perk[PE_AWARENESS] != 0; | |
if( !ShowHealthInfo || critter.IsDead() ) { | |
str += "\n"; | |
int hp_proc = critter.Stat[ ST_CURRENT_HP ] * 100 / critter.Stat[ ST_MAX_LIFE ]; | |
if( critter.IsDead() ) | |
str += "|" + COLOR_GRAY + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 0 ) ); | |
else if( hp_proc < 34 ) | |
str += "|" + COLOR_RED + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 1 ) ); | |
else if( hp_proc < 67 ) | |
str += "|" + COLOR_ORANGE + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 2 ) ); | |
else if( hp_proc < 100 ) | |
str += "|" + COLOR_DGREEN + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 3 ) ); | |
else { | |
// if awareness... here | |
str += "|" + COLOR_GREEN + " " + GetMsgStr( TEXTMSG_GAME, STR_CRIT_LOOK_STATE( 4 ) ); | |
} | |
} | |
// gear | |
if( awareness ) { | |
ItemCl@ armor = critter.GetItem(0, SLOT_ARMOR); | |
if(valid(armor)) | |
if(armor.Lexems != "") | |
str += "\n|" + COLOR_GRAY + " " + FormatTags(GetMsgStr(TEXTMSG_ITEM, STR_ITEM_INFO(armor)), armor.Lexems); | |
else | |
str += "\n|" + COLOR_GRAY + " " + GetMsgStr(TEXTMSG_ITEM, STR_ITEM_INFO(armor)); | |
ItemCl@ item = critter.GetItem(0, SLOT_HAND1); | |
if(valid(item)) | |
if(item.Lexems != "") | |
str += "\n|" + COLOR_WHITE + " " + FormatTags(GetMsgStr(TEXTMSG_ITEM, STR_ITEM_INFO(item)), item.Lexems); | |
else | |
str += "\n|" + COLOR_WHITE + " " + GetMsgStr(TEXTMSG_ITEM, STR_ITEM_INFO(item)); | |
} | |
@MouseOverText = str; | |
} | |
} | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void InitializeGame() // Export | |
{ | |
#ifdef __CLIENT | |
__ShowPlayerNames = true; | |
__ShowNpcNames = true; | |
#endif | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ client module client_critter_info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment