Changeset 446 for Daodan/src


Ignore:
Timestamp:
Jul 20, 2009, 4:06:23 AM (15 years ago)
Author:
gumby
Message:
 
Location:
Daodan/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Daodan/src/BFW_Utility.h

    r437 r446  
    1414void    ONICALL UUrPlatform_Terminate();
    1515
     16typedef struct {
     17        int16_t Top;
     18        int16_t Left;
     19        int16_t Right;
     20        int16_t Bottom;
     21} OniRectangle;
     22
     23
     24void* TestContext;
    1625void ONICALL COrTextArea_Print(uint32_t area, uint32_t priority, uint32_t textshade, uint32_t textshadowshade, const char* text, uint32_t unk_alwaws_0, uint32_t fadetime);
     26int16_t ONICALL TSrContext_DrawText(uint32_t TSrContext, char* Text, int alpha, uint32_t usuallyzero, OniRectangle* pRect);
     27int16_t ONICALL TSrContext_New( void* FontInstance, int size, int hthsik1,int hthsik2,int hthsik3, void* TSrContext); //int16_t TSrContext_New( TSFF*, size 7, ??? 1, ??? 1, ??? 0, TSrContext*);
     28int16_t ONICALL TMrInstance_GetDataPtr(int, char*, void*);      //int TMrInstance_GetDataPtr( Type 'TSFF', char* "Tahoma", ptr);
    1729
    1830int __cdecl AUrMessageBox(int Buttons, char *Message, ...);
  • Daodan/src/Daodan_BSL.c

    r445 r446  
    1010#include "Oni_Character.h"
    1111#include "dSFMT\dSFMT.h"
     12#include "Daodan_Character.h"
    1213
    1314uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     
    9293        int index;
    9394        if (numargs == 0) index = 0;
     95        else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
    9496        else index = args[0].value_int32;
    9597        int* killcount = ONgGameState + index * 0x16A0 + 0x1260 + 0x1670;
     
    103105        int index;
    104106        if (numargs == 0) index = 0;
     107        else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
    105108        else index = args[0].value_int32;
    106109        int* killcount = ONgGameState + index * 0x16A0 + 0x1260 + 0x1674;
    107110        ret->value_int32 = *killcount;
    108111        ret->type = sl_int32;
     112        return 0;
     113}
     114
     115uint16_t ONICALL bsl_powerup(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     116{
     117        char powerup_list[7][16] = {"ammo", "cell", "hypo", "shield", "invis" , "lsi", "bossshield"};
     118        int powerup_offset[7] = {    0xE,    0x12,   0x10,   0x24,     0x26,     0x20,  -1};
     119        char powerup_type[16] = "\0";
     120        int index;
     121        if (numargs < 2 || args[1].type != sl_str32) return 1;
     122        else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
     123        else index = args[0].value_int32;
     124        int i;
     125       
     126        for(i = 0; i < 6; i++)
     127        {
     128                if(!strcmp(args[1].value_str32,powerup_list[i]))
     129                {
     130                        sprintf(powerup_type,"%s",powerup_list[i]);
     131                                break;
     132                }
     133        }
     134       
     135        //todo, add setting
     136       
     137        if (powerup_type[0] == 0) return 1;
     138        Character* Chr = ONgGameState + 0x1260;
     139        void* returnval = &(Chr[index]) + 0x194 + powerup_offset[i];
     140        //*returnval = (int)Inv
     141        if (numargs >= 2)
     142        {
     143                //*health = args[1].value_int32;
     144        }
     145        ret->value_int32 = (int)*(uint16_t*)returnval;
     146        ret->type = sl_int32;
     147        return 0;
     148}
     149
     150uint16_t ONICALL bsl_health(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     151{
     152        int index;
     153        if (numargs == 0) index = 0;
     154        else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
     155        else index = args[0].value_int32;
     156        Character* Chr = ONgGameState + 0x1260 ;
     157        int* health = &Chr[index].Health;
     158
     159        ret->value_int32 = *health;
     160        ret->type = sl_int32;
     161
     162        if (numargs >= 2) {
     163                *health = args[1].value_int32;
     164        }
     165        ret->value_int32 = *health;
     166        ret->type = sl_int32;
     167        return 0;
     168}
     169
     170uint16_t ONICALL bsl_maxhealth(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     171{
     172        int index;
     173        if (numargs == 0) index = 0;
     174        else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
     175        else index = args[0].value_int32;
     176        Character* Chr = ONgGameState + 0x1260 ;
     177        int* maxhealth = &Chr[index].MaxHealth;
     178        int oldmaxhealth = Chr[index].MaxHealth;
     179        int oldhealth = Chr->Health;
     180        if (numargs >= 2) {
     181                *maxhealth = args[1].value_int32;
     182        }
     183        if (numargs >= 3 && args[2].value_bool) {
     184                Chr->Health = (int)(((float)args[1].value_int32 / (float)oldmaxhealth) * (float)oldhealth);
     185        }
     186        ret->value_int32 = oldmaxhealth;
     187        ret->type = sl_int32;
     188        return 0;
     189}
     190
     191uint16_t ONICALL bsl_getattacker(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     192{
     193        //broken...not only does it sometimes blam, but it returns a string when i want an int so i can study it :<
     194        int index;
     195        if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
     196        else index = args[0].value_int32;
     197       
     198
     199        if(ONrGetActiveCharacter(ONgGameState + 0x1260 + index * 0x16A0)) return 1;
     200
     201        int attacker= (int)(ONrGetActiveCharacter(ONgGameState + 0x1260 + index * 0x16A0) + 0x120);
     202        ret->type = sl_int32;
     203        ret->value_int32 = attacker;
     204        return 0;
     205}
     206
     207
     208uint16_t ONICALL bsl_chrname(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     209{
     210        int index;
     211        if (numargs == 0) index = 0;
     212        else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
     213        else index = args[0].value_int32;
     214        if (index == -1) {
     215                ret->type = sl_str32;
     216                ret->value_str32 = "NULL";
     217                return 0;
     218        }
     219        char* name = ONgGameState + 0x1260  + index * 0x16A0 + 0x14;
     220        if (numargs == 2) {
     221                strncpy(name, (char*)args[1].value_str32, 31);
     222        }
     223       
     224        ret->type = sl_str32;
     225        ret->value_str32 = name;
     226       
     227        return 0;
     228}
     229
     230
     231uint16_t ONICALL bsl_count(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     232{
     233        //testing numargs...
     234        ret->type = sl_int32;
     235        ret->value_int32 = numargs;
     236        return 0;
     237}
     238
     239uint16_t ONICALL bsl_dprintcolored(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     240{
     241        //TODO: figure out why our implementation of dprint shows after dev mode is turned off
     242        RGBA color;
     243        RGBA shade;
     244       
     245        if(numargs == 0) return 0;
     246        if(numargs > 1 ) color.R = (char)args[1].value_int32;
     247        else color.R = 255;
     248        if(numargs > 2 ) color.G = (char)args[2].value_int32;
     249        else color.G = 255;
     250        if(numargs > 3 ) color.B = (char)args[3].value_int32;
     251        else color.B = 255;
     252        color.A = 0;
     253        if(numargs > 5 ) shade.R = (char)args[5].value_int32;
     254        else shade.R = 0x3F;
     255        if(numargs > 6 ) shade.G = (char)args[6].value_int32;
     256        else shade.G = 0x3F;
     257        if(numargs > 7 ) shade.B = (char)args[7].value_int32;
     258        else shade.B = 0x3F;
     259        shade.A = 0;
     260
     261        DDrConsole_PrintColored(args[0].value_str32, 1, color, shade);
     262        return 0;
     263}
     264
     265
     266uint16_t ONICALL bsl_nametoindex(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     267{
     268        ret->type = sl_int32;
     269        ret->value_int32 = DDrGetCharacterIndexFromName(args[0].value_str32);
    109270        return 0;
    110271}
     
    193354        SLrScript_Command_Register_ReturnType("int32rand", "Returns a pseudo-random number between two numbers (inclusive).", "start:int end:int", sl_int32, bsl_int32rand);
    194355       
    195         SLrScript_Command_Register_ReturnType("chr_getkills","Gets the number of kills a character has", "[chrindex:int]", sl_int32, bsl_getkills);
    196         SLrScript_Command_Register_ReturnType("chr_getdamage","Gets the amount of damage a character has caused", "[chrindex:int]", sl_int32, bsl_getdamage);
     356        SLrScript_Command_Register_ReturnType("d_getkills","Gets the number of kills a character has", "[ai_name:str | script_id:int]", sl_int32, bsl_getkills);
     357        SLrScript_Command_Register_ReturnType("d_getdamage","Gets the amount of damage a character has caused", "[ai_name:string | script_id:int]", sl_int32, bsl_getdamage);
     358        SLrScript_Command_Register_ReturnType("d_name","Gets or sets a character's name", "[ai_name:str | script_id:int] [newname:string]", sl_str32, bsl_chrname);
     359        SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "script_id:int", sl_int32, bsl_nametoindex);
     360        SLrScript_Command_Register_ReturnType("d_health","Gets or sets a character's health", "[ai_name:str | script_id:int] [newhealth:int]", sl_str32, bsl_health);
     361        SLrScript_Command_Register_ReturnType("d_maxhealth","Gets or sets a character's maximum health", "[ai_name:str | script_id:int] [newmaxhealth:int] [scalehealth:bool]", sl_str32, bsl_maxhealth);
     362        SLrScript_Command_Register_ReturnType("d_powerup","Gets or sets a character's powerups", "ai_name:str|script_id:int powerup:str", sl_int32, bsl_powerup);
     363        //broken. sometimes crashes, and sometimes returns a string... : /
     364        SLrScript_Command_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_chrname);
    197365       
    198366        SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf);
    199 }
     367
     368        SLrScript_Command_Register_ReturnType("dprintcolor", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored);
     369}
  • Daodan/src/Daodan_Character.c

    r434 r446  
    22#include "Daodan_Character.h"
    33#include "Oni_Character.h"
     4#include "BFW_Utility.h"
     5#include "Oni.h"
    46
    57int DDr_TeamToTeamID(const char* team_string) //Already something like this in the engine, but I'm reimplementing it...
     
    1618}
    1719
     20uint32_t DDrGetCharacterIndexFromName(char* input) {
     21        Character **characterlist;                                                              //pointer to array of Character pointers
     22        characterlist = ONgGameState + 0x00167500;                              //Character List
     23        int* total_characters = ONgGameState + 0x00167700;              //Max number of characters
     24        int i;
     25        for(i = 0; i < *total_characters; i++) {
     26                if (characterlist[i] != 0)                                                      //anti Blam!
     27                        if (!strcmp(characterlist[i]->Name, input)) {   //checks for the same name
     28                        return characterlist[i]->Number;
     29                        }
     30        }
     31return -1;                                                                                                      //not found :(
     32}
     33
     34OniRectangle TestRect;
    1835void CHARTest()
    1936{
     37       
    2038        CharacterObject* TestCHAR = malloc(sizeof(CharacterObject));
    2139        memset(TestCHAR, 0, sizeof(CharacterObject));
     
    2543        memcpy(TestCHAR->OSD.Name, "Gumby", 6);
    2644        memcpy(TestCHAR->OSD.Class, "striker_easy_1", 15);
    27         memcpy(TestCHAR->OSD.ScriptSpawn, "dmsg", 20);
    28         TestCHAR->OSD.Options = chr_unkillable;
     45        memcpy(TestCHAR->OSD.ScriptSpawn, "dmsg", 20); 
     46        //TestCHAR->OSD.Options = chr_unkillable;
    2947        TestCHAR->OSD.TeamID = team_syndicate;
     48        //int* ptr = 0x005ECE70;
     49        TestRect.Top = 10;
     50        TestRect.Left = 10;
     51        TestRect.Right = 100;
     52        TestRect.Bottom = 100;
    3053       
    31 
    32         ONrGameState_NewCharacter(TestCHAR, NULL, NULL, NULL);
     54        char str[5] = "hi";
     55        str[2] = '\0';
     56        AUrMessageBox(0, "%8x", &TestRect);
     57        int16_t a = TSrContext_DrawText(TestContext, str, 0xFF, &TestRect, &TestRect);
     58        //ONrGameState_NewCharacter(TestCHAR, NULL, NULL, NULL);
     59        return;
    3360}
  • Daodan/src/Daodan_Character.h

    r429 r446  
    88int DDr_TeamToTeamID(const char* team_string);
    99void CHARTest();
    10 
     10uint32_t DDrGetCharacterIndexFromName(char* );
    1111#endif
  • Daodan/src/Daodan_Console.c

    r437 r446  
    99{
    1010        COrTextArea_Print(COgConsoleLines, 1, COgDefaultTextShade, COgDefaultTextShadow, text, 0, COgFadeTimeValue);
     11}
     12
     13void DDrConsole_PrintColored(const char* text, int priority, RGBA color, RGBA shade)
     14{
     15        int* intcolor = (int*)&color;
     16        int* intshade = (int*)&shade;
     17        COrTextArea_Print(COgConsoleLines, 1, *intcolor, *intshade, text, 0, COgFadeTimeValue);
    1118}
    1219
  • Daodan/src/Daodan_Console.h

    r437 r446  
    77#include "Daodan.h"
    88
     9typedef struct {
     10char B;
     11char G;
     12char R;
     13char A;
     14} RGBA;
     15
    916void DDrConsole_Print(const char* text);
     17void DDrConsole_PrintColored(const char* text, int priority, RGBA color, RGBA shade);
    1018void DDrConsole_PrintF(const char* fmt, ...);
    1119
  • Daodan/src/Oni_Character.h

    r441 r446  
    211211        int16_t ShieldUsed;                             //Bullet shield given for the char to use
    212212        int16_t CloakUsed;                              //Phase Cloak given for the char to use
    213         int16_t field_28;                       //probably bullet shield dropped
    214         int16_t DoorKeys;               //Lol. We can use this later for other sorts of items.
     213        int32_t field_28;                       //probably bullet shield dropped
     214        int32_t DoorKeys;               //Lol. We can use this later for other sorts of items.
    215215} Inventory;
    216216
     
    432432} ActiveCharacter;
    433433
    434 
     434//This struct is good.
    435435typedef struct { //Character
    436         int16_t Number;
     436        char Number;
     437        char field_2;
    437438        int16_t ActiveCharacterIndex;
    438439        int32_t Flags;
    439         int16_t field_8;
     440        int32_t field_8;
    440441        int32_t ONCC;                   //change type to ONCC when we get that far...
    441         int32_t field_10;
     442        int16_t field_10;
    442443        int16_t Team;
    443444        char Name[32];
     
    471472        Vector3 Velocity;
    472473        int32_t field_1D0;
    473         int32_t field_1D4;
     474        int32_t Recoil;
    474475        int32_t field_1D8;
    475476        int32_t field_1DC;
    476         int32_t field_1E0;
     477        int32_t LastNotIdleGameTime;
    477478        int32_t IdleDelay;
    478         int32_t field_1E8;
    479         int32_t field_1EzC;
     479        int32_t Type;
     480        int32_t field_1EC;
    480481        int32_t CombatFlags;
    481482        int32_t JobId;
     
    484485        int32_t field_200;
    485486        int32_t field_204;
    486         int32_t field_208[107]; //its all undocumented through here
     487        int32_t field_208[428]; //208-8B8   
    487488        int32_t CombatState;    //I think....
    488         int32_t field_8BB;
     489        int32_t field_8BC;
    489490        int32_t PatrolPathOSD[10];      //actually another struct. Not needed atm.
    490491        int32_t PatrolPathPoints[5][64]; //64 of another struct
     
    509510        int32_t PursuitWeakHigh;
    510511        int32_t Pursuit5;
    511         int32_t field_FC8[16];
     512        int32_t field_FC8[4];
    512513        int32_t AlarmGroups; //a bitset
    513         int32_t field_FDC[16]; //FDC-F68
    514         int32_t field_F68;
     514        int32_t field_FDC[17]; //FDC-1020
    515515        int32_t DazeTimer;
    516         int32_t field_1024[16]; //1024-1064
     516        int32_t field_1024[17]; //1024-1068
    517517        int32_t MeleePtr; //probably MELE. Looks somewhat important.
    518518        int32_t field_106C[270]; //106C-14A4 skipping lots of junk and a little pathfinding stuff that we might want later.
     519        int32_t MovementMode;
     520        int32_t field_14A8;
     521        int32_t field_14AC;
    519522        int32_t MovementModifiers; //hopefully sprinting, pistol, rifle, etc.
    520523        int32_t field_14B4[101]; //14B4-1648 Glossing over a few other things we don't need having to do with AI direction.
     524        BoundingBox BoundingBox_;
     525        int32_t field_1660;
    521526        int32_t BossShieldPower;        //a multiplier? or just a flag? who knows
    522527        int32_t field_1668[6];
    523528        int32_t CurrentConsoleActionMarker; //not sure.
    524         int32_t field_1684[7]; // done. hopefully i didnt screw this up somewhere.
     529        int32_t field_1684[7];
    525530} Character;
    526531
     
    552557}; //
    553558int16_t ONICALL ONrGameState_NewCharacter(CharacterObject* CHAR, void* AISA, void* flag, int* list_location);
     559int32_t* ONICALL ONrGetActiveCharacter(void* CharacterPtr);
    554560//int16_t ONICALL ONrGameState_GetPlayerCharacter();
    555561
Note: See TracChangeset for help on using the changeset viewer.