Created
July 24, 2016 00:09
-
-
Save anonymous/070135a16749a21b70994cb5148e99cf 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
#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 ShowNpcNames = false; | |
void InitCritterInfo() // import | |
{ | |
CritterInfoOverMouse MouseMove; | |
GUI_AddScreenElement( CLIENT_MAIN_SCREEN_GAME ) | |
.CallbackMouseMove( MouseMove ); | |
} | |
bool ToggleHealthInfo() // import | |
{ | |
return ShowHealthInfo = !ShowHealthInfo; | |
} | |
bool ToggleNpcNames() // import | |
{ | |
return ShowNpcNames = !ShowNpcNames; | |
} | |
bool IsChosenAware() | |
{ | |
CritterCl@ chosen = GetChosen(); | |
if( !valid(chosen) ) | |
return false; | |
return chosen.Perk[PE_AWARENESS] != 0; | |
} | |
void UpdateInfoOnHeads() { // import | |
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, IsChosenAware() ); | |
} | |
} | |
void UpdateInfoOnHead( CritterCl@ critter ) { // import | |
GetOnHeadStr( critter, IsChosenAware() ); | |
} | |
void CritterHealthActivity( CritterCl& critter, uint, int ) { // called by Parameters behaviour change | |
GetOnHeadStr( critter, IsChosenAware()); | |
} | |
void GetOnHeadStr(CritterCl@ critter, bool awareness) { | |
if ( critter.IsPlayer() ) { | |
if( _IsAdmin( critter.Name ) ) { | |
critter.NameOnHead = "|" + COLOR_RED + " [GM]\n" + "|" + COLOR_CRITTER_NAME + " " + critter.Name; | |
} | |
else | |
critter.NameOnHead = "|" + COLOR_CRITTER_NAME + " " + critter.Name; | |
//if( critter.Param[INCOGNITO] != 0 ) //name is visible only if critter is not in incognito mode | |
// critter.NameOnHead = ""; | |
} | |
if ( critter.IsNpc() ) { | |
critter.NameOnHead = ShowNpcNames ? "|" + 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.NameOnHead = ""; | |
} | |
} | |
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() && !ShowNpcNames || critter.IsPlayer() && !__ShowPlayerNames) | |
{ | |
uint color = 0; | |
if( critter.IsNpc() ) { | |
color = COLOR_YELLOW; | |
str += "|"+color + " " + GetMsgStr( TEXTMSG_DLG, STR_NPC_PROTO_NAME(critter.Pid) ); | |
} | |
else { | |
uint color = critter.IsChosen() ? COLOR_WHITE : COLOR_LGRAY; | |
str += "|"+color + " " + critter.Name; | |
} | |
// 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; | |
// } | |
} | |
// 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
import void InitCritterInfo() from "client_critter_info"; | |
import bool ToggleHealthInfo() 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 UpdateInfoOnHeads() 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) { // This is handled internaly... you don't need it. | |
// Message("ShowPlayerNames: " + (TogglePlayerNames() ? "on" : "off")); | |
// CrittersUpdate(); | |
// } | |
if(key == DIK_F7) { // the purpose of this is to let the player find the critter he needs to talk easily. | |
Message("ShowNpcNames: " + (ToggleNpcNames() ? "on" : "off")); | |
UpdateInfoOnHeads(); | |
} | |
if(key == DIK_F9) { | |
Message("ShowHealthInfo: " + (ToggleHealthInfo() ? "on" : "off")); | |
UpdateInfoOnHeads(); | |
} | |
} | |
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 UpdateInfoOnHead( CritterCl@ critter ) from "client_critter_info"; | |
// ////////////////////////////////////////////////////////////////////////////////////////////////// | |
// Called on something critter in/out game. | |
void critter_in( CritterCl& cr ) | |
{ | |
// add this into critter_in() | |
UpdateInfoOnHead(cr); | |
} | |
void combat_result( uint[]& data ) | |
{ | |
// at beginning of the func look for this "!self" statement... | |
// and replace the bottom lines "if and else..." | |
// or you wont have the critter name shown in the console... | |
if( valid( cr ) ) | |
{ | |
if( !self ) { | |
if ( cr.IsPlayer() ) | |
name = cr.Name; | |
else | |
name = GetMsgStr( TEXTMSG_DLG, STR_NPC_PROTO_NAME(cr.Pid) ); | |
} | |
} | |
} |
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