Changeset 450


Ignore:
Timestamp:
Jul 22, 2009, 8:00:30 AM (15 years ago)
Author:
gumby
Message:

Started Bink.h...I probably did it all wrong. :p
Some minor BSL stuff.

Location:
Daodan/src
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • Daodan/src/Daodan_BSL.c

    r447 r450  
    117117uint16_t ONICALL bsl_powerup(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
    118118{
    119         char powerup_list[7][16] = {"ammo", "cell", "hypo", "shield", "invis" , "lsi", "bossshield"};
    120         int powerup_offset[7] = {    0xE,    0x12,   0x10,   0x24,     0x26,     0x20,  -1};
    121         char powerup_type[16] = "\0";
    122119        int index;
    123120        if (numargs < 2 || args[1].type != sl_str32) return 1;
    124121        else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
    125122        else index = args[0].value_int32;
    126         int i;
    127        
    128         for(i = 0; i < 6; i++)
    129         {
    130                 if(!strcmp(args[1].value_str32,powerup_list[i]))
    131                 {
    132                         sprintf(powerup_type,"%s",powerup_list[i]);
    133                                 break;
     123        void* returnval;
     124        bool is_lsi = 0;
     125        Character* Chr = ONgGameState + 0x1260;
     126        if(!strcmp(args[1].value_str32,"ammo"))
     127        {
     128                returnval = &(Chr[index].Inventory_.AmmoUsed);
     129        }
     130        else if(!strcmp(args[1].value_str32,"hypo"))
     131        {
     132                returnval = &(Chr[index].Inventory_.HypoUsed);
     133        }
     134        else if(!strcmp(args[1].value_str32,"cells"))
     135        {
     136                returnval = &(Chr[index].Inventory_.CellsUsed);
     137        }
     138        else if(!strcmp(args[1].value_str32,"invis"))
     139        {
     140                returnval = &(Chr[index].Inventory_.CloakUsed);
     141        }
     142        else if(!strcmp(args[1].value_str32,"shield"))
     143        {
     144                returnval = &(Chr[index].Inventory_.ShieldUsed);
     145        }
     146        else if(!strcmp(args[1].value_str32,"lsi"))
     147        {
     148                returnval = &(Chr[index].Inventory_.hasLSI);
     149                is_lsi = 1;
     150        }
     151        else if(!strcmp(args[1].value_str32,"bossshield"))
     152        {
     153                ret->value_int32 = Chr[index].Flags & char_bossshield;
     154                ret->type = sl_int32;
     155                if (numargs >=3) {
     156                        if (Chr[index].Flags & char_bossshield) Chr[index].Flags = Chr[index].Flags & ~char_bossshield;
     157                        else Chr[index].Flags = Chr[index].Flags | char_bossshield;
    134158                }
    135         }
    136        
     159                return 0;
     160        }
     161        else return 1;
    137162        //todo, add setting
    138163       
    139         if (powerup_type[0] == 0) return 1;
    140         Character* Chr = ONgGameState + 0x1260;
    141         void* returnval = &(Chr[index]) + 0x194 + powerup_offset[i];
    142         //*returnval = (int)Inv
    143         if (numargs >= 2)
    144         {
    145                 //*health = args[1].value_int32;
    146         }
    147         ret->value_int32 = (int)*(uint16_t*)returnval;
    148         ret->type = sl_int32;
     164        if(is_lsi) ret->value_int32 = (int)*(bool*)returnval;
     165        else    ret->value_int32 = *(int*)returnval;
     166        ret->type = sl_int32;
     167
     168        if (numargs >= 3)
     169        {
     170                if(is_lsi) *(bool*)returnval = args[2].value_int32;
     171                else *(int*)returnval = args[2].value_int32;
     172        }
     173       
     174       
    149175        return 0;
    150176}
     
    195221        //broken...not only does it sometimes blam, but it returns a string when i want an int so i can study it :<
    196222        int index;
    197         if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
    198         else index = args[0].value_int32;
    199        
    200 
    201         if(ONrGetActiveCharacter(ONgGameState + 0x1260 + index * 0x16A0)) return 1;
    202 
    203         int attacker= (int)(ONrGetActiveCharacter(ONgGameState + 0x1260 + index * 0x16A0) + 0x120);
    204         ret->type = sl_int32;
    205         ret->value_int32 = attacker;
    206         return 0;
    207 }
     223        if (numargs == 0) index = 0;
     224        else    if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32);
     225        else index = args[0].value_int32;
     226       
     227        Character* Chr = ONgGameState + 0x1260;
     228        ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
     229        if ((int)Active == 0) return 1;
     230        ret->value_int32 = Active->LastDamageSourceCharacter;
     231        ret->type = sl_int32;
     232        return 0;
     233}
     234
    208235
    209236
     
    272299        return 0;
    273300}
     301
     302uint16_t ONICALL bsl_getactiveoffset(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     303{
     304        DDrConsole_PrintF("Character: 0x%x",(int)ONgGameState + 0x1260);
     305        DDrConsole_PrintF("ActiveChar: 0x%x",(int)ONrGetActiveCharacter((void*)((int)ONgGameState + 0x1260)));
     306        return 0;
     307}
    274308/*
    275309uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret)
     
    371405        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);
    372406        //broken. sometimes crashes, and sometimes returns a string... : /
    373         SLrScript_Command_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_chrname);
    374        
     407        SLrScript_Command_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker);
     408       
     409        SLrScript_Command_Register_ReturnType("d_active","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset);
     410
    375411        SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf);
    376412        SLrScript_Command_Register_ReturnType("dprintcolor", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored);
    377 }
    378 
     413
     414
     415
     416        SLrScript_Command_Register_ReturnType("d_dprint", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored);
     417}
    379418void SLrDaodan_Patch()
    380419{
    381420        DDrPatch_Int32(OniExe + 0x000f3755, (int)cinematic_start_patch);
    382421}
     422
Note: See TracChangeset for help on using the changeset viewer.