[443] | 1 | #include <stdio.h>
|
---|
[692] | 2 | #include "stdint.h"
|
---|
[440] | 3 | #include <time.h>
|
---|
[481] | 4 | #include <math.h>
|
---|
[692] | 5 | #include "Inifile_Reader.h"
|
---|
[439] | 6 | #include "Daodan_BSL.h"
|
---|
[444] | 7 | #include "Daodan_Utility.h"
|
---|
[447] | 8 | #include "Daodan_Patch.h"
|
---|
[444] | 9 | #include "Daodan_Console.h"
|
---|
[445] | 10 | #include "BFW_ScriptLang.h"
|
---|
[441] | 11 | #include "Oni.h"
|
---|
| 12 | #include "Oni_Character.h"
|
---|
[692] | 13 | #include "Oni_GL.h"
|
---|
[446] | 14 | #include "Daodan_Character.h"
|
---|
[440] | 15 |
|
---|
[484] | 16 |
|
---|
[474] | 17 | uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[439] | 18 | {
|
---|
[688] | 19 | ret->val.value_int32 = args[0].val.value_int32 * args[1].val.value_int32;
|
---|
[439] | 20 | ret->type = sl_int32;
|
---|
| 21 | return 0;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
[474] | 24 | uint16_t ONICALL bsl_mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[439] | 25 | {
|
---|
| 26 | double val1;
|
---|
| 27 | double val2;
|
---|
| 28 |
|
---|
| 29 | if (args[0].type == sl_int32)
|
---|
[688] | 30 | val1 = args[0].val.value_int32;
|
---|
[439] | 31 | else
|
---|
[688] | 32 | val1 = args[0].val.value_float;
|
---|
[439] | 33 |
|
---|
| 34 | if (args[1].type == sl_int32)
|
---|
[688] | 35 | val2 = args[1].val.value_int32;
|
---|
[439] | 36 | else
|
---|
[688] | 37 | val2 = args[1].val.value_float;
|
---|
[439] | 38 |
|
---|
[688] | 39 | ret->val.value_float = (float)(val1 * val2);
|
---|
[439] | 40 | ret->type = sl_float;
|
---|
| 41 | return 0;
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[474] | 44 | uint16_t ONICALL bsl_int32div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[439] | 45 | {
|
---|
[688] | 46 | ret->val.value_int32 = args[0].val.value_int32 / args[1].val.value_int32;
|
---|
[439] | 47 | ret->type = sl_int32;
|
---|
| 48 | return 0;
|
---|
| 49 | }
|
---|
[474] | 50 | uint16_t ONICALL bsl_div(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[439] | 51 | {
|
---|
| 52 | double val1;
|
---|
| 53 | double val2;
|
---|
| 54 |
|
---|
| 55 | if (args[0].type == sl_int32)
|
---|
[688] | 56 | val1 = args[0].val.value_int32;
|
---|
[439] | 57 | else
|
---|
[688] | 58 | val1 = args[0].val.value_float;
|
---|
[439] | 59 |
|
---|
| 60 | if (args[1].type == sl_int32)
|
---|
[688] | 61 | val2 = args[1].val.value_int32;
|
---|
[439] | 62 | else
|
---|
[688] | 63 | val2 = args[1].val.value_float;
|
---|
[439] | 64 |
|
---|
[688] | 65 | ret->val.value_float = (float)(val1 / val2);
|
---|
[439] | 66 | ret->type = sl_float;
|
---|
| 67 | return 0;
|
---|
| 68 | }
|
---|
[443] | 69 |
|
---|
[474] | 70 | uint16_t ONICALL bsl_int32rand(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[443] | 71 | {
|
---|
| 72 | int32_t start = 0;
|
---|
| 73 | int32_t end = 0;
|
---|
| 74 |
|
---|
[688] | 75 | if (args[0].val.value_int32 == args[1].val.value_int32)
|
---|
[443] | 76 | return 1;
|
---|
[688] | 77 | else if (args[0].val.value_int32 > args[1].val.value_int32)
|
---|
[443] | 78 | {
|
---|
[688] | 79 | start = args[1].val.value_int32;
|
---|
| 80 | end = args[0].val.value_int32;
|
---|
[443] | 81 | }
|
---|
| 82 | else
|
---|
| 83 | {
|
---|
[688] | 84 | start = args[0].val.value_int32;
|
---|
| 85 | end = args[1].val.value_int32;
|
---|
[443] | 86 | }
|
---|
| 87 |
|
---|
[688] | 88 | ret->val.value_int32 = start + (rand() % (uint32_t)(end - start + 1));
|
---|
[443] | 89 | ret->type = sl_int32;
|
---|
| 90 | return 0;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
[474] | 93 | uint16_t ONICALL bsl_getkills(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[443] | 94 | {
|
---|
| 95 | int index;
|
---|
| 96 | if (numargs == 0) index = 0;
|
---|
[688] | 97 | else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 98 | else index = args[0].val.value_int32;
|
---|
[677] | 99 | //killcount = ONgGameState->CharacterStorage[index].Kills;
|
---|
| 100 | //ONgGameState + index * 0x16A0 + 0x1260 + 0x1670;
|
---|
[688] | 101 | ret->val.value_int32 = ONgGameState->CharacterStorage[index].Kills;
|
---|
[443] | 102 | ret->type = sl_int32;
|
---|
| 103 | return 0;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
[474] | 106 | uint16_t ONICALL bsl_getdamage(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[443] | 107 | {
|
---|
| 108 | int index;
|
---|
| 109 | if (numargs == 0) index = 0;
|
---|
[688] | 110 | else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 111 | else index = args[0].val.value_int32;
|
---|
| 112 | ret->val.value_int32 = ONgGameState->CharacterStorage[index].Damage;
|
---|
[443] | 113 | ret->type = sl_int32;
|
---|
| 114 | return 0;
|
---|
| 115 | }
|
---|
[446] | 116 |
|
---|
[470] | 117 |
|
---|
| 118 |
|
---|
[474] | 119 | uint16_t ONICALL bsl_powerup(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[446] | 120 | {
|
---|
| 121 | int index;
|
---|
[677] | 122 | void* returnval;
|
---|
| 123 | bool is_lsi = 0;
|
---|
| 124 | Character* Chr = ONgGameState->CharacterStorage;
|
---|
| 125 |
|
---|
[446] | 126 | if (numargs < 2 || args[1].type != sl_str32) return 1;
|
---|
[688] | 127 | else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 128 | else index = args[0].val.value_int32;
|
---|
[677] | 129 |
|
---|
| 130 |
|
---|
| 131 |
|
---|
[688] | 132 | if(!strcmp(args[1].val.value_str32,"ammo"))
|
---|
[446] | 133 | {
|
---|
[677] | 134 | returnval = &(Chr[index].Inventory.AmmoUsed);
|
---|
[450] | 135 | }
|
---|
[688] | 136 | else if(!strcmp(args[1].val.value_str32,"hypo"))
|
---|
[450] | 137 | {
|
---|
[677] | 138 | returnval = &(Chr[index].Inventory.HypoUsed);
|
---|
[450] | 139 | }
|
---|
[688] | 140 | else if(!strcmp(args[1].val.value_str32,"cells"))
|
---|
[450] | 141 | {
|
---|
[677] | 142 | returnval = &(Chr[index].Inventory.CellsUsed);
|
---|
[450] | 143 | }
|
---|
[688] | 144 | else if(!strcmp(args[1].val.value_str32,"invis"))
|
---|
[450] | 145 | {
|
---|
[677] | 146 | returnval = &(Chr[index].Inventory.CloakUsed);
|
---|
[450] | 147 | }
|
---|
[688] | 148 | else if(!strcmp(args[1].val.value_str32,"shield"))
|
---|
[450] | 149 | {
|
---|
[677] | 150 | returnval = &(Chr[index].Inventory.ShieldUsed);
|
---|
[450] | 151 | }
|
---|
[688] | 152 | else if(!strcmp(args[1].val.value_str32,"lsi"))
|
---|
[450] | 153 | {
|
---|
[677] | 154 | returnval = &(Chr[index].Inventory.hasLSI);
|
---|
[450] | 155 | is_lsi = 1;
|
---|
| 156 | }
|
---|
[451] | 157 | // else if(!strcmp(args[1].value_str32,"bossshield"))
|
---|
| 158 | // {
|
---|
| 159 | // ret->value_int32 = Chr[index].Flags & char_bossshield;
|
---|
| 160 | // ret->type = sl_int32;
|
---|
| 161 | // if (numargs >=3) {
|
---|
| 162 | // if (Chr[index].Flags & char_bossshield) Chr[index].Flags = Chr[index].Flags & ~char_bossshield;
|
---|
| 163 | // else Chr[index].Flags = Chr[index].Flags | char_bossshield;
|
---|
| 164 | // }
|
---|
| 165 | // return 0;
|
---|
| 166 | // }
|
---|
[450] | 167 | else return 1;
|
---|
[446] | 168 | //todo, add setting
|
---|
| 169 |
|
---|
[688] | 170 | if(is_lsi) ret->val.value_int32 = (int)*(bool*)returnval;
|
---|
| 171 | else ret->val.value_int32 = *(int*)returnval;
|
---|
[450] | 172 | ret->type = sl_int32;
|
---|
| 173 |
|
---|
| 174 | if (numargs >= 3)
|
---|
[446] | 175 | {
|
---|
[688] | 176 | if(is_lsi) *(bool*)returnval = args[2].val.value_int32;
|
---|
| 177 | else *(int*)returnval = args[2].val.value_int32;
|
---|
[446] | 178 | }
|
---|
[450] | 179 |
|
---|
| 180 |
|
---|
[446] | 181 | return 0;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
[474] | 184 | uint16_t ONICALL bsl_health(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[446] | 185 | {
|
---|
| 186 | int index;
|
---|
[677] | 187 | Character* Chr;
|
---|
| 188 | int* health;
|
---|
[446] | 189 | if (numargs == 0) index = 0;
|
---|
[688] | 190 | else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 191 | else index = args[0].val.value_int32;
|
---|
[677] | 192 | Chr = ONgGameState->CharacterStorage;
|
---|
| 193 | health = &Chr[index].Health;
|
---|
[446] | 194 |
|
---|
[688] | 195 | ret->val.value_int32 = *health;
|
---|
[446] | 196 | ret->type = sl_int32;
|
---|
| 197 |
|
---|
[688] | 198 | if (args[1].val.value_int32) {
|
---|
| 199 | *health = args[1].val.value_int32;
|
---|
[446] | 200 | }
|
---|
[688] | 201 | ret->val.value_int32 = *health;
|
---|
[446] | 202 | ret->type = sl_int32;
|
---|
| 203 | return 0;
|
---|
| 204 | }
|
---|
| 205 |
|
---|
[474] | 206 | uint16_t ONICALL bsl_regen(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[470] | 207 | {
|
---|
| 208 | int index;
|
---|
[677] | 209 | Character* Chr;
|
---|
[470] | 210 | if (numargs == 0) index = 0;
|
---|
[688] | 211 | else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 212 | else index = args[0].val.value_int32;
|
---|
[677] | 213 | Chr = ONgGameState->CharacterStorage ;
|
---|
[484] | 214 |
|
---|
[677] | 215 |
|
---|
[484] | 216 | /*
|
---|
| 217 | DDrConsole_PrintF("Character %s", Chr[index].Name);
|
---|
| 218 | DDrConsole_PrintF("Spawn %s", Chr[index].ScriptSpawn);
|
---|
| 219 | DDrConsole_PrintF("Death %s", Chr[index].ScriptDie);
|
---|
| 220 | DDrConsole_PrintF("Aware %s", Chr[index].ScriptAware);
|
---|
| 221 | DDrConsole_PrintF("Alarm %s", Chr[index].ScriptAlarm);
|
---|
| 222 | DDrConsole_PrintF("Hurt %s", Chr[index].ScriptHurt);
|
---|
| 223 | DDrConsole_PrintF("Defeat %s", Chr[index].ScriptDefeat);
|
---|
| 224 | DDrConsole_PrintF("NoAmmo %s", Chr[index].ScriptNoAmmo);
|
---|
| 225 | DDrConsole_PrintF("NoPath %s", Chr[index].ScriptNoPath);
|
---|
| 226 | */
|
---|
[688] | 227 | ret->val.value_int32 = Chr[index].RegenHax;
|
---|
[470] | 228 | ret->type = sl_int32;
|
---|
| 229 |
|
---|
| 230 | if (numargs >= 2) {
|
---|
[688] | 231 | Chr[index].RegenHax = args[1].val.value_int32;
|
---|
[470] | 232 | }
|
---|
| 233 | return 0;
|
---|
| 234 | }
|
---|
| 235 |
|
---|
[677] | 236 | //wow this is broken.
|
---|
[481] | 237 | uint16_t ONICALL bsl_distance(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) {
|
---|
| 238 | int index;
|
---|
| 239 | int index2;
|
---|
[677] | 240 | Character* Chr = ONgGameState->CharacterStorage;
|
---|
| 241 | Character* Char1;
|
---|
| 242 | Character* Char2;
|
---|
| 243 |
|
---|
| 244 | if (numargs < 2) return 1;
|
---|
| 245 |
|
---|
[688] | 246 | if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 247 | else index = args[0].val.value_int32;
|
---|
| 248 | if (index == -1) index = args[0].val.value_int32;
|
---|
[470] | 249 |
|
---|
[688] | 250 | if (args[1].type == sl_str32) index2 = DDrGetCharacterIndexFromName(args[1].val.value_str32);
|
---|
| 251 | else index2 = args[1].val.value_int32;
|
---|
| 252 | if (index2 == -1) index2 = args[1].val.value_int32;
|
---|
[677] | 253 | Char1 = &Chr[index];
|
---|
| 254 | Char2 = &Chr[index2];
|
---|
[481] | 255 |
|
---|
[677] | 256 |
|
---|
[688] | 257 | ret->val.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));
|
---|
[481] | 258 | ret->type = sl_float;
|
---|
| 259 | return 0;
|
---|
| 260 | }
|
---|
| 261 | uint16_t ONICALL bsl_location(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret) {
|
---|
[677] | 262 | int index, i;
|
---|
| 263 | float* loc;
|
---|
| 264 | Character* Chr;
|
---|
| 265 | numargs = 0;
|
---|
| 266 | for(i = 0; args[i].type < sl_void; i++)
|
---|
| 267 | {
|
---|
| 268 | numargs++;
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 |
|
---|
[481] | 272 | if (numargs < 2) return 1;
|
---|
[688] | 273 | if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 274 | else index = args[0].val.value_int32;
|
---|
| 275 | if (index == -1) index = args[0].val.value_int32;
|
---|
[677] | 276 | Chr = ONgGameState->CharacterStorage;
|
---|
| 277 | if(numargs == 3)
|
---|
| 278 | {
|
---|
[688] | 279 | if (!strcmp(args[1].val.value_str32,"X") || !strcmp(args[1].val.value_str32,"x"))
|
---|
[677] | 280 | loc = &(Chr[index].Position.X);
|
---|
[688] | 281 | else if (!strcmp(args[1].val.value_str32,"Y") || !strcmp(args[1].val.value_str32,"y"))
|
---|
[677] | 282 | loc = &(Chr[index].Position.Y);
|
---|
[688] | 283 | else if (!strcmp(args[1].val.value_str32,"Z") || !strcmp(args[1].val.value_str32,"z"))
|
---|
[677] | 284 | loc = &(Chr[index].Position.Z);
|
---|
| 285 | }
|
---|
[481] | 286 | else if (numargs == 4) {
|
---|
[677] | 287 | ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
|
---|
[688] | 288 | Chr[index].Location.X = args[1].val.value_float;
|
---|
| 289 | Chr[index].Location.Y = args[2].val.value_float;
|
---|
| 290 | Chr[index].Location.Z = args[3].val.value_float;
|
---|
[677] | 291 | if(Active)
|
---|
| 292 | {
|
---|
| 293 | Active->PhyContext->Position = Chr[index].Location;
|
---|
| 294 | }
|
---|
[688] | 295 | ret->val.value_float = 1;
|
---|
[481] | 296 | ret->type = sl_float;
|
---|
| 297 | return 0;
|
---|
| 298 | }
|
---|
| 299 | else return 1;
|
---|
| 300 |
|
---|
[688] | 301 | ret->val.value_float = *loc;
|
---|
[481] | 302 | ret->type = sl_float;
|
---|
| 303 |
|
---|
| 304 | if(numargs == 3) {
|
---|
| 305 | //currently broken, does nothing.
|
---|
[688] | 306 | *loc = args[2].val.value_float;
|
---|
[481] | 307 | }
|
---|
| 308 | return 0;
|
---|
| 309 | }
|
---|
| 310 |
|
---|
[474] | 311 | uint16_t ONICALL bsl_maxhealth(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[446] | 312 | {
|
---|
| 313 | int index;
|
---|
| 314 | if (numargs == 0) index = 0;
|
---|
[688] | 315 | else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 316 | else index = args[0].val.value_int32;
|
---|
[677] | 317 | if(1) {
|
---|
| 318 | Character* Chr = ONgGameState->CharacterStorage ;
|
---|
[446] | 319 | int* maxhealth = &Chr[index].MaxHealth;
|
---|
| 320 | int oldmaxhealth = Chr[index].MaxHealth;
|
---|
| 321 | int oldhealth = Chr->Health;
|
---|
| 322 | if (numargs >= 2) {
|
---|
[688] | 323 | *maxhealth = args[1].val.value_int32;
|
---|
[446] | 324 | }
|
---|
[688] | 325 | if (numargs >= 3 && args[2].val.value_bool) {
|
---|
| 326 | Chr->Health = (int)(((float)args[1].val.value_int32 / (float)oldmaxhealth) * (float)oldhealth);
|
---|
[446] | 327 | }
|
---|
[688] | 328 | ret->val.value_int32 = oldmaxhealth;
|
---|
[446] | 329 | ret->type = sl_int32;
|
---|
| 330 | return 0;
|
---|
[677] | 331 | }
|
---|
[446] | 332 | }
|
---|
| 333 |
|
---|
[474] | 334 | uint16_t ONICALL bsl_getattacker(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[446] | 335 | {
|
---|
[470] | 336 | //broken
|
---|
| 337 |
|
---|
[446] | 338 | int index;
|
---|
[450] | 339 | if (numargs == 0) index = 0;
|
---|
[688] | 340 | else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 341 | else index = args[0].val.value_int32;
|
---|
[677] | 342 | if(1) {
|
---|
| 343 | Character* Chr = ONgGameState->CharacterStorage;
|
---|
[450] | 344 | ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
|
---|
[677] | 345 | if (!Active) return 1;
|
---|
[688] | 346 | // ret->val.value_int32 = Active->LastDamageSourceCharacter;
|
---|
[446] | 347 | ret->type = sl_int32;
|
---|
| 348 | return 0;
|
---|
[677] | 349 | }
|
---|
[446] | 350 | }
|
---|
| 351 |
|
---|
| 352 |
|
---|
[450] | 353 |
|
---|
[474] | 354 | uint16_t ONICALL bsl_chrname(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[446] | 355 | {
|
---|
| 356 | int index;
|
---|
[677] | 357 | char* name;
|
---|
| 358 |
|
---|
[446] | 359 | if (numargs == 0) index = 0;
|
---|
[688] | 360 | else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 361 | else index = args[0].val.value_int32;
|
---|
[446] | 362 | if (index == -1) {
|
---|
| 363 | ret->type = sl_str32;
|
---|
[688] | 364 | ret->val.value_str32 = "NULL";
|
---|
[446] | 365 | return 0;
|
---|
| 366 | }
|
---|
[689] | 367 | name = (char*)(&ONgGameState->CharacterStorage[index].Name);
|
---|
[446] | 368 | if (numargs == 2) {
|
---|
[688] | 369 | strncpy(name, (char*)args[1].val.value_str32, 31);
|
---|
[446] | 370 | }
|
---|
| 371 |
|
---|
| 372 | ret->type = sl_str32;
|
---|
[688] | 373 | ret->val.value_str32 = name;
|
---|
[446] | 374 |
|
---|
| 375 | return 0;
|
---|
| 376 | }
|
---|
| 377 |
|
---|
| 378 |
|
---|
[474] | 379 | uint16_t ONICALL bsl_count(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[446] | 380 | {
|
---|
| 381 | //testing numargs...
|
---|
| 382 | ret->type = sl_int32;
|
---|
[688] | 383 | ret->val.value_int32 = numargs;
|
---|
[446] | 384 | return 0;
|
---|
| 385 | }
|
---|
| 386 |
|
---|
[474] | 387 | uint16_t ONICALL bsl_dprintcolored(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[446] | 388 | {
|
---|
| 389 | //TODO: figure out why our implementation of dprint shows after dev mode is turned off
|
---|
| 390 | RGBA color;
|
---|
| 391 | RGBA shade;
|
---|
[677] | 392 | int i;
|
---|
| 393 | numargs = 0;
|
---|
| 394 | for(i = 0; args[i].type < sl_void; i++)
|
---|
| 395 | {
|
---|
| 396 | numargs++;
|
---|
| 397 | }
|
---|
[446] | 398 | if(numargs == 0) return 0;
|
---|
[688] | 399 | if(numargs > 1 ) color.R = (char)args[1].val.value_int32;
|
---|
[446] | 400 | else color.R = 255;
|
---|
[688] | 401 | if(numargs > 2 ) color.G = (char)args[2].val.value_int32;
|
---|
[446] | 402 | else color.G = 255;
|
---|
[688] | 403 | if(numargs > 3 ) color.B = (char)args[3].val.value_int32;
|
---|
[446] | 404 | else color.B = 255;
|
---|
| 405 | color.A = 0;
|
---|
[688] | 406 | if(numargs > 5 ) shade.R = (char)args[5].val.value_int32;
|
---|
[446] | 407 | else shade.R = 0x3F;
|
---|
[688] | 408 | if(numargs > 6 ) shade.G = (char)args[6].val.value_int32;
|
---|
[446] | 409 | else shade.G = 0x3F;
|
---|
[688] | 410 | if(numargs > 7 ) shade.B = (char)args[7].val.value_int32;
|
---|
[446] | 411 | else shade.B = 0x3F;
|
---|
| 412 | shade.A = 0;
|
---|
| 413 |
|
---|
[688] | 414 | DDrConsole_PrintColored(args[0].val.value_str32, 1, color, shade);
|
---|
[446] | 415 | return 0;
|
---|
| 416 | }
|
---|
| 417 |
|
---|
| 418 |
|
---|
[474] | 419 | uint16_t ONICALL bsl_nametoindex(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[446] | 420 | {
|
---|
[481] | 421 |
|
---|
[446] | 422 | ret->type = sl_int32;
|
---|
[688] | 423 | ret->val.value_int32 = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
[481] | 424 |
|
---|
[446] | 425 | return 0;
|
---|
| 426 | }
|
---|
[450] | 427 |
|
---|
[470] | 428 | typedef struct {
|
---|
| 429 | char Name[16];
|
---|
| 430 | int Bit;
|
---|
| 431 | } KeyBit;
|
---|
| 432 |
|
---|
| 433 | KeyBit Actions1[32] = {
|
---|
| 434 | {"Escape", Action_Escape},
|
---|
| 435 | {"Console", Action_Console},
|
---|
| 436 | {"PauseScreen", Action_PauseScreen},
|
---|
| 437 | {"Cutscene1", Action_Cutscene_1 },
|
---|
| 438 | {"Cutscene2", Action_Cutscene_2 },
|
---|
| 439 | {"F4", Action_F4 },
|
---|
| 440 | {"F5", Action_F5 },
|
---|
| 441 | {"F6", Action_F6 },
|
---|
| 442 | {"F7", Action_F7 },
|
---|
| 443 | {"F8", Action_F8 },
|
---|
| 444 | {"StartRecorn", Action_StartRecord },
|
---|
| 445 | {"StopRecord", Action_StopRecord },
|
---|
| 446 | {"PlayRecord", Action_PlayRecord },
|
---|
| 447 | {"F12", Action_F12 },
|
---|
| 448 | {"Unknown1", Action_Unknown1 },
|
---|
| 449 | {"LookMode", Action_LookMode },
|
---|
| 450 | {"Screenshot", Action_Screenshot },
|
---|
| 451 | {"Unknown2", Action_Unknown2 },
|
---|
| 452 | {"Unknown3", Action_Unknown3 },
|
---|
| 453 | {"Unknown4", Action_Unknown4 },
|
---|
| 454 | {"Unknown5", Action_Unknown5 },
|
---|
| 455 | {"Forward", Action_Forward },
|
---|
| 456 | {"Backward", Action_Backward },
|
---|
| 457 | {"TurnLeft", Action_TurnLeft },
|
---|
| 458 | {"TurnRight", Action_TurnRight },
|
---|
| 459 | {"StepLeft", Action_StepLeft },
|
---|
| 460 | {"StepRight", Action_StepRight },
|
---|
| 461 | {"Jump", Action_Jump },
|
---|
| 462 | {"Crouch", Action_Crouch },
|
---|
| 463 | {"Punch",Action_Punch },
|
---|
| 464 | {"Kick", Action_Kick },
|
---|
| 465 | {"Block", Action_Block }
|
---|
| 466 | };
|
---|
| 467 |
|
---|
| 468 | KeyBit Actions2[9] = {
|
---|
| 469 | {"Walk", Action2_Walk},
|
---|
| 470 | {"Action", Action2_Action},
|
---|
| 471 | {"Hypo", Action2_Hypo},
|
---|
| 472 | {"Reload", Action2_Reload },
|
---|
| 473 | {"Swap", Action2_Swap },
|
---|
| 474 | {"Drop", Action2_Drop },
|
---|
| 475 | {"Fire1", Action2_Fire1 },
|
---|
| 476 | {"Fire2", Action2_Fire2 },
|
---|
| 477 | {"Fire3", Action2_Fire3 }
|
---|
| 478 | };
|
---|
[474] | 479 | uint16_t ONICALL bsl_holdkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[677] | 480 | {
|
---|
| 481 | uint32_t index;
|
---|
| 482 | uint32_t i = 2;
|
---|
| 483 | uint32_t j = 0;
|
---|
[470] | 484 | int Input1 = 0;
|
---|
| 485 | int Input2 = 0;
|
---|
[677] | 486 | Character* Chr;
|
---|
| 487 | ActiveCharacter* Active;
|
---|
[688] | 488 | if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 489 | else index = args[0].val.value_int32;
|
---|
[677] | 490 |
|
---|
| 491 | Chr = &(ONgGameState->CharacterStorage[index]);
|
---|
| 492 | Active = ONrGetActiveCharacter(Chr);
|
---|
| 493 | if (!Active) return 1;
|
---|
| 494 |
|
---|
[481] | 495 | for(i = 1; i < numargs - 1; i++) {
|
---|
[470] | 496 | for(j = 0; j < 32; j++) {
|
---|
[688] | 497 | if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) {
|
---|
[481] | 498 | Input1 = Input1 | Actions1[j].Bit;
|
---|
| 499 | }
|
---|
[470] | 500 | }
|
---|
| 501 | for(j = 0; j < 9; j++) {
|
---|
[688] | 502 | if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) {
|
---|
[481] | 503 | Input2 = Input2 | Actions2[j].Bit;
|
---|
| 504 | }
|
---|
[470] | 505 | }
|
---|
| 506 | }
|
---|
[481] | 507 | Active->Input.Current.Actions1 = Active->Input.Current.Actions1 | Input1;
|
---|
[677] | 508 | Active->Input.Current.Actions2 = Active->Input.Current.Actions2 | Input2;
|
---|
[481] | 509 | if( Input1 + Input2 == 0 ) {
|
---|
| 510 | DDrConsole_PrintF("Func \"%s\", File \"%s\", Line %d: semantic error, \"%s\": No valid keys given.", callinfo->name, callinfo->calllocation, callinfo->linenumber, callinfo->name);
|
---|
| 511 | return 0;
|
---|
| 512 | }
|
---|
[688] | 513 | if ( args[numargs - 1].val.value_int32 <= 0) {
|
---|
[481] | 514 | return 0;
|
---|
| 515 | }
|
---|
| 516 | else {
|
---|
[688] | 517 | args[numargs - 1].val.value_int32 -= 1;
|
---|
[481] | 518 | *dontuse2 = 1;
|
---|
| 519 | *dontuse1 = 1;
|
---|
| 520 | }
|
---|
[470] | 521 | return 0;
|
---|
| 522 | }
|
---|
| 523 |
|
---|
[474] | 524 | uint16_t ONICALL bsl_isheld(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[470] | 525 | {
|
---|
| 526 | // int index;
|
---|
| 527 | // if (numargs < 4) index = 0;
|
---|
[688] | 528 | // else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 529 | // else index = args[0].val.value_int32;
|
---|
[470] | 530 |
|
---|
[677] | 531 | // Character* Chr = ONgGameState->CharacterStorage;
|
---|
[470] | 532 | // ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
|
---|
| 533 | // if ((int)Active == 0) return 1;
|
---|
[677] | 534 | uint32_t i = 2;
|
---|
| 535 | uint32_t j = 0;
|
---|
[470] | 536 | int Input1 = 0;
|
---|
| 537 | int Input2 = 0;
|
---|
| 538 | for(i = 0; i < numargs; i++) {
|
---|
| 539 | for(j = 0; j < 32; j++) {
|
---|
[688] | 540 | //DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].val.value_str32, Actions1[j].Name, Actions1[j].Bit);
|
---|
| 541 | if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) {
|
---|
[470] | 542 | Input1 = Input1 | Actions1[j].Bit;
|
---|
| 543 | //DDrConsole_PrintF("Success!");
|
---|
| 544 | }
|
---|
| 545 |
|
---|
| 546 | }
|
---|
| 547 | for(j = 0; j < 9; j++) {
|
---|
[688] | 548 | if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit;
|
---|
[470] | 549 |
|
---|
| 550 | }
|
---|
| 551 | }
|
---|
| 552 | //DDrConsole_PrintF("Testing: 0x%x Input: 0x%x",Input1, *(int*)(ONgGameState + 0xB8 + 0x10));
|
---|
[688] | 553 | ret->val.value_int32 = 0;
|
---|
[470] | 554 | ret->type = sl_int32;
|
---|
[688] | 555 | if ( (ONgGameState->Input.Current.Actions1 == Input1) && (ONgGameState->Input.Current.Actions2 == Input2)) ret->val.value_int32 = 1;
|
---|
[470] | 556 | return 0;
|
---|
| 557 | }
|
---|
| 558 |
|
---|
| 559 | uint16_t ONICALL bsl_waitforkey(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
| 560 | {
|
---|
| 561 | // int index;
|
---|
| 562 | // if (numargs < 4) index = 0;
|
---|
[688] | 563 | // else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].val.value_str32);
|
---|
| 564 | // else index = args[0].val.value_int32;
|
---|
[470] | 565 |
|
---|
[677] | 566 | // Character* Chr = ONgGameState->CharacterStorage;
|
---|
[470] | 567 | // ActiveCharacter* Active = (ActiveCharacter*)ONrGetActiveCharacter(&Chr[index]);
|
---|
| 568 | // if ((int)Active == 0) return 1;
|
---|
[677] | 569 |
|
---|
[470] | 570 | int i = 2;
|
---|
| 571 | int j = 0;
|
---|
| 572 | int Input1 = 0;
|
---|
| 573 | int Input2 = 0;
|
---|
[677] | 574 | /*
|
---|
| 575 | numargs = 0;
|
---|
| 576 | for(i = 0; args[i].type <= sl_void; i++)
|
---|
| 577 | {
|
---|
| 578 | //DDrConsole_PrintF("%i", args[i].type );
|
---|
| 579 | numargs++;
|
---|
| 580 |
|
---|
| 581 | }
|
---|
[688] | 582 | if(numargs < 1 || args[0].val.value == 0) return;
|
---|
[677] | 583 | //for(i = 0; i < numargs; i++) {
|
---|
| 584 | */
|
---|
| 585 | i = 0;
|
---|
[470] | 586 | for(j = 0; j < 32; j++) {
|
---|
[688] | 587 | //DDrConsole_PrintF("Testing %s against %s 0x%x", args[i].val.value_str32, Actions1[j].Name, Actions1[j].Bit);
|
---|
| 588 | if(!strcmp(args[i].val.value_str32, Actions1[j].Name)) {
|
---|
[470] | 589 | Input1 = Input1 | Actions1[j].Bit;
|
---|
| 590 | //DDrConsole_PrintF("Success!");
|
---|
| 591 | }
|
---|
| 592 |
|
---|
| 593 | }
|
---|
| 594 | for(j = 0; j < 9; j++) {
|
---|
[688] | 595 | if(!strcmp(args[i].val.value_str32, Actions2[j].Name)) Input2 = Input2 | Actions2[j].Bit;
|
---|
[470] | 596 |
|
---|
| 597 | }
|
---|
[677] | 598 | // }
|
---|
| 599 | DDrConsole_PrintF("Waiting...");
|
---|
| 600 | if (
|
---|
| 601 | (( ONgGameState->Input.Current.Actions1 & Input1) == Input1) &&
|
---|
| 602 | (( ONgGameState->Input.Current.Actions2 & Input2) == Input2)
|
---|
| 603 | )
|
---|
| 604 | {
|
---|
| 605 | DDrConsole_PrintF("Found key!");
|
---|
[470] | 606 | }
|
---|
| 607 | else {
|
---|
| 608 | //else (int)*ret = 1;
|
---|
| 609 | *dontuse2 = 1;
|
---|
| 610 | *dontuse1 = 1;
|
---|
| 611 | }
|
---|
[677] | 612 | return 0;
|
---|
[470] | 613 | }
|
---|
| 614 |
|
---|
[677] | 615 |
|
---|
[474] | 616 | uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[441] | 617 | {
|
---|
[677] | 618 | char output[1024];
|
---|
| 619 | char buffer[1024];
|
---|
[689] | 620 | unsigned int i;
|
---|
[677] | 621 | char* placeinoutput = output;
|
---|
[688] | 622 | char* placeininput = args[0].val.value_str32;
|
---|
[677] | 623 | int formatnum = 0;
|
---|
| 624 | //fix the broken bsl numargs...
|
---|
| 625 | numargs = 0;
|
---|
| 626 |
|
---|
| 627 | for(i = 0; args[i].type < sl_void; i++)
|
---|
| 628 | {
|
---|
| 629 | numargs++;
|
---|
| 630 | }
|
---|
| 631 |
|
---|
| 632 |
|
---|
| 633 | if (numargs < 1)
|
---|
[441] | 634 | return 1;
|
---|
[445] | 635 |
|
---|
[677] | 636 | while(1)
|
---|
| 637 | {
|
---|
| 638 | int size;
|
---|
| 639 | //s is the pointer to the args
|
---|
| 640 | char* s = strchr(placeininput , '%');
|
---|
| 641 | //we didnt find a %, break!
|
---|
| 642 | if(!s)
|
---|
| 643 | {
|
---|
| 644 | strcpy(placeinoutput, placeininput);
|
---|
| 645 | break;
|
---|
| 646 | }
|
---|
| 647 | size = (int)s - (int)placeininput ;
|
---|
| 648 | //we found one, so copy the portion of string
|
---|
| 649 |
|
---|
| 650 |
|
---|
| 651 |
|
---|
| 652 | memcpy( placeinoutput,placeininput, size);
|
---|
| 653 | placeininput += size;
|
---|
| 654 | placeinoutput += size;
|
---|
| 655 |
|
---|
| 656 | memset( placeinoutput, '%', (int)pow(2, formatnum));
|
---|
| 657 | placeinoutput += (int)pow(2, formatnum);
|
---|
| 658 |
|
---|
| 659 |
|
---|
| 660 | placeininput += 1;
|
---|
| 661 | *placeinoutput = 0;
|
---|
| 662 | formatnum++;
|
---|
| 663 |
|
---|
| 664 | }
|
---|
| 665 | //strcpy( output, args[0].value_str32 );
|
---|
| 666 |
|
---|
[444] | 667 | for(i = 1; i < numargs; i++) {
|
---|
[677] | 668 | //sprintf(output, output, args[i].value_str32);
|
---|
| 669 | memcpy(buffer, output, 1024);
|
---|
[688] | 670 | if(args[i].val.value == 0) break;
|
---|
[677] | 671 | switch(args[i].type)
|
---|
| 672 | {
|
---|
| 673 | case sl_bool:
|
---|
| 674 | case sl_int32:
|
---|
[688] | 675 | sprintf(output, buffer, args[i].val.value_int32);
|
---|
[677] | 676 | break;
|
---|
| 677 | case sl_float:
|
---|
| 678 | //crashes oni, why?
|
---|
[688] | 679 | // sprintf(output, output, args[i].val.value_float);
|
---|
[677] | 680 | break;
|
---|
| 681 | case sl_str32:
|
---|
[688] | 682 | sprintf(output, buffer, args[i].val.value_str32);
|
---|
[677] | 683 | break;
|
---|
| 684 | case sl_void:
|
---|
| 685 | default:
|
---|
| 686 | break;
|
---|
| 687 | }
|
---|
[441] | 688 | }
|
---|
[677] | 689 | //output[32] = 0;
|
---|
[688] | 690 | ret->val.value_str32 = output;
|
---|
[441] | 691 | ret->type = sl_str32;
|
---|
| 692 | return 0;
|
---|
| 693 | }
|
---|
[677] | 694 |
|
---|
| 695 | //Sorry rossy, I broke this. FFI isnt in windows
|
---|
| 696 | /*
|
---|
[474] | 697 | uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[440] | 698 | {
|
---|
[677] | 699 |
|
---|
| 700 |
|
---|
| 701 | int ffi_ret;
|
---|
| 702 | char* str = NULL;
|
---|
| 703 | int size = 0;
|
---|
| 704 |
|
---|
| 705 | ffi_cif cif;
|
---|
| 706 | ffi_type* ffi_args[256];
|
---|
| 707 | void* values[256];
|
---|
| 708 | int i;
|
---|
| 709 | numargs = 0;
|
---|
| 710 | for(i = 0; args[i].type <= sl_void; i++)
|
---|
| 711 | {
|
---|
| 712 | //DDrConsole_PrintF("%i", args[i].type );
|
---|
| 713 | numargs++;
|
---|
| 714 |
|
---|
| 715 | }
|
---|
| 716 |
|
---|
[445] | 717 | if (numargs < 1 || args[0].type != sl_str32)
|
---|
| 718 | {
|
---|
| 719 | 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);
|
---|
| 720 | return 0;
|
---|
| 721 | }
|
---|
| 722 |
|
---|
| 723 | if (!args[0].value_str32)
|
---|
| 724 | args[0].value_str32 = "";
|
---|
| 725 |
|
---|
[440] | 726 |
|
---|
| 727 |
|
---|
[443] | 728 | ffi_args[0] = &ffi_type_pointer;
|
---|
[444] | 729 | values[0] = &str;
|
---|
[443] | 730 | ffi_args[1] = &ffi_type_uint32;
|
---|
[444] | 731 | values[1] = &size;
|
---|
[443] | 732 |
|
---|
[677] | 733 |
|
---|
[443] | 734 | for(i = 2; i < numargs + 2; i ++)
|
---|
[440] | 735 | {
|
---|
[444] | 736 | if (args[i - 2].type == sl_float)
|
---|
| 737 | {
|
---|
| 738 | float value_float = args[i - 2].value_float;
|
---|
| 739 | double* value_double = (double*)&(args[i - 2]);
|
---|
| 740 | *value_double = value_float;
|
---|
| 741 |
|
---|
| 742 | ffi_args[i] = &ffi_type_double;
|
---|
| 743 | values[i] = value_double;
|
---|
| 744 | }
|
---|
| 745 | else
|
---|
| 746 | {
|
---|
| 747 | ffi_args[i] = &ffi_type_pointer;
|
---|
| 748 | values[i] = &(args[i - 2].value);
|
---|
| 749 | }
|
---|
[440] | 750 | }
|
---|
| 751 |
|
---|
[444] | 752 | if (ffi_prep_cif(&cif, FFI_DEFAULT_ABI, i, &ffi_type_sint32, ffi_args) != FFI_OK)
|
---|
[445] | 753 | return 1;
|
---|
[677] | 754 | ffi_call(&cif, (void*)_snprintf, (void*)&ffi_ret, values);
|
---|
[444] | 755 | str = malloc(ffi_ret + 1);
|
---|
| 756 | size = ffi_ret + 1;
|
---|
[677] | 757 | ffi_call(&cif, (void*)_snprintf, (void*)&ffi_ret, values);
|
---|
[444] | 758 | ret->value_str32 = str;
|
---|
[443] | 759 | ret->type = sl_str32;
|
---|
[440] | 760 | return 0;
|
---|
| 761 | }
|
---|
[677] | 762 | */
|
---|
[447] | 763 | // Widescreen patch for talking heads.
|
---|
[474] | 764 | uint16_t ONICALL cinematic_start_patch(sl_callinfo* callinfo, unsigned int numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[447] | 765 | {
|
---|
[688] | 766 | args[1].val.value_int32 = (double)args[1].val.value_int32 / (double)(gl_eng->DisplayMode.Width) * (4.0 / 3.0 * (double)(gl_eng->DisplayMode.Height));
|
---|
[447] | 767 | return ((sl_func)(OniExe + 0x000f3830))(callinfo, numargs, args, dontuse1, dontuse2, ret);
|
---|
| 768 | }
|
---|
| 769 |
|
---|
[451] | 770 | bool ini_inbsl = false;
|
---|
| 771 | bool SLrIniCallback(char* section, bool newsection, char* name, char* value)
|
---|
| 772 | {
|
---|
[677] | 773 | if (newsection && !_stricmp(section, "bsl"))
|
---|
[451] | 774 | ini_inbsl = true;
|
---|
| 775 |
|
---|
| 776 | if (ini_inbsl)
|
---|
| 777 | {
|
---|
[677] | 778 | char* type = value;
|
---|
[451] | 779 | bool isptr = false;
|
---|
| 780 | sl_type bsl_type;
|
---|
| 781 |
|
---|
| 782 | if (value[0] == 'p' && value[1] == 't' && value[2] == 'r' && value[3] == ':')
|
---|
| 783 | {
|
---|
| 784 | isptr = true;
|
---|
| 785 | value += 4;
|
---|
| 786 | }
|
---|
| 787 |
|
---|
| 788 |
|
---|
[677] | 789 |
|
---|
[451] | 790 | for (; *type; type++)
|
---|
| 791 | if (*type == ':')
|
---|
| 792 | {
|
---|
| 793 | *type = '\0';
|
---|
| 794 | type++;
|
---|
| 795 | break;
|
---|
| 796 | }
|
---|
| 797 |
|
---|
| 798 | if (!*type)
|
---|
| 799 | DDrStartupMessage("badly formed bsl definition for \"%s\"", name);
|
---|
| 800 |
|
---|
| 801 | if (!strcmp(type, "int"))
|
---|
| 802 | bsl_type = sl_int32;
|
---|
| 803 | else if (!strcmp(type, "string"))
|
---|
| 804 | bsl_type = sl_str32;
|
---|
| 805 | else if (!strcmp(type, "float"))
|
---|
| 806 | bsl_type = sl_float;
|
---|
| 807 | else if (!strcmp(type, "bool"))
|
---|
| 808 | bsl_type = sl_bool;
|
---|
| 809 | else
|
---|
| 810 | {
|
---|
| 811 | DDrStartupMessage("unknown type in bsl definition for \"%s\"", name);
|
---|
| 812 | return true;
|
---|
| 813 | }
|
---|
| 814 |
|
---|
| 815 | if (isptr)
|
---|
| 816 | {
|
---|
| 817 | char* bsl_var = malloc(strlen(name) + 1);
|
---|
| 818 | memcpy(bsl_var, name, strlen(name) + 1);
|
---|
| 819 | switch (bsl_type)
|
---|
| 820 | {
|
---|
| 821 | case sl_int32:
|
---|
| 822 | SLrGlobalVariable_Register_Int32(bsl_var, "see daodan.ini", (int32_t*)(uint32_t)inifile_parseint(value, false));
|
---|
| 823 | break;
|
---|
| 824 | case sl_float:
|
---|
| 825 | SLrGlobalVariable_Register_Float(bsl_var, "see daodan.ini", (float*)(uint32_t)inifile_parseint(value, false));
|
---|
| 826 | break;
|
---|
| 827 | default:
|
---|
| 828 | break;
|
---|
| 829 | }
|
---|
| 830 | }
|
---|
| 831 | else
|
---|
| 832 | {
|
---|
| 833 | char* bsl_var = malloc(strlen(name) + 1 + sizeof(int32_t));
|
---|
| 834 | int32_t* bsl_val = (int32_t*)bsl_var;
|
---|
| 835 | bsl_var += sizeof(int32_t);
|
---|
| 836 | memcpy(bsl_var, name, strlen(name) + 1);
|
---|
| 837 |
|
---|
| 838 | switch (bsl_type)
|
---|
| 839 | {
|
---|
| 840 | case sl_int32:
|
---|
| 841 | *bsl_val = inifile_parseint(value, false);
|
---|
| 842 | SLrGlobalVariable_Register_Int32(bsl_var, "see daodan.ini", bsl_val);
|
---|
| 843 | break;
|
---|
| 844 | case sl_float:
|
---|
| 845 | break;
|
---|
| 846 | default:
|
---|
| 847 | break;
|
---|
| 848 | }
|
---|
| 849 | }
|
---|
| 850 | }
|
---|
| 851 | return true;
|
---|
| 852 | }
|
---|
| 853 |
|
---|
| 854 | void SLrConfig()
|
---|
| 855 | {
|
---|
| 856 | DDrStartupMessage("re-parsing daodan.ini for bsl...");
|
---|
| 857 | inifile_read("daodan.ini", SLrIniCallback);
|
---|
| 858 | DDrStartupMessage("finished parsing");
|
---|
| 859 | }
|
---|
| 860 |
|
---|
[677] | 861 | void ONICALL SLrDaodan_Register_ReturnType(char* name, char* desc, char* argfmt, sl_type type, sl_func callback) {
|
---|
| 862 | char argfmt2[512];
|
---|
| 863 | uint16_t errornum;
|
---|
[681] | 864 | if (argfmt && strlen(argfmt) < 507) {
|
---|
| 865 | sprintf(argfmt2, "%s [|]", argfmt);
|
---|
| 866 | errornum = SLrScript_Command_Register_ReturnType(name, desc, argfmt2, type, callback);
|
---|
| 867 | if(errornum)
|
---|
| 868 | {
|
---|
| 869 | DDrStartupMessage("Registration of script command %s failed with error %i", name, errornum);
|
---|
| 870 | }
|
---|
| 871 | } else {
|
---|
| 872 | DDrStartupMessage("Registration of script command %s failed because of a too long argfmt", name);
|
---|
[677] | 873 | }
|
---|
| 874 | }
|
---|
| 875 |
|
---|
| 876 | void* TSrTest = 0;
|
---|
| 877 | uint16_t ONICALL new_text(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
|
---|
[439] | 878 | {
|
---|
[677] | 879 | void* TSFFTahoma;
|
---|
| 880 | int returnval;
|
---|
[470] | 881 |
|
---|
[677] | 882 | if(!TSrTest){
|
---|
| 883 | TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma);
|
---|
[689] | 884 | returnval = TSrContext_New( TSFFTahoma, 7, 1, 1, 0, &TSrTest);
|
---|
[677] | 885 | }
|
---|
[689] | 886 | DDrPatch_MakeCall((void*)0x004FBCEA, (void*)DDrText_Hook);
|
---|
[677] | 887 |
|
---|
| 888 | *dontuse2 = 1;
|
---|
| 889 | return 0;
|
---|
| 890 | }
|
---|
[470] | 891 |
|
---|
[677] | 892 | void SLrDaodan_Initalize()
|
---|
| 893 | {
|
---|
| 894 | SLrConfig();
|
---|
[484] | 895 |
|
---|
[677] | 896 | SLrScript_Command_Register_Void("debug_daodan","Adds text to screen", "", new_text);
|
---|
[484] | 897 |
|
---|
[439] | 898 | SLrScript_Command_Register_ReturnType("int32mul", "Multiplies two numbers", "n1:int n2:int", sl_int32, bsl_int32mul);
|
---|
| 899 | SLrScript_Command_Register_ReturnType("mul", "Multiplies two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_mul);
|
---|
| 900 | SLrScript_Command_Register_ReturnType("int32div", "Divides two numbers", "n1:int n2:int", sl_int32, bsl_int32div);
|
---|
| 901 | SLrScript_Command_Register_ReturnType("div", "Divides two numbers", "[int1:int|float1:float] [int2:int|float2:float]", sl_float, bsl_div);
|
---|
[677] | 902 | srand((uint32_t)time(NULL));
|
---|
[443] | 903 | SLrScript_Command_Register_ReturnType("int32rand", "Returns a pseudo-random number between two numbers (inclusive).", "start:int end:int", sl_int32, bsl_int32rand);
|
---|
[677] | 904 | SLrScript_Command_Register_ReturnType("d_getkills","Gets the number of kills a character has", "[ai_name:string | script_id:int] [|]", sl_int32, bsl_getkills);
|
---|
[446] | 905 | 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);
|
---|
[677] | 906 | 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);
|
---|
[481] | 907 | SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "ai_name:string", sl_int32, bsl_nametoindex);
|
---|
[677] | 908 | 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);
|
---|
| 909 | 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);
|
---|
| 910 | 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);
|
---|
| 911 | 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);
|
---|
| 912 | //d_holdkey is broken!
|
---|
| 913 | 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);
|
---|
| 914 | 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);
|
---|
| 915 | SLrScript_Command_Register_ReturnType("d_location","Returns the X, Y or Z coord of a character", "", sl_float, bsl_location);
|
---|
| 916 | 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);
|
---|
| 917 | SLrScript_Command_Register_Void("d_waitforkey","Waits for a keypress from the player", "key:string", bsl_waitforkey);
|
---|
[470] | 918 |
|
---|
[481] | 919 | //broken, only works for one damage type.
|
---|
[677] | 920 | //SLrDaodan_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_getattacker);
|
---|
[441] | 921 |
|
---|
[481] | 922 | //used for debugging.
|
---|
[677] | 923 | // SLrDaodan_Register_ReturnType("d_active","Returns a hex offset. ;)", "[ai_name:string | script_id:int]", sl_int32, bsl_getactiveoffset);
|
---|
[450] | 924 |
|
---|
[677] | 925 | SLrScript_Command_Register_Void("sprintf", "C-style sprintf.", "", bsl_sprintf);
|
---|
| 926 | SLrScript_Command_Register_ReturnType("st", "prints to console in color", "", sl_void, bsl_dprintcolored);
|
---|
| 927 | SLrScript_Command_Register_ReturnType("d_dprint", "prints to console in color", "", sl_void, bsl_dprintcolored);
|
---|
[447] | 928 | }
|
---|
[451] | 929 |
|
---|
[447] | 930 | void SLrDaodan_Patch()
|
---|
| 931 | {
|
---|
[689] | 932 | DDrPatch_Int32((int*)(OniExe + 0x000f3755), (int)cinematic_start_patch);
|
---|
[447] | 933 | }
|
---|