| 1 |
|
#include <stdio.h> |
| 2 |
< |
#include <stdbool.h> |
| 2 |
> |
#include "bool.h" |
| 3 |
|
#include <time.h> |
| 4 |
< |
#include <ffi.h> |
| 4 |
> |
//#include <ffi.h> |
| 5 |
|
#include <math.h> |
| 6 |
|
#include "inifile.h" |
| 7 |
– |
|
| 7 |
|
#include "Daodan_BSL.h" |
| 9 |
– |
#include "Flatline_BSL.h" |
| 8 |
|
#include "Daodan_Utility.h" |
| 9 |
|
#include "Daodan_Patch.h" |
| 10 |
|
#include "Daodan_Console.h" |
| 12 |
|
#include "Oni.h" |
| 13 |
|
#include "Oni_Character.h" |
| 14 |
|
#include "oni_gl.h" |
| 17 |
– |
#include "dSFMT\dSFMT.h" |
| 15 |
|
#include "Daodan_Character.h" |
| 16 |
< |
|
| 16 |
> |
#include "BFW_Utility.h" |
| 17 |
|
|
| 18 |
|
|
| 19 |
|
uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 87 |
|
end = args[1].value_int32; |
| 88 |
|
} |
| 89 |
|
|
| 90 |
< |
ret->value_int32 = start + (dsfmt_gv_genrand_uint32() % (uint32_t)(end - start + 1)); |
| 90 |
> |
ret->value_int32 = start + (rand() % (uint32_t)(end - start + 1)); |
| 91 |
|
ret->type = sl_int32; |
| 92 |
|
return 0; |
| 93 |
|
} |
| 98 |
|
if (numargs == 0) index = 0; |
| 99 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 100 |
|
else index = args[0].value_int32; |
| 101 |
< |
int* killcount = ONgGameState + index * 0x16A0 + 0x1260 + 0x1670; |
| 102 |
< |
ret->value_int32 = *killcount; |
| 101 |
> |
//killcount = ONgGameState->CharacterStorage[index].Kills; |
| 102 |
> |
//ONgGameState + index * 0x16A0 + 0x1260 + 0x1670; |
| 103 |
> |
ret->value_int32 = ONgGameState->CharacterStorage[index].Kills; |
| 104 |
|
ret->type = sl_int32; |
| 105 |
|
return 0; |
| 106 |
|
} |
| 111 |
|
if (numargs == 0) index = 0; |
| 112 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 113 |
|
else index = args[0].value_int32; |
| 114 |
< |
int* killcount = ONgGameState + index * 0x16A0 + 0x1260 + 0x1674; |
| 117 |
< |
ret->value_int32 = *killcount; |
| 114 |
> |
ret->value_int32 = ONgGameState->CharacterStorage[index].Damage; |
| 115 |
|
ret->type = sl_int32; |
| 116 |
|
return 0; |
| 117 |
|
} |
| 118 |
|
|
| 122 |
– |
uint16_t ONICALL bsl_returnoffset(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 123 |
– |
{ |
| 124 |
– |
//int offset = 140; |
| 125 |
– |
//if (== 1) offset = 148; |
| 126 |
– |
//else index = args[0].value_int32; |
| 127 |
– |
int* killcount = ONgGameState + args[0].value_int32; |
| 128 |
– |
ret->value_int32 = *killcount; |
| 129 |
– |
ret->type = sl_int32; |
| 130 |
– |
return 0; |
| 131 |
– |
} |
| 119 |
|
|
| 120 |
|
|
| 121 |
|
uint16_t ONICALL bsl_powerup(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 122 |
|
{ |
| 123 |
|
int index; |
| 124 |
+ |
void* returnval; |
| 125 |
+ |
bool is_lsi = 0; |
| 126 |
+ |
Character* Chr = ONgGameState->CharacterStorage; |
| 127 |
+ |
|
| 128 |
|
if (numargs < 2 || args[1].type != sl_str32) return 1; |
| 129 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 130 |
|
else index = args[0].value_int32; |
| 131 |
< |
void* returnval; |
| 132 |
< |
bool is_lsi = 0; |
| 133 |
< |
Character* Chr = ONgGameState + 0x1260; |
| 131 |
> |
|
| 132 |
> |
|
| 133 |
> |
|
| 134 |
|
if(!strcmp(args[1].value_str32,"ammo")) |
| 135 |
|
{ |
| 136 |
< |
returnval = &(Chr[index].Inventory_.AmmoUsed); |
| 136 |
> |
returnval = &(Chr[index].Inventory.AmmoUsed); |
| 137 |
|
} |
| 138 |
|
else if(!strcmp(args[1].value_str32,"hypo")) |
| 139 |
|
{ |
| 140 |
< |
returnval = &(Chr[index].Inventory_.HypoUsed); |
| 140 |
> |
returnval = &(Chr[index].Inventory.HypoUsed); |
| 141 |
|
} |
| 142 |
|
else if(!strcmp(args[1].value_str32,"cells")) |
| 143 |
|
{ |
| 144 |
< |
returnval = &(Chr[index].Inventory_.CellsUsed); |
| 144 |
> |
returnval = &(Chr[index].Inventory.CellsUsed); |
| 145 |
|
} |
| 146 |
|
else if(!strcmp(args[1].value_str32,"invis")) |
| 147 |
|
{ |
| 148 |
< |
returnval = &(Chr[index].Inventory_.CloakUsed); |
| 148 |
> |
returnval = &(Chr[index].Inventory.CloakUsed); |
| 149 |
|
} |
| 150 |
|
else if(!strcmp(args[1].value_str32,"shield")) |
| 151 |
|
{ |
| 152 |
< |
returnval = &(Chr[index].Inventory_.ShieldUsed); |
| 152 |
> |
returnval = &(Chr[index].Inventory.ShieldUsed); |
| 153 |
|
} |
| 154 |
|
else if(!strcmp(args[1].value_str32,"lsi")) |
| 155 |
|
{ |
| 156 |
< |
returnval = &(Chr[index].Inventory_.hasLSI); |
| 156 |
> |
returnval = &(Chr[index].Inventory.hasLSI); |
| 157 |
|
is_lsi = 1; |
| 158 |
|
} |
| 159 |
|
// else if(!strcmp(args[1].value_str32,"bossshield")) |
| 186 |
|
uint16_t ONICALL bsl_health(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 187 |
|
{ |
| 188 |
|
int index; |
| 189 |
+ |
Character* Chr; |
| 190 |
+ |
int* health; |
| 191 |
|
if (numargs == 0) index = 0; |
| 192 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 193 |
|
else index = args[0].value_int32; |
| 194 |
< |
Character* Chr = ONgGameState + 0x1260 ; |
| 195 |
< |
int* health = &Chr[index].Health; |
| 194 |
> |
Chr = ONgGameState->CharacterStorage; |
| 195 |
> |
health = &Chr[index].Health; |
| 196 |
|
|
| 197 |
|
ret->value_int32 = *health; |
| 198 |
|
ret->type = sl_int32; |
| 199 |
|
|
| 200 |
< |
if (numargs >= 2) { |
| 200 |
> |
if (args[1].value_int32) { |
| 201 |
|
*health = args[1].value_int32; |
| 202 |
|
} |
| 203 |
|
ret->value_int32 = *health; |
| 208 |
|
uint16_t ONICALL bsl_regen(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 209 |
|
{ |
| 210 |
|
int index; |
| 211 |
+ |
Character* Chr; |
| 212 |
|
if (numargs == 0) index = 0; |
| 213 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 214 |
|
else index = args[0].value_int32; |
| 215 |
< |
Character* Chr = ONgGameState + 0x1260 ; |
| 216 |
< |
int* health = (int*)Chr[index].ScriptNoPath; |
| 215 |
> |
Chr = ONgGameState->CharacterStorage ; |
| 216 |
> |
|
| 217 |
|
|
| 218 |
|
/* |
| 219 |
|
DDrConsole_PrintF("Character %s", Chr[index].Name); |
| 226 |
|
DDrConsole_PrintF("NoAmmo %s", Chr[index].ScriptNoAmmo); |
| 227 |
|
DDrConsole_PrintF("NoPath %s", Chr[index].ScriptNoPath); |
| 228 |
|
*/ |
| 229 |
< |
ret->value_int32 = *health; |
| 229 |
> |
ret->value_int32 = Chr[index].RegenHax; |
| 230 |
|
ret->type = sl_int32; |
| 231 |
|
|
| 232 |
|
if (numargs >= 2) { |
| 233 |
< |
*health = args[1].value_int32; |
| 233 |
> |
Chr[index].RegenHax = args[1].value_int32; |
| 234 |
|
} |
| 235 |
|
return 0; |
| 236 |
|
} |
| 237 |
|
|
| 238 |
+ |
//wow this is broken. |
| 239 |
|
uint16_t ONICALL bsl_distance(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) { |
| 245 |
– |
|
| 246 |
– |
if (numargs < 2) return 1; |
| 240 |
|
int index; |
| 241 |
|
int index2; |
| 242 |
+ |
Character* Chr = ONgGameState->CharacterStorage; |
| 243 |
+ |
Character* Char1; |
| 244 |
+ |
Character* Char2; |
| 245 |
+ |
|
| 246 |
+ |
if (numargs < 2) return 1; |
| 247 |
+ |
|
| 248 |
|
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 249 |
|
else index = args[0].value_int32; |
| 250 |
|
if (index == -1) index = args[0].value_int32; |
| 252 |
|
if (args[1].type == sl_str32) index2 = DDrGetCharacterIndexFromName(args[1].value_str32); |
| 253 |
|
else index2 = args[1].value_int32; |
| 254 |
|
if (index2 == -1) index2 = args[1].value_int32; |
| 255 |
< |
|
| 256 |
< |
Character* Chr = ONgGameState + 0x1260; |
| 257 |
< |
Character* Char1 = &Chr[index]; |
| 259 |
< |
Character* Char2 = &Chr[index2]; |
| 255 |
> |
Char1 = &Chr[index]; |
| 256 |
> |
Char2 = &Chr[index2]; |
| 257 |
> |
|
| 258 |
|
|
| 259 |
|
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)); |
| 260 |
|
ret->type = sl_float; |
| 261 |
|
return 0; |
| 262 |
|
} |
| 263 |
|
uint16_t ONICALL bsl_location(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) { |
| 264 |
< |
int index; |
| 264 |
> |
int index, i; |
| 265 |
> |
float* loc; |
| 266 |
> |
Character* Chr; |
| 267 |
> |
numargs = 0; |
| 268 |
> |
for(i = 0; args[i].type < sl_void; i++) |
| 269 |
> |
{ |
| 270 |
> |
numargs++; |
| 271 |
> |
} |
| 272 |
> |
|
| 273 |
> |
|
| 274 |
|
if (numargs < 2) return 1; |
| 275 |
|
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 276 |
|
else index = args[0].value_int32; |
| 277 |
|
if (index == -1) index = args[0].value_int32; |
| 278 |
< |
Character* Chr = ONgGameState + 0x1260; |
| 279 |
< |
float* loc; |
| 280 |
< |
if (!strcmp(args[1].value_str32,"X") || !strcmp(args[1].value_str32,"x")) |
| 281 |
< |
loc = &(Chr[index].Position.X); |
| 282 |
< |
else if (!strcmp(args[1].value_str32,"Y") || !strcmp(args[1].value_str32,"y")) |
| 283 |
< |
loc = &(Chr[index].Position.Y); |
| 284 |
< |
else if (!strcmp(args[1].value_str32,"Z") || !strcmp(args[1].value_str32,"z")) |
| 285 |
< |
loc = &(Chr[index].Position.Z); |
| 278 |
> |
Chr = ONgGameState->CharacterStorage; |
| 279 |
> |
if(numargs == 3) |
| 280 |
> |
{ |
| 281 |
> |
if (!strcmp(args[1].value_str32,"X") || !strcmp(args[1].value_str32,"x")) |
| 282 |
> |
loc = &(Chr[index].Position.X); |
| 283 |
> |
else if (!strcmp(args[1].value_str32,"Y") || !strcmp(args[1].value_str32,"y")) |
| 284 |
> |
loc = &(Chr[index].Position.Y); |
| 285 |
> |
else if (!strcmp(args[1].value_str32,"Z") || !strcmp(args[1].value_str32,"z")) |
| 286 |
> |
loc = &(Chr[index].Position.Z); |
| 287 |
> |
} |
| 288 |
|
else if (numargs == 4) { |
| 289 |
< |
//currently broken. crashes oni. |
| 290 |
< |
Chr[index].Position.X = args[1].value_float; |
| 291 |
< |
Chr[index].Position.Y = args[2].value_float; |
| 292 |
< |
Chr[index].Position.Z = args[3].value_float; |
| 289 |
> |
ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
| 290 |
> |
Chr[index].Location.X = args[1].value_float; |
| 291 |
> |
Chr[index].Location.Y = args[2].value_float; |
| 292 |
> |
Chr[index].Location.Z = args[3].value_float; |
| 293 |
> |
if(Active) |
| 294 |
> |
{ |
| 295 |
> |
Active->PhyContext->Position = Chr[index].Location; |
| 296 |
> |
} |
| 297 |
|
ret->value_float = 1; |
| 298 |
|
ret->type = sl_float; |
| 299 |
|
return 0; |
| 316 |
|
if (numargs == 0) index = 0; |
| 317 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 318 |
|
else index = args[0].value_int32; |
| 319 |
< |
Character* Chr = ONgGameState + 0x1260 ; |
| 319 |
> |
if(1) { |
| 320 |
> |
Character* Chr = ONgGameState->CharacterStorage ; |
| 321 |
|
int* maxhealth = &Chr[index].MaxHealth; |
| 322 |
|
int oldmaxhealth = Chr[index].MaxHealth; |
| 323 |
|
int oldhealth = Chr->Health; |
| 330 |
|
ret->value_int32 = oldmaxhealth; |
| 331 |
|
ret->type = sl_int32; |
| 332 |
|
return 0; |
| 333 |
+ |
} |
| 334 |
|
} |
| 335 |
|
|
| 336 |
|
uint16_t ONICALL bsl_getattacker(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 341 |
|
if (numargs == 0) index = 0; |
| 342 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 343 |
|
else index = args[0].value_int32; |
| 344 |
< |
|
| 345 |
< |
Character* Chr = ONgGameState + 0x1260; |
| 344 |
> |
if(1) { |
| 345 |
> |
Character* Chr = ONgGameState->CharacterStorage; |
| 346 |
|
ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
| 347 |
< |
if ((int)Active == 0) return 1; |
| 347 |
> |
if (!Active) return 1; |
| 348 |
|
// ret->value_int32 = Active->LastDamageSourceCharacter; |
| 349 |
|
ret->type = sl_int32; |
| 350 |
|
return 0; |
| 351 |
+ |
} |
| 352 |
|
} |
| 353 |
|
|
| 354 |
|
|
| 356 |
|
uint16_t ONICALL bsl_chrname(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 357 |
|
{ |
| 358 |
|
int index; |
| 359 |
+ |
char* name; |
| 360 |
+ |
|
| 361 |
|
if (numargs == 0) index = 0; |
| 362 |
|
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 363 |
|
else index = args[0].value_int32; |
| 366 |
|
ret->value_str32 = "NULL"; |
| 367 |
|
return 0; |
| 368 |
|
} |
| 369 |
< |
char* name = ONgGameState + 0x1260 + index * 0x16A0 + 0x14; |
| 369 |
> |
name = &ONgGameState->CharacterStorage[index].Name; |
| 370 |
|
if (numargs == 2) { |
| 371 |
|
strncpy(name, (char*)args[1].value_str32, 31); |
| 372 |
|
} |
| 391 |
|
//TODO: figure out why our implementation of dprint shows after dev mode is turned off |
| 392 |
|
RGBA color; |
| 393 |
|
RGBA shade; |
| 394 |
< |
|
| 394 |
> |
int i; |
| 395 |
> |
numargs = 0; |
| 396 |
> |
for(i = 0; args[i].type < sl_void; i++) |
| 397 |
> |
{ |
| 398 |
> |
numargs++; |
| 399 |
> |
} |
| 400 |
|
if(numargs == 0) return 0; |
| 401 |
|
if(numargs > 1 ) color.R = (char)args[1].value_int32; |
| 402 |
|
else color.R = 255; |
| 427 |
|
return 0; |
| 428 |
|
} |
| 429 |
|
|
| 407 |
– |
uint16_t ONICALL bsl_getactiveoffset(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 408 |
– |
{ |
| 409 |
– |
DDrConsole_PrintF("Character: 0x%x",(int)ONgGameState + 0x1260); |
| 410 |
– |
DDrConsole_PrintF("ActiveChar: 0x%x",(int)ONrGetActiveCharacter((void*)((int)ONgGameState + 0x1260))); |
| 411 |
– |
return 0; |
| 412 |
– |
} |
| 430 |
|
typedef struct { |
| 431 |
|
char Name[16]; |
| 432 |
|
int Bit; |
| 479 |
|
{"Fire3", Action2_Fire3 } |
| 480 |
|
}; |
| 481 |
|
uint16_t ONICALL bsl_holdkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 482 |
< |
{ |
| 483 |
< |
int index; |
| 484 |
< |
|
| 485 |
< |
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 469 |
< |
else index = args[0].value_int32; |
| 470 |
< |
|
| 471 |
< |
Character* Chr = ONgGameState + 0x1260; |
| 472 |
< |
ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
| 473 |
< |
if ((int)Active == 0) return 1; |
| 474 |
< |
int i = 2; |
| 475 |
< |
int j = 0; |
| 482 |
> |
{ |
| 483 |
> |
uint32_t index; |
| 484 |
> |
uint32_t i = 2; |
| 485 |
> |
uint32_t j = 0; |
| 486 |
|
int Input1 = 0; |
| 487 |
|
int Input2 = 0; |
| 488 |
+ |
Character* Chr; |
| 489 |
+ |
ActiveCharacter* Active; |
| 490 |
+ |
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 491 |
+ |
else index = args[0].value_int32; |
| 492 |
+ |
|
| 493 |
+ |
Chr = &(ONgGameState->CharacterStorage[index]); |
| 494 |
+ |
Active = ONrGetActiveCharacter(Chr); |
| 495 |
+ |
if (!Active) return 1; |
| 496 |
+ |
|
| 497 |
|
for(i = 1; i < numargs - 1; i++) { |
| 498 |
|
for(j = 0; j < 32; j++) { |
| 499 |
|
if(!strcmp(args[i].value_str32, Actions1[j].Name)) { |
| 507 |
|
} |
| 508 |
|
} |
| 509 |
|
Active->Input.Current.Actions1 = Active->Input.Current.Actions1 | Input1; |
| 510 |
< |
Active->Input.Current.Actions2 = Active->Input.Current.Actions1 | Input2; |
| 510 |
> |
Active->Input.Current.Actions2 = Active->Input.Current.Actions2 | Input2; |
| 511 |
|
if( Input1 + Input2 == 0 ) { |
| 512 |
|
DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": No valid keys given.", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name); |
| 513 |
|
return 0; |
| 530 |
|
// else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 531 |
|
// else index = args[0].value_int32; |
| 532 |
|
|
| 533 |
< |
// Character* Chr = ONgGameState + 0x1260; |
| 533 |
> |
// Character* Chr = ONgGameState->CharacterStorage; |
| 534 |
|
// ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
| 535 |
|
// if ((int)Active == 0) return 1; |
| 536 |
< |
int i = 2; |
| 537 |
< |
int j = 0; |
| 536 |
> |
uint32_t i = 2; |
| 537 |
> |
uint32_t j = 0; |
| 538 |
|
int Input1 = 0; |
| 539 |
|
int Input2 = 0; |
| 540 |
|
for(i = 0; i < numargs; i++) { |
| 554 |
|
//DDrConsole_PrintF("Testing: 0x%x Input: 0x%x",Input1, *(int*)(ONgGameState + 0xB8 + 0x10)); |
| 555 |
|
ret->value_int32 = 0; |
| 556 |
|
ret->type = sl_int32; |
| 557 |
< |
if ( ((*(int*)(ONgGameState + 0xB8 + 0x10) & Input1) == Input1) && ((*(int*)(ONgGameState + 0xB8 + 0x14) & Input2) == Input2)) ret->value_int32 = 1; |
| 557 |
> |
if ( (ONgGameState->Input.Current.Actions1 == Input1) && (ONgGameState->Input.Current.Actions2 == Input2)) ret->value_int32 = 1; |
| 558 |
|
return 0; |
| 559 |
|
} |
| 560 |
|
|
| 565 |
|
// else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
| 566 |
|
// else index = args[0].value_int32; |
| 567 |
|
|
| 568 |
< |
// Character* Chr = ONgGameState + 0x1260; |
| 568 |
> |
// Character* Chr = ONgGameState->CharacterStorage; |
| 569 |
|
// ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]); |
| 570 |
|
// if ((int)Active == 0) return 1; |
| 571 |
+ |
|
| 572 |
|
int i = 2; |
| 573 |
|
int j = 0; |
| 574 |
|
int Input1 = 0; |
| 575 |
|
int Input2 = 0; |
| 576 |
< |
for(i = 0; i < numargs; i++) { |
| 576 |
> |
/* |
| 577 |
> |
numargs = 0; |
| 578 |
> |
for(i = 0; args[i].type <= sl_void; i++) |
| 579 |
> |
{ |
| 580 |
> |
//DDrConsole_PrintF("%i", args[i].type ); |
| 581 |
> |
numargs++; |
| 582 |
> |
|
| 583 |
> |
} |
| 584 |
> |
if(numargs < 1 || args[0].value == 0) return; |
| 585 |
> |
//for(i = 0; i < numargs; i++) { |
| 586 |
> |
*/ |
| 587 |
> |
i = 0; |
| 588 |
|
for(j = 0; j < 32; j++) { |
| 589 |
|
//DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].value_str32, Actions1[j].Name, Actions1[j].Bit); |
| 590 |
|
if(!strcmp(args[i].value_str32, Actions1[j].Name)) { |
| 597 |
|
if(!strcmp(args[i].value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit; |
| 598 |
|
|
| 599 |
|
} |
| 600 |
< |
} |
| 601 |
< |
//DDrConsole_PrintF("Waiting..."); |
| 602 |
< |
if ( ((*(int*)(ONgGameState + 0xB8 + 0x10) & Input1) == Input1) && ((*(int*)(ONgGameState + 0xB8 + 0x14) & Input2) == Input2)) { |
| 600 |
> |
// } |
| 601 |
> |
DDrConsole_PrintF("Waiting..."); |
| 602 |
> |
if ( |
| 603 |
> |
(( ONgGameState->Input.Current.Actions1 & Input1) == Input1) && |
| 604 |
> |
(( ONgGameState->Input.Current.Actions2 & Input2) == Input2) |
| 605 |
> |
) |
| 606 |
> |
{ |
| 607 |
> |
DDrConsole_PrintF("Found key!"); |
| 608 |
|
} |
| 609 |
|
else { |
| 610 |
|
//else (int)*ret = 1; |
| 611 |
|
*dontuse2 = 1; |
| 612 |
|
*dontuse1 = 1; |
| 613 |
|
} |
| 614 |
< |
/* |
| 579 |
< |
__asm__( |
| 580 |
< |
"movl 0x10(%esp), %edx\n\t" |
| 581 |
< |
"movl $1,(%eax)\n\t" |
| 582 |
< |
); |
| 583 |
< |
//ret->type = sl_void |
| 584 |
< |
*/ return 0; |
| 614 |
> |
return 0; |
| 615 |
|
} |
| 616 |
|
|
| 617 |
< |
/* |
| 617 |
> |
|
| 618 |
|
uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 619 |
|
{ |
| 620 |
< |
if (numargs < 2) |
| 620 |
> |
char output[1024]; |
| 621 |
> |
char buffer[1024]; |
| 622 |
> |
int i; |
| 623 |
> |
char* placeinoutput = output; |
| 624 |
> |
char* placeininput = args[0].value_str32; |
| 625 |
> |
int formatnum = 0; |
| 626 |
> |
//fix the broken bsl numargs... |
| 627 |
> |
numargs = 0; |
| 628 |
> |
|
| 629 |
> |
for(i = 0; args[i].type < sl_void; i++) |
| 630 |
> |
{ |
| 631 |
> |
numargs++; |
| 632 |
> |
} |
| 633 |
> |
|
| 634 |
> |
|
| 635 |
> |
if (numargs < 1) |
| 636 |
|
return 1; |
| 637 |
|
|
| 638 |
< |
char output[255]; |
| 639 |
< |
int i; |
| 638 |
> |
while(1) |
| 639 |
> |
{ |
| 640 |
> |
int size; |
| 641 |
> |
//s is the pointer to the args |
| 642 |
> |
char* s = strchr(placeininput , '%'); |
| 643 |
> |
//we didnt find a %, break! |
| 644 |
> |
if(!s) |
| 645 |
> |
{ |
| 646 |
> |
strcpy(placeinoutput, placeininput); |
| 647 |
> |
break; |
| 648 |
> |
} |
| 649 |
> |
size = (int)s - (int)placeininput ; |
| 650 |
> |
//we found one, so copy the portion of string |
| 651 |
> |
|
| 652 |
> |
|
| 653 |
> |
|
| 654 |
> |
memcpy( placeinoutput,placeininput, size); |
| 655 |
> |
placeininput += size; |
| 656 |
> |
placeinoutput += size; |
| 657 |
> |
|
| 658 |
> |
memset( placeinoutput, '%', (int)pow(2, formatnum)); |
| 659 |
> |
placeinoutput += (int)pow(2, formatnum); |
| 660 |
> |
|
| 661 |
> |
|
| 662 |
> |
placeininput += 1; |
| 663 |
> |
*placeinoutput = 0; |
| 664 |
> |
formatnum++; |
| 665 |
> |
|
| 666 |
> |
} |
| 667 |
> |
//strcpy( output, args[0].value_str32 ); |
| 668 |
> |
|
| 669 |
|
for(i = 1; i < numargs; i++) { |
| 670 |
< |
sprintf(output, args[0].value_str32, args[i].value_str32); |
| 670 |
> |
//sprintf(output, output, args[i].value_str32); |
| 671 |
> |
memcpy(buffer, output, 1024); |
| 672 |
> |
if(args[i].value == 0) break; |
| 673 |
> |
switch(args[i].type) |
| 674 |
> |
{ |
| 675 |
> |
case sl_bool: |
| 676 |
> |
case sl_int32: |
| 677 |
> |
sprintf(output, buffer, args[i].value_int32); |
| 678 |
> |
break; |
| 679 |
> |
case sl_float: |
| 680 |
> |
//crashes oni, why? |
| 681 |
> |
// sprintf(output, output, args[i].value_float); |
| 682 |
> |
break; |
| 683 |
> |
case sl_str32: |
| 684 |
> |
sprintf(output, buffer, args[i].value_str32); |
| 685 |
> |
break; |
| 686 |
> |
case sl_void: |
| 687 |
> |
default: |
| 688 |
> |
break; |
| 689 |
> |
} |
| 690 |
|
} |
| 691 |
< |
|
| 691 |
> |
//output[32] = 0; |
| 692 |
|
ret->value_str32 = output; |
| 693 |
|
ret->type = sl_str32; |
| 694 |
|
return 0; |
| 695 |
|
} |
| 696 |
< |
*/ |
| 696 |
> |
|
| 697 |
> |
//Sorry rossy, I broke this. FFI isnt in windows |
| 698 |
> |
/* |
| 699 |
|
uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 700 |
|
{ |
| 701 |
+ |
|
| 702 |
+ |
|
| 703 |
+ |
int ffi_ret; |
| 704 |
+ |
char* str = NULL; |
| 705 |
+ |
int size = 0; |
| 706 |
+ |
|
| 707 |
+ |
ffi_cif cif; |
| 708 |
+ |
ffi_type* ffi_args[256]; |
| 709 |
+ |
void* values[256]; |
| 710 |
+ |
int i; |
| 711 |
+ |
numargs = 0; |
| 712 |
+ |
for(i = 0; args[i].type <= sl_void; i++) |
| 713 |
+ |
{ |
| 714 |
+ |
//DDrConsole_PrintF("%i", args[i].type ); |
| 715 |
+ |
numargs++; |
| 716 |
+ |
|
| 717 |
+ |
} |
| 718 |
+ |
|
| 719 |
|
if (numargs < 1 || args[0].type != sl_str32) |
| 720 |
|
{ |
| 721 |
|
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); |
| 725 |
|
if (!args[0].value_str32) |
| 726 |
|
args[0].value_str32 = ""; |
| 727 |
|
|
| 615 |
– |
int ffi_ret; |
| 616 |
– |
char* str = NULL; |
| 617 |
– |
int size = 0; |
| 728 |
|
|
| 619 |
– |
ffi_cif cif; |
| 620 |
– |
ffi_type* ffi_args[256]; |
| 621 |
– |
void* values[256]; |
| 729 |
|
|
| 730 |
|
ffi_args[0] = &ffi_type_pointer; |
| 731 |
|
values[0] = &str; |
| 732 |
|
ffi_args[1] = &ffi_type_uint32; |
| 733 |
|
values[1] = &size; |
| 734 |
|
|
| 735 |
< |
int i; |
| 735 |
> |
|
| 736 |
|
for(i = 2; i < numargs + 2; i ++) |
| 737 |
|
{ |
| 738 |
|
if (args[i - 2].type == sl_float) |
| 753 |
|
|
| 754 |
|
if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, i, &ffi_type_sint32, ffi_args) != FFI_OK) |
| 755 |
|
return 1; |
| 756 |
< |
ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values); |
| 756 |
> |
ffi_call(&cif, (void*)_snprintf, (void*)&ffi_ret, values); |
| 757 |
|
str = malloc(ffi_ret + 1); |
| 758 |
|
size = ffi_ret + 1; |
| 759 |
< |
ffi_call(&cif, (void*)snprintf, (void*)&ffi_ret, values); |
| 759 |
> |
ffi_call(&cif, (void*)_snprintf, (void*)&ffi_ret, values); |
| 760 |
|
ret->value_str32 = str; |
| 761 |
|
ret->type = sl_str32; |
| 762 |
|
return 0; |
| 763 |
|
} |
| 764 |
< |
|
| 764 |
> |
*/ |
| 765 |
|
// Widescreen patch for talking heads. |
| 766 |
|
uint16_t ONICALL cinematic_start_patch(sl_callinfo* callinfo, unsigned int numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 767 |
|
{ |
| 768 |
< |
args[1].value_int32 = (double)args[1].value_int32 / (double)(gl->DisplayMode.Width) * (4.0 / 3.0 * (double)(gl->DisplayMode.Height)); |
| 768 |
> |
args[1].value_int32 = (double)args[1].value_int32 / (double)(gl_eng->DisplayMode.Width) * (4.0 / 3.0 * (double)(gl_eng->DisplayMode.Height)); |
| 769 |
|
return ((sl_func)(OniExe + 0x000f3830))(callinfo, numargs, args, dontuse1, dontuse2, ret); |
| 770 |
|
} |
| 771 |
|
|
| 772 |
|
bool ini_inbsl = false; |
| 773 |
|
bool SLrIniCallback(char* section, bool newsection, char* name, char* value) |
| 774 |
|
{ |
| 775 |
< |
if (newsection && !stricmp(section, "bsl")) |
| 775 |
> |
if (newsection && !_stricmp(section, "bsl")) |
| 776 |
|
ini_inbsl = true; |
| 777 |
|
|
| 778 |
|
if (ini_inbsl) |
| 779 |
|
{ |
| 780 |
+ |
char* type = value; |
| 781 |
|
bool isptr = false; |
| 782 |
|
sl_type bsl_type; |
| 783 |
|
|
| 787 |
|
value += 4; |
| 788 |
|
} |
| 789 |
|
|
| 790 |
< |
char* type = value; |
| 790 |
> |
|
| 791 |
|
|
| 792 |
|
for (; *type; type++) |
| 793 |
|
if (*type == ':') |
| 860 |
|
DDrStartupMessage("finished parsing"); |
| 861 |
|
} |
| 862 |
|
|
| 863 |
< |
void SLrDaodan_Initalize() |
| 864 |
< |
{ |
| 863 |
> |
void ONICALL SLrDaodan_Register_ReturnType(char* name, char* desc, char* argfmt, sl_type type, sl_func callback) { |
| 864 |
> |
char argfmt2[512]; |
| 865 |
> |
uint16_t errornum; |
| 866 |
> |
sprintf_s(argfmt2, 512, "%s [|]", argfmt); |
| 867 |
> |
errornum = SLrScript_Command_Register_ReturnType(name, desc, argfmt2, type, callback); |
| 868 |
> |
if(errornum) |
| 869 |
> |
{ |
| 870 |
> |
DDrStartupMessage("Registration of script command %s failed with error %i", name, errornum); |
| 871 |
> |
} |
| 872 |
|
|
| 873 |
+ |
} |
| 874 |
|
|
| 875 |
< |
//Calculating the value of the needed offset is much more reliable when the compiler does it for you. |
| 875 |
> |
void* TSrTest = 0; |
| 876 |
> |
uint16_t ONICALL new_text(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) |
| 877 |
> |
{ |
| 878 |
> |
void* TSFFTahoma; |
| 879 |
> |
int returnval; |
| 880 |
|
|
| 881 |
< |
//TODO: fix moonshadow. |
| 882 |
< |
Character * Chr = 0; |
| 883 |
< |
char NoPath = (char)(0x100 - (int)(Chr->ScriptNoPath)); |
| 884 |
< |
const char regen_patch[] = |
| 885 |
< |
{0x90, 0x90, 0x90, 0x90, 0x90, // mov al, _WPgRegenerationCheat |
| 886 |
< |
0x90, 0x90, // test al, al |
| 887 |
< |
0x90, 0x90, // jz short loc_51BB98 |
| 888 |
< |
0x8B, 0x86, NoPath}; |
| 889 |
< |
DDrPatch_Const(OniExe + 0x0011BB64, regen_patch); |
| 881 |
> |
if(!TSrTest){ |
| 882 |
> |
TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma); |
| 883 |
> |
returnval = TSrContext_New( TSFFTahoma, 7, 1, 1, 0, &TSrTest); |
| 884 |
> |
} |
| 885 |
> |
DDrPatch_MakeCall(0x004FBCEA, DDrText_Hook); |
| 886 |
> |
|
| 887 |
> |
*dontuse2 = 1; |
| 888 |
> |
return 0; |
| 889 |
> |
} |
| 890 |
|
|
| 891 |
< |
SLrConfig(); |
| 891 |
> |
void SLrDaodan_Initalize() |
| 892 |
> |
{ |
| 893 |
> |
SLrConfig(); |
| 894 |
> |
|
| 895 |
> |
SLrScript_Command_Register_Void("debug_daodan","Adds text to screen", "", new_text); |
| 896 |
|
|
| 897 |
|
SLrScript_Command_Register_ReturnType("int32mul", "Multiplies two numbers", "n1:int n2:int", sl_int32, bsl_int32mul); |
| 898 |
|
SLrScript_Command_Register_ReturnType("mul", "Multiplies two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_mul); |
| 775 |
– |
|
| 899 |
|
SLrScript_Command_Register_ReturnType("int32div", "Divides two numbers", "n1:int n2:int", sl_int32, bsl_int32div); |
| 900 |
|
SLrScript_Command_Register_ReturnType("div", "Divides two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_div); |
| 901 |
< |
|
| 779 |
< |
dsfmt_gv_init_gen_rand((uint32_t)time(NULL)); |
| 901 |
> |
srand((uint32_t)time(NULL)); |
| 902 |
|
SLrScript_Command_Register_ReturnType("int32rand", "Returns a pseudo-random number between two numbers (inclusive).", "start:int end:int", sl_int32, bsl_int32rand); |
| 903 |
< |
|
| 782 |
< |
SLrScript_Command_Register_ReturnType("d_getkills","Gets the number of kills a character has", "[ai_name:str | script_id:int]", sl_int32, bsl_getkills); |
| 903 |
> |
SLrScript_Command_Register_ReturnType("d_getkills","Gets the number of kills a character has", "[ai_name:string | script_id:int] [|]", sl_int32, bsl_getkills); |
| 904 |
|
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); |
| 905 |
< |
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); |
| 905 |
> |
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); |
| 906 |
|
SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "ai_name:string", sl_int32, bsl_nametoindex); |
| 907 |
< |
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); |
| 908 |
< |
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); |
| 909 |
< |
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); |
| 910 |
< |
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); |
| 911 |
< |
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); |
| 912 |
< |
SLrScript_Command_Register_ReturnType("d_isheld","Checks if player is holding a key", "keys", sl_int32, bsl_isheld); |
| 913 |
< |
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); |
| 914 |
< |
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); |
| 915 |
< |
SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "keys", bsl_waitforkey); |
| 907 |
> |
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); |
| 908 |
> |
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); |
| 909 |
> |
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); |
| 910 |
> |
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); |
| 911 |
> |
//d_holdkey is broken! |
| 912 |
> |
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); |
| 913 |
> |
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); |
| 914 |
> |
SLrScript_Command_Register_ReturnType("d_location","Returns the X, Y or Z coord of a character", "", sl_float, bsl_location); |
| 915 |
> |
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); |
| 916 |
> |
SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "key:string", bsl_waitforkey); |
| 917 |
|
|
| 918 |
|
//broken, only works for one damage type. |
| 919 |
< |
//SLrScript_Command_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker); |
| 919 |
> |
//SLrDaodan_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker); |
| 920 |
|
|
| 921 |
|
//used for debugging. |
| 922 |
< |
SLrScript_Command_Register_ReturnType("d_active","Returns a hex offset. ;)", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset); |
| 801 |
< |
|
| 802 |
< |
SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf); |
| 803 |
< |
|
| 804 |
< |
SLrScript_Command_Register_ReturnType("st", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored); |
| 805 |
< |
|
| 806 |
< |
//Flatline |
| 807 |
< |
SLrFlatline_Initialize(); |
| 922 |
> |
// SLrDaodan_Register_ReturnType("d_active","Returns a hex offset. ;)", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset); |
| 923 |
|
|
| 924 |
+ |
SLrScript_Command_Register_Void("sprintf", "C-style sprintf.", "", bsl_sprintf); |
| 925 |
+ |
SLrScript_Command_Register_ReturnType("st", "prints to console in color", "", sl_void, bsl_dprintcolored); |
| 926 |
+ |
SLrScript_Command_Register_ReturnType("d_dprint", "prints to console in color", "", sl_void, bsl_dprintcolored); |
| 927 |
|
} |
| 928 |
|
|
| 929 |
|
void SLrDaodan_Patch() |