ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/src/Daodan_Utility.c
(Generate patch)

Comparing Daodan/src/Daodan_Utility.c (file contents):
Revision 380 by rossy, Sat Jul 4 03:52:36 2009 UTC vs.
Revision 476 by gumby, Tue Nov 3 10:38:47 2009 UTC

# Line 6 | Line 6
6  
7   #include "Daodan_Utility.h"
8   #include "BFW_Utility.h"
9 + #include "Oni.h"
10  
11   const double fps = 60.0;
12  
# Line 79 | Line 80 | double ONICALL DDrMachineTime_High_Frequ
80   //
81   //      if (!QueryPerformanceFrequency(&Frequency))
82                  return 1000.0;
83 <
83 >        
84   //      return Frequency.QuadPart;
85   }
86 +        
87 + void ONICALL DDrWeapon2Message(int* weapon, void* output_ptr) {
88 +        char buffer[128] = {0};
89 +        char* weapon_string = (char*)(*(weapon + 1)+0x5C);
90 +        int16_t ammo = *(int16_t *)((int)weapon + 0x56);
91 +        int16_t maxammo = *(int16_t *)(*(weapon + 1)+0xC0);
92 +        float ratio = (float)ammo / (float)maxammo;
93 +        char ammocolor = ' ';
94 +        if(ratio >= .9) ammocolor = 'g';
95 +        else if (ratio >= .5) ammocolor = 'y';
96 +        else if (ratio >= .2) ammocolor = 'o';
97 +        else ammocolor = 'r';
98 +        DDrMake_Weapon_Message( weapon_string, buffer); //gets the name of the weapon and formats it...probably doesn't need to be in seperate func.
99 +        sprintf(SSrMessage_Find("autoprompt_weapon"), "%s |[%s.%i/%i]|", buffer, &ammocolor, ammo, maxammo); //copies the new string to ONGS
100 +        ONiGameState_FindAutoPromptMessage("weapon", output_ptr);       //does what the code i replaced does. Basically tells the game to show the msg.
101 + }
102 +
103 +
104 + void ONICALL DDrMake_Weapon_Message(char* weapon_string, char* output_ptr) {
105 +        char* weapon_msg = NULL;        //The normal "You have recieved X" message.
106 +        char weapon_name[64] = {'\0'};  //The stripped weapon name
107 +        //TODO, someday: dynamically detect different keybindings.
108 +        char default_msg[] = "Press [c.Q] to pick up weapon.";  //default return
109 +        
110 +        //Find the recieved message string
111 +        weapon_msg = SSrMessage_Find(weapon_string);
112 +        //this probably could be reorganized
113 +        if(weapon_msg) {        //SSrMsgblah returns NULL if it can't find the message key
114 +                memcpy(weapon_name, weapon_msg, (strstr(weapon_msg," received.") - weapon_msg )); //strips uneeded characters
115 +                sprintf(output_ptr, "Press [c.Q] to pick up %s", weapon_name);
116 +        }
117 +        else {
118 +                memcpy(output_ptr, default_msg, sizeof(default_msg));
119 +        }
120 +        
121 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)