| 116 |
|
|
| 117 |
|
uint16_t ONICALL bsl_powerup(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 118 |
|
{ |
| 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"; |
| 119 |
|
int index; |
| 120 |
|
if (numargs < 2 || args[1].type != sl_str32) return 1; |
| 121 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 122 |
|
else index = args[0].value_int32; |
| 123 |
< |
int i; |
| 124 |
< |
|
| 125 |
< |
for(i = 0; i < 6; i++) |
| 123 |
> |
void* returnval; |
| 124 |
> |
bool is_lsi = 0; |
| 125 |
> |
Character* Chr = ONgGameState + 0x1260; |
| 126 |
> |
if(!strcmp(args[1].value_str32,"ammo")) |
| 127 |
|
{ |
| 128 |
< |
if(!strcmp(args[1].value_str32,powerup_list[i])) |
| 129 |
< |
{ |
| 130 |
< |
sprintf(powerup_type,"%s",powerup_list[i]); |
| 131 |
< |
break; |
| 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; |
| 158 |
|
} |
| 159 |
+ |
return 0; |
| 160 |
|
} |
| 161 |
< |
|
| 161 |
> |
else return 1; |
| 162 |
|
//todo, add setting |
| 163 |
|
|
| 164 |
< |
if (powerup_type[0] == 0) return 1; |
| 165 |
< |
Character* Chr = ONgGameState + 0x1260; |
| 166 |
< |
void* returnval = &(Chr[index]) + 0x194 + powerup_offset[i]; |
| 167 |
< |
//*returnval = (int)Inv |
| 168 |
< |
if (numargs >= 2) |
| 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 |
< |
//*health = args[1].value_int32; |
| 170 |
> |
if(is_lsi) *(bool*)returnval = args[2].value_int32; |
| 171 |
> |
else *(int*)returnval = args[2].value_int32; |
| 172 |
|
} |
| 173 |
< |
ret->value_int32 = (int)*(uint16_t*)returnval; |
| 174 |
< |
ret->type = sl_int32; |
| 173 |
> |
|
| 174 |
> |
|
| 175 |
|
return 0; |
| 176 |
|
} |
| 177 |
|
|
| 220 |
|
{ |
| 221 |
|
//broken...not only does it sometimes blam, but it returns a string when i want an int so i can study it :< |
| 222 |
|
int index; |
| 223 |
< |
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 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 |
< |
|
| 228 |
< |
if(ONrGetActiveCharacter(ONgGameState + 0x1260 + index * 0x16A0)) return 1; |
| 229 |
< |
|
| 230 |
< |
int attacker= (int)(ONrGetActiveCharacter(ONgGameState + 0x1260 + index * 0x16A0) + 0x120); |
| 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; |
| 205 |
– |
ret->value_int32 = attacker; |
| 232 |
|
return 0; |
| 233 |
|
} |
| 234 |
|
|
| 235 |
|
|
| 236 |
+ |
|
| 237 |
|
uint16_t ONICALL bsl_chrname(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 238 |
|
{ |
| 239 |
|
int index; |
| 298 |
|
ret->value_int32 = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 299 |
|
return 0; |
| 300 |
|
} |
| 301 |
+ |
|
| 302 |
+ |
uint16_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 |
+ |
} |
| 308 |
|
/* |
| 309 |
|
uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 310 |
|
{ |
| 404 |
|
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); |
| 405 |
|
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); |
| 406 |
|
//broken. sometimes crashes, and sometimes returns a string... : / |
| 407 |
< |
SLrScript_Command_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_chrname); |
| 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 |
+ |
|
| 411 |
|
SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf); |
| 412 |
|
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 |
– |
} |
| 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 |
+ |
} |
| 418 |
|
void SLrDaodan_Patch() |
| 419 |
|
{ |
| 420 |
|
DDrPatch_Int32(OniExe + 0x000f3755, (int)cinematic_start_patch); |
| 421 |
|
} |
| 422 |
+ |
|