2 |
|
#include <stdbool.h> |
3 |
|
#include <time.h> |
4 |
|
#include <ffi.h> |
5 |
< |
|
5 |
> |
#include <math.h> |
6 |
|
#include "inifile.h" |
7 |
|
|
8 |
|
#include "Daodan_BSL.h" |
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; |
220 |
> |
int* health = (int)&Chr[index] + 0x144; |
221 |
|
|
222 |
|
ret->value_int32 = *health; |
223 |
|
ret->type = sl_int32; |
225 |
|
if (numargs >= 2) { |
226 |
|
*health = args[1].value_int32; |
227 |
|
} |
228 |
– |
ret->value_int32 = *health; |
229 |
– |
ret->type = sl_int32; |
228 |
|
return 0; |
229 |
|
} |
230 |
|
|
231 |
+ |
uint16_t ONICALL bsl_distance(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) { |
232 |
+ |
|
233 |
+ |
if (numargs < 2) return 1; |
234 |
+ |
int index; |
235 |
+ |
int index2; |
236 |
+ |
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
237 |
+ |
else index = args[0].value_int32; |
238 |
+ |
if (index == -1) index = args[0].value_int32; |
239 |
+ |
|
240 |
+ |
if (args[1].type == sl_str32) index2 = DDrGetCharacterIndexFromName(args[1].value_str32); |
241 |
+ |
else index2 = args[1].value_int32; |
242 |
+ |
if (index2 == -1) index2 = args[1].value_int32; |
243 |
+ |
|
244 |
+ |
Character* Chr = ONgGameState + 0x1260; |
245 |
+ |
Character* Char1 = &Chr[index]; |
246 |
+ |
Character* Char2 = &Chr[index2]; |
247 |
+ |
|
248 |
+ |
ret->value_float = sqrt( pow((Char1->Location.X - Char2->Location.X), 2) + pow((Char1->Location.Y - Char2->Location.Y), 2) + pow((Char1->Location.Z - Char2->Location.Z),2)); |
249 |
+ |
ret->type = sl_float; |
250 |
+ |
return 0; |
251 |
+ |
} |
252 |
+ |
uint16_t ONICALL bsl_location(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) { |
253 |
+ |
int index; |
254 |
+ |
if (numargs < 2) return 1; |
255 |
+ |
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
256 |
+ |
else index = args[0].value_int32; |
257 |
+ |
if (index == -1) index = args[0].value_int32; |
258 |
+ |
Character* Chr = ONgGameState + 0x1260; |
259 |
+ |
float* loc; |
260 |
+ |
if (!strcmp(args[1].value_str32,"X") || !strcmp(args[1].value_str32,"x")) |
261 |
+ |
loc = &(Chr[index].Position.X); |
262 |
+ |
else if (!strcmp(args[1].value_str32,"Y") || !strcmp(args[1].value_str32,"y")) |
263 |
+ |
loc = &(Chr[index].Position.Y); |
264 |
+ |
else if (!strcmp(args[1].value_str32,"Z") || !strcmp(args[1].value_str32,"z")) |
265 |
+ |
loc = &(Chr[index].Position.Z); |
266 |
+ |
else if (numargs == 4) { |
267 |
+ |
//currently broken. crashes oni. |
268 |
+ |
Chr[index].Position.X = args[1].value_float; |
269 |
+ |
Chr[index].Position.Y = args[2].value_float; |
270 |
+ |
Chr[index].Position.Z = args[3].value_float; |
271 |
+ |
ret->value_float = 1; |
272 |
+ |
ret->type = sl_float; |
273 |
+ |
return 0; |
274 |
+ |
} |
275 |
+ |
else return 1; |
276 |
+ |
|
277 |
+ |
ret->value_float = *loc; |
278 |
+ |
ret->type = sl_float; |
279 |
+ |
|
280 |
+ |
if(numargs == 3) { |
281 |
+ |
//currently broken, does nothing. |
282 |
+ |
*loc = args[2].value_float; |
283 |
+ |
} |
284 |
+ |
return 0; |
285 |
+ |
} |
286 |
|
|
287 |
|
uint16_t ONICALL bsl_maxhealth(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
288 |
|
{ |
384 |
|
|
385 |
|
uint16_t ONICALL bsl_nametoindex(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
386 |
|
{ |
387 |
+ |
|
388 |
|
ret->type = sl_int32; |
389 |
|
ret->value_int32 = DDrGetCharacterIndexFromName(args[0].value_str32); |
390 |
+ |
|
391 |
|
return 0; |
392 |
|
} |
393 |
|
|
451 |
|
uint16_t ONICALL bsl_holdkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
452 |
|
{ |
453 |
|
int index; |
454 |
< |
if (numargs < 4) index = 0; |
455 |
< |
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
454 |
> |
|
455 |
> |
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
456 |
|
else index = args[0].value_int32; |
457 |
< |
|
457 |
> |
|
458 |
|
Character* Chr = ONgGameState + 0x1260; |
459 |
|
ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
460 |
|
if ((int)Active == 0) return 1; |
462 |
|
int j = 0; |
463 |
|
int Input1 = 0; |
464 |
|
int Input2 = 0; |
465 |
< |
for(i = 1; i < numargs; i++) { |
465 |
> |
for(i = 1; i < numargs - 1; i++) { |
466 |
|
for(j = 0; j < 32; j++) { |
467 |
< |
if(strcmp(args[i].value_str32, Actions1[j].Name)) Input1 = Input1 | Actions1[j].Bit; |
468 |
< |
DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].value_str32, Actions1[j].Name, Actions1[j].Bit); |
467 |
> |
if(!strcmp(args[i].value_str32, Actions1[j].Name)) { |
468 |
> |
Input1 = Input1 | Actions1[j].Bit; |
469 |
> |
} |
470 |
|
} |
471 |
|
for(j = 0; j < 9; j++) { |
472 |
< |
if(!strcmp(args[i].value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit; |
473 |
< |
|
474 |
< |
} |
472 |
> |
if(!strcmp(args[i].value_str32, Actions2[j].Name)) { |
473 |
> |
Input2 = Input2 | Actions2[j].Bit; |
474 |
> |
} |
475 |
|
} |
420 |
– |
for(i = 0; i < numargs; i++) { |
421 |
– |
DDrConsole_PrintF("%s", args[i].value_str32); |
476 |
|
} |
477 |
< |
// if |
477 |
> |
Active->Input.Current.Actions1 = Active->Input.Current.Actions1 | Input1; |
478 |
> |
Active->Input.Current.Actions2 = Active->Input.Current.Actions1 | Input2; |
479 |
> |
if( Input1 + Input2 == 0 ) { |
480 |
> |
DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": No valid keys given.", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name); |
481 |
> |
return 0; |
482 |
> |
} |
483 |
> |
if ( args[numargs - 1].value_int32 <= 0) { |
484 |
> |
return 0; |
485 |
> |
} |
486 |
> |
else { |
487 |
> |
args[numargs - 1].value_int32 -= 1; |
488 |
> |
*dontuse2 = 1; |
489 |
> |
*dontuse1 = 1; |
490 |
> |
} |
491 |
|
return 0; |
492 |
|
} |
493 |
|
|
739 |
|
DDrStartupMessage("finished parsing"); |
740 |
|
} |
741 |
|
|
675 |
– |
uint16_t ONICALL bsl_findmsg(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
676 |
– |
{ |
677 |
– |
//DDrMake_Weapon_Message(args[0].value_str32); |
678 |
– |
return false; |
679 |
– |
} |
742 |
|
void SLrDaodan_Initalize() |
743 |
|
{ |
744 |
|
|
750 |
|
//DDrPatch_Const(OniExe + 0x0011BB64, regen_patch); |
751 |
|
|
752 |
|
SLrConfig(); |
691 |
– |
SLrScript_Command_Register_ReturnType("d_wp", "Shows weapon message", "wpn:string", sl_void, bsl_findmsg); |
753 |
|
|
754 |
|
SLrScript_Command_Register_ReturnType("int32mul", "Multiplies two numbers", "n1:int n2:int", sl_int32, bsl_int32mul); |
755 |
|
SLrScript_Command_Register_ReturnType("mul", "Multiplies two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_mul); |
763 |
|
SLrScript_Command_Register_ReturnType("d_getkills","Gets the number of kills a character has", "[ai_name:str | script_id:int]", sl_int32, bsl_getkills); |
764 |
|
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); |
765 |
|
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); |
766 |
< |
SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "script_id:int", sl_int32, bsl_nametoindex); |
766 |
> |
SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "ai_name:string", sl_int32, bsl_nametoindex); |
767 |
|
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); |
768 |
|
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); |
769 |
|
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); |
770 |
|
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); |
771 |
< |
SLrScript_Command_Register_ReturnType("d_holdkey","Makes an AI hold a key", "[ai_name:string | script_id:int] keys", sl_int32, bsl_holdkey); |
772 |
< |
SLrScript_Command_Register_ReturnType("d_isheld","Checks for a held key", "keys", sl_int32, bsl_isheld); |
773 |
< |
SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress.", "keys", bsl_waitforkey); |
771 |
> |
SLrScript_Command_Register_ReturnType("d_holdkey","Makes a character hold a key", "[ai_name:string | script_id:int] keys frames:int", sl_int32, bsl_holdkey); |
772 |
> |
SLrScript_Command_Register_ReturnType("d_isheld","Checks if player is holding a key", "keys", sl_int32, bsl_isheld); |
773 |
> |
SLrScript_Command_Register_ReturnType("d_location","Returns the X, Y or Z coord of a character", "ai_name:str | script_id:int xyz:string [newlocation:float]", sl_float, bsl_location); |
774 |
> |
SLrScript_Command_Register_ReturnType("d_distance","Returns the distance between two characters", "ai_name:str | script_id:int ai_name:str | script_id:int ", sl_float, bsl_distance); |
775 |
> |
SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "keys", bsl_waitforkey); |
776 |
|
|
777 |
< |
//broken. sometimes crashes, and sometimes returns a string... : / |
778 |
< |
SLrScript_Command_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker); |
777 |
> |
//broken, only works for one damage type. |
778 |
> |
//SLrScript_Command_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker); |
779 |
|
|
780 |
< |
SLrScript_Command_Register_ReturnType("d_active","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset); |
780 |
> |
//used for debugging. |
781 |
> |
SLrScript_Command_Register_ReturnType("d_active","Returns a hex offset. ;)", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset); |
782 |
|
|
783 |
|
SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf); |
784 |
|
|