| 117 |
|
return 0; |
| 118 |
|
} |
| 119 |
|
|
| 120 |
+ |
uint16_t ONICALL bsl_returnoffset(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 121 |
+ |
{ |
| 122 |
+ |
//int offset = 140; |
| 123 |
+ |
//if (== 1) offset = 148; |
| 124 |
+ |
//else index = args[0].value_int32; |
| 125 |
+ |
int* killcount = ONgGameState + args[0].value_int32; |
| 126 |
+ |
ret->value_int32 = *killcount; |
| 127 |
+ |
ret->type = sl_int32; |
| 128 |
+ |
return 0; |
| 129 |
+ |
} |
| 130 |
+ |
|
| 131 |
+ |
|
| 132 |
|
uint16_t ONICALL bsl_powerup(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 133 |
|
{ |
| 134 |
|
int index; |
| 210 |
|
return 0; |
| 211 |
|
} |
| 212 |
|
|
| 213 |
+ |
uint16_t ONICALL bsl_regen(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 214 |
+ |
{ |
| 215 |
+ |
int index; |
| 216 |
+ |
if (numargs == 0) index = 0; |
| 217 |
+ |
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 218 |
+ |
else index = args[0].value_int32; |
| 219 |
+ |
Character* Chr = ONgGameState + 0x1260 ; |
| 220 |
+ |
int* health = (int*)&Chr[index] + 0x144; |
| 221 |
+ |
|
| 222 |
+ |
ret->value_int32 = *health; |
| 223 |
+ |
ret->type = sl_int32; |
| 224 |
+ |
|
| 225 |
+ |
if (numargs >= 2) { |
| 226 |
+ |
*health = args[1].value_int32; |
| 227 |
+ |
} |
| 228 |
+ |
ret->value_int32 = *health; |
| 229 |
+ |
ret->type = sl_int32; |
| 230 |
+ |
return 0; |
| 231 |
+ |
} |
| 232 |
+ |
|
| 233 |
+ |
|
| 234 |
|
uint16_t ONICALL bsl_maxhealth(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 235 |
|
{ |
| 236 |
|
int index; |
| 254 |
|
|
| 255 |
|
uint16_t ONICALL bsl_getattacker(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 256 |
|
{ |
| 257 |
< |
//broken...not only does it sometimes blam, but it returns a string when i want an int so i can study it :< |
| 257 |
> |
//broken |
| 258 |
> |
|
| 259 |
|
int index; |
| 260 |
|
if (numargs == 0) index = 0; |
| 261 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 342 |
|
DDrConsole_PrintF("ActiveChar: 0x%x",(int)ONrGetActiveCharacter((void*)((int)ONgGameState + 0x1260))); |
| 343 |
|
return 0; |
| 344 |
|
} |
| 345 |
+ |
typedef struct { |
| 346 |
+ |
char Name[16]; |
| 347 |
+ |
int Bit; |
| 348 |
+ |
} KeyBit; |
| 349 |
+ |
|
| 350 |
+ |
KeyBit Actions1[32] = { |
| 351 |
+ |
{"Escape", Action_Escape}, |
| 352 |
+ |
{"Console", Action_Console}, |
| 353 |
+ |
{"PauseScreen", Action_PauseScreen}, |
| 354 |
+ |
{"Cutscene1", Action_Cutscene_1 }, |
| 355 |
+ |
{"Cutscene2", Action_Cutscene_2 }, |
| 356 |
+ |
{"F4", Action_F4 }, |
| 357 |
+ |
{"F5", Action_F5 }, |
| 358 |
+ |
{"F6", Action_F6 }, |
| 359 |
+ |
{"F7", Action_F7 }, |
| 360 |
+ |
{"F8", Action_F8 }, |
| 361 |
+ |
{"StartRecorn", Action_StartRecord }, |
| 362 |
+ |
{"StopRecord", Action_StopRecord }, |
| 363 |
+ |
{"PlayRecord", Action_PlayRecord }, |
| 364 |
+ |
{"F12", Action_F12 }, |
| 365 |
+ |
{"Unknown1", Action_Unknown1 }, |
| 366 |
+ |
{"LookMode", Action_LookMode }, |
| 367 |
+ |
{"Screenshot", Action_Screenshot }, |
| 368 |
+ |
{"Unknown2", Action_Unknown2 }, |
| 369 |
+ |
{"Unknown3", Action_Unknown3 }, |
| 370 |
+ |
{"Unknown4", Action_Unknown4 }, |
| 371 |
+ |
{"Unknown5", Action_Unknown5 }, |
| 372 |
+ |
{"Forward", Action_Forward }, |
| 373 |
+ |
{"Backward", Action_Backward }, |
| 374 |
+ |
{"TurnLeft", Action_TurnLeft }, |
| 375 |
+ |
{"TurnRight", Action_TurnRight }, |
| 376 |
+ |
{"StepLeft", Action_StepLeft }, |
| 377 |
+ |
{"StepRight", Action_StepRight }, |
| 378 |
+ |
{"Jump", Action_Jump }, |
| 379 |
+ |
{"Crouch", Action_Crouch }, |
| 380 |
+ |
{"Punch",Action_Punch }, |
| 381 |
+ |
{"Kick", Action_Kick }, |
| 382 |
+ |
{"Block", Action_Block } |
| 383 |
+ |
}; |
| 384 |
+ |
|
| 385 |
+ |
KeyBit Actions2[9] = { |
| 386 |
+ |
{"Walk", Action2_Walk}, |
| 387 |
+ |
{"Action", Action2_Action}, |
| 388 |
+ |
{"Hypo", Action2_Hypo}, |
| 389 |
+ |
{"Reload", Action2_Reload }, |
| 390 |
+ |
{"Swap", Action2_Swap }, |
| 391 |
+ |
{"Drop", Action2_Drop }, |
| 392 |
+ |
{"Fire1", Action2_Fire1 }, |
| 393 |
+ |
{"Fire2", Action2_Fire2 }, |
| 394 |
+ |
{"Fire3", Action2_Fire3 } |
| 395 |
+ |
}; |
| 396 |
+ |
uint16_t ONICALL bsl_holdkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 397 |
+ |
{ |
| 398 |
+ |
int index; |
| 399 |
+ |
if (numargs < 4) index = 0; |
| 400 |
+ |
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 401 |
+ |
else index = args[0].value_int32; |
| 402 |
+ |
|
| 403 |
+ |
Character* Chr = ONgGameState + 0x1260; |
| 404 |
+ |
ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
| 405 |
+ |
if ((int)Active == 0) return 1; |
| 406 |
+ |
int i = 2; |
| 407 |
+ |
int j = 0; |
| 408 |
+ |
int Input1 = 0; |
| 409 |
+ |
int Input2 = 0; |
| 410 |
+ |
for(i = 1; i < numargs; i++) { |
| 411 |
+ |
for(j = 0; j < 32; j++) { |
| 412 |
+ |
if(strcmp(args[i].value_str32, Actions1[j].Name)) Input1 = Input1 | Actions1[j].Bit; |
| 413 |
+ |
DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].value_str32, Actions1[j].Name, Actions1[j].Bit); |
| 414 |
+ |
} |
| 415 |
+ |
for(j = 0; j < 9; j++) { |
| 416 |
+ |
if(!strcmp(args[i].value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit; |
| 417 |
+ |
|
| 418 |
+ |
} |
| 419 |
+ |
} |
| 420 |
+ |
for(i = 0; i < numargs; i++) { |
| 421 |
+ |
DDrConsole_PrintF("%s", args[i].value_str32); |
| 422 |
+ |
} |
| 423 |
+ |
// if |
| 424 |
+ |
return 0; |
| 425 |
+ |
} |
| 426 |
+ |
|
| 427 |
+ |
uint16_t ONICALL bsl_isheld(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 428 |
+ |
{ |
| 429 |
+ |
// int index; |
| 430 |
+ |
// if (numargs < 4) index = 0; |
| 431 |
+ |
// else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 432 |
+ |
// else index = args[0].value_int32; |
| 433 |
+ |
|
| 434 |
+ |
// Character* Chr = ONgGameState + 0x1260; |
| 435 |
+ |
// ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
| 436 |
+ |
// if ((int)Active == 0) return 1; |
| 437 |
+ |
int i = 2; |
| 438 |
+ |
int j = 0; |
| 439 |
+ |
int Input1 = 0; |
| 440 |
+ |
int Input2 = 0; |
| 441 |
+ |
for(i = 0; i < numargs; i++) { |
| 442 |
+ |
for(j = 0; j < 32; j++) { |
| 443 |
+ |
//DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].value_str32, Actions1[j].Name, Actions1[j].Bit); |
| 444 |
+ |
if(!strcmp(args[i].value_str32, Actions1[j].Name)) { |
| 445 |
+ |
Input1 = Input1 | Actions1[j].Bit; |
| 446 |
+ |
//DDrConsole_PrintF("Success!"); |
| 447 |
+ |
} |
| 448 |
+ |
|
| 449 |
+ |
} |
| 450 |
+ |
for(j = 0; j < 9; j++) { |
| 451 |
+ |
if(!strcmp(args[i].value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit; |
| 452 |
+ |
|
| 453 |
+ |
} |
| 454 |
+ |
} |
| 455 |
+ |
//DDrConsole_PrintF("Testing: 0x%x Input: 0x%x",Input1, *(int*)(ONgGameState + 0xB8 + 0x10)); |
| 456 |
+ |
ret->value_int32 = 0; |
| 457 |
+ |
ret->type = sl_int32; |
| 458 |
+ |
if ( ((*(int*)(ONgGameState + 0xB8 + 0x10) & Input1) == Input1) && ((*(int*)(ONgGameState + 0xB8 + 0x14) & Input2) == Input2)) ret->value_int32 = 1; |
| 459 |
+ |
return 0; |
| 460 |
+ |
} |
| 461 |
+ |
|
| 462 |
+ |
uint16_t ONICALL bsl_waitforkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 463 |
+ |
{ |
| 464 |
+ |
// int index; |
| 465 |
+ |
// if (numargs < 4) index = 0; |
| 466 |
+ |
// else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 467 |
+ |
// else index = args[0].value_int32; |
| 468 |
+ |
|
| 469 |
+ |
// Character* Chr = ONgGameState + 0x1260; |
| 470 |
+ |
// ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
| 471 |
+ |
// if ((int)Active == 0) return 1; |
| 472 |
+ |
int i = 2; |
| 473 |
+ |
int j = 0; |
| 474 |
+ |
int Input1 = 0; |
| 475 |
+ |
int Input2 = 0; |
| 476 |
+ |
for(i = 0; i < numargs; i++) { |
| 477 |
+ |
for(j = 0; j < 32; j++) { |
| 478 |
+ |
//DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].value_str32, Actions1[j].Name, Actions1[j].Bit); |
| 479 |
+ |
if(!strcmp(args[i].value_str32, Actions1[j].Name)) { |
| 480 |
+ |
Input1 = Input1 | Actions1[j].Bit; |
| 481 |
+ |
//DDrConsole_PrintF("Success!"); |
| 482 |
+ |
} |
| 483 |
+ |
|
| 484 |
+ |
} |
| 485 |
+ |
for(j = 0; j < 9; j++) { |
| 486 |
+ |
if(!strcmp(args[i].value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit; |
| 487 |
+ |
|
| 488 |
+ |
} |
| 489 |
+ |
} |
| 490 |
+ |
//DDrConsole_PrintF("Waiting..."); |
| 491 |
+ |
if ( ((*(int*)(ONgGameState + 0xB8 + 0x10) & Input1) == Input1) && ((*(int*)(ONgGameState + 0xB8 + 0x14) & Input2) == Input2)) { |
| 492 |
+ |
} |
| 493 |
+ |
else { |
| 494 |
+ |
//else (int)*ret = 1; |
| 495 |
+ |
*dontuse2 = 1; |
| 496 |
+ |
*dontuse1 = 1; |
| 497 |
+ |
} |
| 498 |
+ |
/* |
| 499 |
+ |
__asm__( |
| 500 |
+ |
"movl 0x10(%esp), %edx\n\t" |
| 501 |
+ |
"movl $1,(%eax)\n\t" |
| 502 |
+ |
); |
| 503 |
+ |
//ret->type = sl_void |
| 504 |
+ |
*/ return 0; |
| 505 |
+ |
} |
| 506 |
+ |
|
| 507 |
|
/* |
| 508 |
|
uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 509 |
|
{ |
| 523 |
|
*/ |
| 524 |
|
uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
| 525 |
|
{ |
| 330 |
– |
DDrConsole_PrintF("%d", numargs); |
| 331 |
– |
|
| 526 |
|
if (numargs < 1 || args[0].type != sl_str32) |
| 527 |
|
{ |
| 528 |
|
DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": parameter list does not match: format:string arg1 arg2 ...", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name); |
| 674 |
|
|
| 675 |
|
void SLrDaodan_Initalize() |
| 676 |
|
{ |
| 677 |
+ |
|
| 678 |
+ |
//const char regen_patch[] = {0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; |
| 679 |
+ |
//DDrPatch_Const(OniExe + 0x0011BB6D, regen_patch); |
| 680 |
+ |
|
| 681 |
+ |
//This one should work but doesn't. |
| 682 |
+ |
//const char regen_patch[] ={0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x8B, 0x86, 0x44}; |
| 683 |
+ |
//DDrPatch_Const(OniExe + 0x0011BB64, regen_patch); |
| 684 |
+ |
|
| 685 |
|
SLrConfig(); |
| 686 |
|
|
| 687 |
+ |
|
| 688 |
|
SLrScript_Command_Register_ReturnType("int32mul", "Multiplies two numbers", "n1:int n2:int", sl_int32, bsl_int32mul); |
| 689 |
|
SLrScript_Command_Register_ReturnType("mul", "Multiplies two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_mul); |
| 690 |
|
|
| 699 |
|
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); |
| 700 |
|
SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "script_id:int", sl_int32, bsl_nametoindex); |
| 701 |
|
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); |
| 702 |
+ |
SLrScript_Command_Register_ReturnType("d_regen","Gets or sets a character's health", "[ai_name:str | script_id:int] [newhealth:int]", sl_str32, bsl_regen); |
| 703 |
|
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); |
| 704 |
|
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); |
| 705 |
+ |
SLrScript_Command_Register_ReturnType("d_holdkey","Makes an AI hold a key", "[ai_name:string | script_id:int] keys", sl_int32, bsl_holdkey); |
| 706 |
+ |
SLrScript_Command_Register_ReturnType("d_isheld","Checks for a held key", "keys", sl_int32, bsl_isheld); |
| 707 |
+ |
SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress.", "keys", bsl_waitforkey); |
| 708 |
+ |
|
| 709 |
|
//broken. sometimes crashes, and sometimes returns a string... : / |
| 710 |
|
SLrScript_Command_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker); |
| 711 |
|
|
| 712 |
|
SLrScript_Command_Register_ReturnType("d_active","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset); |
| 713 |
|
|
| 714 |
|
SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf); |
| 507 |
– |
SLrScript_Command_Register_ReturnType("dprintcolor", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored); |
| 715 |
|
|
| 716 |
|
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); |
| 717 |
+ |
|
| 718 |
+ |
//SLrScript_Command_Register_ReturnType("d_offset", "a test", "thing:int", sl_int32, bsl_returnoffset); |
| 719 |
|
} |
| 720 |
|
|
| 721 |
|
void SLrDaodan_Patch() |