#include #include "Daodan_BSL.h" #include "BFW_ScriptingLanguage.h" #include #include "Oni.h" #include "Oni_Character.h" #include "dSFMT\dSFMT.h" uint16_t ONICALL bsl_int32mul(void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) { if (numargs < 2) return 1; ret->value_int32 = args[0].value_int32 * args[1].value_int32; ret->type = sl_int32; return 0; } uint16_t ONICALL bsl_getkills(void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) { //void* GS = (short int**)(ONgGameState); //if (numargs < 2) // return 1; //fix the AC struct :( //ret->value_int32 = ((ActiveCharacter *)(ONgGameState+0xB6268))->NumberOfKills; //short int index =; //char temp_bitset[2]; int index2; if (numargs == 0) index2 = 0; else index2 = args[0].value_int32; char* active_index = ONgGameState + index2 * 0x16A0 + 0x1260 + 2; //index = *(*()+ 0x1260 +2); //ret->value_int32 = *((signed int*)(ONgGameState)) +0xB6268+(*(((signed int*)(ONgGameState)) + 0xAC)+2)*0x2838+0x1670; //ret->value_int32 = *(int*)(ONgGameState +0xB6268 + index2 * 0x2838 + 0x1670); //TODO: Clean up this mess... // ret->value_int32 = *active_index; ret->value_int32 = ((uint32_t*)(ONgGameState +0xB6268+(int)(*active_index)*0x2838+0x1670)); ret->type = sl_int32; return 0; } uint16_t ONICALL bsl_mul(void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) { if (numargs < 2) return 1; double val1; double val2; if (args[0].type == sl_int32) val1 = args[0].value_int32; else val1 = args[0].value_float; if (args[1].type == sl_int32) val2 = args[1].value_int32; else val2 = args[1].value_float; ret->value_float = (float)(val1 * val2); ret->type = sl_float; return 0; } uint16_t ONICALL bsl_int32div(void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) { if (numargs < 2) return 1; ret->value_int32 = args[0].value_int32 / args[1].value_int32; ret->type = sl_int32; return 0; } uint16_t ONICALL bsl_div(void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) { if (numargs < 2) return 1; double val1; double val2; if (args[0].type == sl_int32) val1 = args[0].value_int32; else val1 = args[0].value_float; if (args[1].type == sl_int32) val2 = args[1].value_int32; else val2 = args[1].value_float; ret->value_float = (float)(val1 / val2); ret->type = sl_float; return 0; } uint16_t ONICALL bsl_sprintf(void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) { if (numargs < 2) return 1; <<<<<<< .mine char output[255]; char temp[255]; int i = 1; for(i; i < numargs; i++) { sprintf(output, args[0].value_str32, args[i].value_str32);/* if(args[i].type == sl_int32 || args[i].type == sl_bool) { sprintf(temp, "%i",args[i].value_int32); sprintf(output, args[0].value_str32, temp); } else if(args[i].type == sl_float) { sprintf(temp, "%f",args[i].value_float); sprintf(output, args[0].value_str32, temp); } else */ } ret->value_str32 = output; ret->type = sl_str32; return 0; } uint16_t ONICALL bsl_int32rand(void* dontuse0, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) { if (numargs < 2) return 1; int32_t start = 0; int32_t end = 0; if (args[0].value_int32 == args[1].value_int32) return 1; else if (args[0].value_int32 > args[1].value_int32) { start = args[1].value_int32; end = args[0].value_int32; } else { start = args[0].value_int32; end = args[1].value_int32; } ret->value_int32 = start + (dsfmt_gv_genrand_uint32() % (uint32_t)(end - start + 1)); ret->type = sl_int32; return 0; } void SLrDaodan_Initalize() { SLrScript_Command_Register_ReturnType("int32mul", "Multiplies two numbers", "n1:int n2:int", sl_int32, bsl_int32mul); SLrScript_Command_Register_ReturnType("mul", "Multiplies two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_mul); SLrScript_Command_Register_ReturnType("int32div", "Divides two numbers", "n1:int n2:int", sl_int32, bsl_int32div); SLrScript_Command_Register_ReturnType("div", "Divides two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_div); SLrScript_Command_Register_ReturnType("sprintf", "sprintf", "str1:format str2:value [str3:...]", sl_str32, bsl_sprintf); SLrScript_Command_Register_ReturnType("getkills","Gets the number of kills", "[n1:int]", sl_int32, bsl_getkills); dsfmt_gv_init_gen_rand((uint32_t)time(NULL)); SLrScript_Command_Register_ReturnType("int32rand", "Returns a pseudo-random number between two numbers (inclusive).", "start:int end:int", sl_int32, bsl_int32rand); >>>>>>> .r440 }