Release [PC/Steam] Call of Duty Ghosts Hud Elements + A Few Functions

xCometMods

Modder
Messages
68
Reaction score
38
Points
803
So figured out hud elements for ghosts PC steam version. Since game is dead and no one got money for a gsc injector, use this thread to make host mod menu. The way the game sets text is different from other COD's and to bypass a G_LocalizedStringIndex Patch everytime you print text, I decided to use G_FindConfigstringIndex instead. First to get hudelems to work on PC it seems not sure though
Menu Base Made With This : Release - [PC/Steam] Ghosts Menu Base
C++:
/*
EXAMPLE

game_hudelem_s * Shader = AddShader(client,"white", 100, 100, 1000, 1000, 0, 0, 0, 180);
game_hudelem_s * Text = setText(client, "HHHHHHHHHHHHHHHHHHHHHHH",1,4,100,100,255,255,255,255);

*/
typedef unsigned char byte;
typedef unsigned int uint;

union color_s
{
    struct
{
    byte r, g, b, a;
};

uint rgba;
};

struct hudelem_s
{
    int type;
    float x;
    float y;
    float z;
    int targetEntNum;
    float fontScale;
    float fromFontScale;
    float fontScaleStartTime;
    float fontScaleTime;
    int font;
    int alignOrg;
    int alignScreen;
    color_s color;
    color_s fromColor;
    int fadeStartTime;
    int fadeTime;
    int label;
    int width;
    int height;
    int materialIndex;
    int fromWidth;
    int fromHeight;
    int scaleStartTime;
    int scaleTime;
    float fromX;
    float fromY;
    int fromAlignOrg;
    int fromAlignScreen;
    int moveStartTime;
    int moveTime;
    int time;
    int duration;
    float value;
    int text;
    float sort;
    color_s glowColor;
    int fxBirthTime;
    int fxLetterTime;
    int fxDecayStartTime;
    int fxDecayDuration;
    int soundID;
    int flags;
};

struct game_hudelem_s
{
    hudelem_s elem;
    int clientNum;
    int team;
    int archived;
    int currentShowInKillcam;
};

int(*G_MaterialIndex)(const char* shader) = (int(*)(const char*))0x140162320;

int(*G_FindConfigstringIndex)(const char* name, int start, int max, int create, const char* error) = (int(*)(const char*, int, int, int, const char*))0x140161F90;

game_hudelem_s*(*HudElem_Alloc)(int client, int team) = (game_hudelem_s*(*)(int, int))0x1403997E0;

game_hudelem_s* setText(int client, char* Text, int font, float fontScale, float x, float y, byte r, byte g, byte b, byte a)
{
    game_hudelem_s* Element = HudElem_Alloc(client,0);
    Element->elem.type = 0x1;
    Element->elem.alignOrg = 0;
    Element->elem.alignScreen = 0;
    Element->elem.font = font;
    Element->elem.fontScale = fontScale;
    Element->elem.x = x;
    Element->elem.y = y;
    Element->elem.color.r = r;
    Element->elem.color.g = g;
    Element->elem.color.b = b;
    Element->elem.color.a = a;
    Element->elem.sort = 1;
    Element->elem.text = G_FindConfigstringIndex(Text, 0x21D, 0x1FF, 1, "error");
    return Element;
}

game_hudelem_s* AddShader(int client,char* Shader, float x, float y, int width, int height, byte r, byte g, byte b, byte a)
{
    game_hudelem_s* element = HudElem_Alloc(client, 0);
    element->elem.type = 0x04;
    element->elem.materialIndex = G_MaterialIndex(Shader);
    element->elem.x = x;
    element->elem.y = y;
    element->elem.width = width;
    element->elem.height = height;
    element->elem.alignOrg = 0;
    element->elem.alignScreen = 0;
    element->elem.sort = 0;
    element->elem.color.r = r;
    element->elem.color.g = g;
    element->elem.color.b = b;
    element->elem.color.a = a;
    return element;
}

void ChangeGlow(game_hudelem_s* element, byte r, byte g, byte b, byte a)
{
    element->elem.glowColor.r = r;
    element->elem.glowColor.g = g;
    element->elem.glowColor.b = b;
    element->elem.glowColor.a = a;
}

void ChangeColor(game_hudelem_s* element, byte r, byte g, byte b, byte a)
{
    element->elem.color.r = r;
    element->elem.color.g = g;
    element->elem.color.b = b;
    element->elem.color.a = a;
}

void FreeHudElement(game_hudelem_s* element)
{
    ZeroMemory(element, 0xB8);
}

void ChangeFontScale(game_hudelem_s* element, float Scale)
{
    element->elem.fontScale = Scale;
}

void ChangeText(game_hudelem_s* element, const char* Text)
{
    element->elem.text = G_FindConfigstringIndex(Text, 0x21D, 0x1FF, 1, "error");
}

void ChangeMaterial(game_hudelem_s* element, const char* material)
{
    element->elem.materialIndex = G_MaterialIndex(material);
}

void MoveXY(game_hudelem_s* element, float x, float y)
{
    element->elem.x = x;
    element->elem.y = y;
}

C++:
typedef unsigned __int64 QWORD;
template<typename function_type, typename... Parameters>
function_type RPC(QWORD function_address, Parameters... args)
{
    function_type(*placeholder)(Parameters...) = (function_type(*)(Parameters...))function_address;
    return placeholder(args...);
}
C++:
void VM_Notify(unsigned int notifyListOwnerId, unsigned int stringValue, void *top) 0x14043D9B0

const char * SL_ConvertToString(unsigned int stringValue)
{
    return RPC<const char *>(0x1404317F0, stringValue);
}

unsigned int Scr_GetSelf(unsigned int threadID)
{
    return RPC<unsigned int>(0x140436F10, threadID);
}

void Scr_ConstructMessageString(int firstParmIndex, int lastParmIndex, const char *errorContext, char *string, unsigned int stringLimit)
{
    RPC<void>(0x1403CD810, firstParmIndex, lastParmIndex, errorContext, string, stringLimit);
}

void SV_SetConfigString(int ConfigString, const char * b)
{
    RPC<void>(0x140477200, ConfigString, b);
}

void Scr_SetNumParam(int A){
    write_process<int>(0x144D4B0B8 + 4, A);
}

void Scr_ClearOutParams(){
    RPC<void>(0x140438600);
}

void Scr_AddString(const char * value){
    RPC<void>(0x1404381D0, value);
}

void PlayerCMD_giveWeapon(unsigned int Player, const char * Weapon)
{
    Scr_AddString(Weapon);
    Scr_SetNumParam(1);
    RPC<void>(0x1403891F0, Player);
    Scr_ClearOutParams();
}
1654198908523.png

 
Last edited:
Top