#include #include #include #include #include "oni_stdio.h" #include "Daodan_Utility.h" #include "BFW_Utility.h" #include "Oni.h" const double fps = 60.0; void __cdecl DDrStartupMessage(const char* fmt, ...) { va_list ap; va_start(ap, fmt); char* buffer = malloc(vsnprintf(NULL, 0, fmt, ap) + 1); vsprintf(buffer, fmt, ap); va_end(ap); if (!ONgFileStartup) if (!(ONgFileStartup = oni_fopen("startup.txt", "w"))) return; oni_fprintf(ONgFileStartup, "%s\n", buffer); free(buffer); oni_fflush(ONgFileStartup); return; } /* int64_t ONICALL DDrMachineTime_Sixtieths() { static int64_t LastTime, Time; int64_t Current; Current = LastTime + GetTickCount(); if (Current > Time) { LastTime += 1; Current += 1; } Time = Current; return (Time * 3) / 50; } */ int64_t ONICALL DDrMachineTime_Sixtieths() { static uint32_t startticks = 0; double ticks = 0; if (startticks) ticks = GetTickCount() - startticks; else startticks = GetTickCount(); return (int64_t)(ticks / 1000.0 * fps); } int64_t ONICALL DDrMachineTime_High() { // LARGE_INTEGER PerfCount; // // if (!QueryPerformanceCounter(&PerfCount)) // PerfCount.QuadPart = GetTickCount(); // // return PerfCount.QuadPart; return GetTickCount(); } double ONICALL DDrMachineTime_High_Frequency() { // LARGE_INTEGER Frequency; // // if (!QueryPerformanceFrequency(&Frequency)) return 1000.0; // return Frequency.QuadPart; } void ONICALL DDrWeapon2Message(int* weapon, void* output_ptr) { char buffer[128] = {0}; char* weapon_string = (char*)(*(weapon + 1)+0x5C); int16_t ammo = *(int16_t *)((int)weapon + 0x56); int16_t maxammo = *(int16_t *)(*(weapon + 1)+0xC0); float ratio = (float)ammo / (float)maxammo; char ammocolor = ' '; if(ratio >= .9) ammocolor = 'g'; else if (ratio >= .5) ammocolor = 'y'; else if (ratio >= .2) ammocolor = 'o'; else ammocolor = 'r'; DDrMake_Weapon_Message( weapon_string, buffer); //gets the name of the weapon and formats it...probably doesn't need to be in seperate func. sprintf(SSrMessage_Find("autoprompt_weapon"), "%s |[%s.%i/%i]|", buffer, &ammocolor, ammo, maxammo); //copies the new string to ONGS ONiGameState_FindAutoPromptMessage("weapon", output_ptr); //does what the code i replaced does. Basically tells the game to show the msg. } void ONICALL DDrMake_Weapon_Message(char* weapon_string, char* output_ptr) { char* weapon_msg = NULL; //The normal "You have recieved X" message. char weapon_name[64] = {'\0'}; //The stripped weapon name //TODO, someday: dynamically detect different keybindings. char default_msg[] = "Press [c.Q] to pick up weapon."; //default return //Find the recieved message string weapon_msg = SSrMessage_Find(weapon_string); //this probably could be reorganized if(weapon_msg) { //SSrMsgblah returns NULL if it can't find the message key memcpy(weapon_name, weapon_msg, (strstr(weapon_msg," received.") - weapon_msg )); //strips uneeded characters sprintf(output_ptr, "Press [c.Q] to pick up %s", weapon_name); } else { memcpy(output_ptr, default_msg, sizeof(default_msg)); } }