4 |
|
//#include <ffi.h> |
5 |
|
#include <math.h> |
6 |
|
#include "inifile.h" |
7 |
< |
|
7 |
> |
#include "Flatline.h" |
8 |
|
#include "Daodan_BSL.h" |
9 |
|
#include "Flatline_BSL.h" |
10 |
|
#include "Daodan_Utility.h" |
200 |
|
ret->value_int32 = *health; |
201 |
|
ret->type = sl_int32; |
202 |
|
|
203 |
< |
if (numargs >= 2) { |
203 |
> |
if (args[1].value_int32) { |
204 |
|
*health = args[1].value_int32; |
205 |
|
} |
206 |
|
ret->value_int32 = *health; |
264 |
|
return 0; |
265 |
|
} |
266 |
|
uint16_t ONICALL bsl_location(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) { |
267 |
< |
int index; |
267 |
> |
int index, i; |
268 |
|
float* loc; |
269 |
|
Character* Chr; |
270 |
+ |
numargs = 0; |
271 |
+ |
for(i = 0; args[i].type < sl_void; i++) |
272 |
+ |
{ |
273 |
+ |
numargs++; |
274 |
+ |
} |
275 |
+ |
|
276 |
+ |
|
277 |
|
if (numargs < 2) return 1; |
278 |
|
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
279 |
|
else index = args[0].value_int32; |
280 |
|
if (index == -1) index = args[0].value_int32; |
281 |
|
Chr = ONgGameState->CharacterStorage; |
282 |
< |
|
283 |
< |
if (!strcmp(args[1].value_str32,"X") || !strcmp(args[1].value_str32,"x")) |
284 |
< |
loc = &(Chr[index].Position.X); |
285 |
< |
else if (!strcmp(args[1].value_str32,"Y") || !strcmp(args[1].value_str32,"y")) |
286 |
< |
loc = &(Chr[index].Position.Y); |
287 |
< |
else if (!strcmp(args[1].value_str32,"Z") || !strcmp(args[1].value_str32,"z")) |
288 |
< |
loc = &(Chr[index].Position.Z); |
282 |
> |
if(numargs == 3) |
283 |
> |
{ |
284 |
> |
if (!strcmp(args[1].value_str32,"X") || !strcmp(args[1].value_str32,"x")) |
285 |
> |
loc = &(Chr[index].Position.X); |
286 |
> |
else if (!strcmp(args[1].value_str32,"Y") || !strcmp(args[1].value_str32,"y")) |
287 |
> |
loc = &(Chr[index].Position.Y); |
288 |
> |
else if (!strcmp(args[1].value_str32,"Z") || !strcmp(args[1].value_str32,"z")) |
289 |
> |
loc = &(Chr[index].Position.Z); |
290 |
> |
} |
291 |
|
else if (numargs == 4) { |
292 |
< |
//currently broken. crashes oni. |
293 |
< |
Chr[index].Position.X = args[1].value_float; |
294 |
< |
Chr[index].Position.Y = args[2].value_float; |
295 |
< |
Chr[index].Position.Z = args[3].value_float; |
292 |
> |
ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
293 |
> |
Chr[index].Location.X = args[1].value_float; |
294 |
> |
Chr[index].Location.Y = args[2].value_float; |
295 |
> |
Chr[index].Location.Z = args[3].value_float; |
296 |
> |
if(Active) |
297 |
> |
{ |
298 |
> |
Active->PhyContext->Position = Chr[index].Location; |
299 |
> |
} |
300 |
|
ret->value_float = 1; |
301 |
|
ret->type = sl_float; |
302 |
|
return 0; |
360 |
|
{ |
361 |
|
int index; |
362 |
|
char* name; |
363 |
+ |
|
364 |
|
if (numargs == 0) index = 0; |
365 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
366 |
|
else index = args[0].value_int32; |
394 |
|
//TODO: figure out why our implementation of dprint shows after dev mode is turned off |
395 |
|
RGBA color; |
396 |
|
RGBA shade; |
397 |
< |
|
397 |
> |
int i; |
398 |
> |
numargs = 0; |
399 |
> |
for(i = 0; args[i].type < sl_void; i++) |
400 |
> |
{ |
401 |
> |
numargs++; |
402 |
> |
} |
403 |
|
if(numargs == 0) return 0; |
404 |
|
if(numargs > 1 ) color.R = (char)args[1].value_int32; |
405 |
|
else color.R = 255; |
510 |
|
} |
511 |
|
} |
512 |
|
Active->Input.Current.Actions1 = Active->Input.Current.Actions1 | Input1; |
513 |
< |
Active->Input.Current.Actions2 = Active->Input.Current.Actions1 | Input2; |
513 |
> |
Active->Input.Current.Actions2 = Active->Input.Current.Actions2 | Input2; |
514 |
|
if( Input1 + Input2 == 0 ) { |
515 |
|
DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": No valid keys given.", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name); |
516 |
|
return 0; |
874 |
|
} |
875 |
|
|
876 |
|
} |
877 |
+ |
|
878 |
|
void* TSrTest = 0; |
879 |
|
uint16_t ONICALL new_text(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
880 |
|
{ |
881 |
|
void* TSFFTahoma; |
882 |
|
int returnval; |
883 |
< |
TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma); |
883 |
> |
|
884 |
> |
if(!TSrTest){ |
885 |
> |
TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma); |
886 |
|
returnval = TSrContext_New( TSFFTahoma, 7, 1, 1, 0, &TSrTest); |
887 |
+ |
} |
888 |
+ |
DDrPatch_MakeCall(0x004FBCEA, DDrText_Hook); |
889 |
+ |
|
890 |
+ |
*dontuse2 = 1; |
891 |
|
return 0; |
892 |
|
} |
893 |
|
|
908 |
|
SLrScript_Command_Register_ReturnType("d_name","Gets or sets a character's name", "[ai_name:string | script_id:int] [newname:string|]", sl_str32, bsl_chrname); |
909 |
|
SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "ai_name:string", sl_int32, bsl_nametoindex); |
910 |
|
SLrScript_Command_Register_ReturnType("d_health","Gets or sets a character's health", "[ai_name:string | script_id:int] [newhealth:int]", sl_str32, bsl_health); |
911 |
< |
SLrScript_Command_Register_ReturnType("d_regen","Gets or sets a character's health", "[ai_name:string | script_id:int] [newhealth:int]", sl_str32, bsl_regen); |
911 |
> |
SLrScript_Command_Register_ReturnType("d_regen","Gets or sets a character's regeneration abilities", "[ai_name:string | script_id:int] [newhealth:int]", sl_str32, bsl_regen); |
912 |
|
SLrScript_Command_Register_ReturnType("d_maxhealth","Gets or sets a character's maximum health", "[ai_name:string | script_id:int] [newmaxhealth:int] [scalehealth:bool]", sl_str32, bsl_maxhealth); |
913 |
|
SLrScript_Command_Register_ReturnType("d_powerup","Gets or sets a character's powerups", "[ai_name:string | script_id:int] powerup:string", sl_int32, bsl_powerup); |
914 |
|
//d_holdkey is broken! |
915 |
|
SLrScript_Command_Register_ReturnType("d_holdkey","Makes a character hold a key", "[ai_name:string | script_id:int] frames:int keys:string", sl_int32, bsl_holdkey); |
916 |
|
SLrScript_Command_Register_ReturnType("d_isheld","Checks if player is holding a key", "[ai_name:string | script_id:int] [keys:string]", sl_int32, bsl_isheld); |
917 |
< |
SLrScript_Command_Register_ReturnType("d_location","Returns the X, Y or Z coord of a character", "ai_name:string | script_id:int xyz:string [newlocation:float]", sl_float, bsl_location); |
917 |
> |
SLrScript_Command_Register_ReturnType("d_location","Returns the X, Y or Z coord of a character", "", sl_float, bsl_location); |
918 |
|
SLrScript_Command_Register_ReturnType("d_distance","Returns the distance between two characters", "ai_name:string | script_id:int ai_name:string | script_id:int", sl_float, bsl_distance); |
919 |
|
SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "key:string", bsl_waitforkey); |
920 |
|
|
925 |
|
// SLrDaodan_Register_ReturnType("d_active","Returns a hex offset. ;)", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset); |
926 |
|
|
927 |
|
SLrScript_Command_Register_Void("sprintf", "C-style sprintf.", "", bsl_sprintf); |
928 |
< |
SLrScript_Command_Register_ReturnType("st", "prints to console in color", "text:string color1:int color2:int", sl_void, bsl_dprintcolored); |
928 |
> |
SLrScript_Command_Register_ReturnType("st", "prints to console in color", "", sl_void, bsl_dprintcolored); |
929 |
> |
SLrScript_Command_Register_ReturnType("d_dprint", "prints to console in color", "", sl_void, bsl_dprintcolored); |
930 |
|
|
931 |
|
//Flatline |
932 |
|
//#ifdef FLATLINE |