9 |
|
#include "Oni.h" |
10 |
|
#include "Oni_Character.h" |
11 |
|
#include "dSFMT\dSFMT.h" |
12 |
+ |
#include "Daodan_Character.h" |
13 |
|
|
14 |
|
uint16_t ONICALL bsl_int32mul(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
15 |
|
{ |
92 |
|
{ |
93 |
|
int index; |
94 |
|
if (numargs == 0) index = 0; |
95 |
+ |
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
96 |
|
else index = args[0].value_int32; |
97 |
|
int* killcount = ONgGameState + index * 0x16A0 + 0x1260 + 0x1670; |
98 |
|
ret->value_int32 = *killcount; |
104 |
|
{ |
105 |
|
int index; |
106 |
|
if (numargs == 0) index = 0; |
107 |
+ |
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
108 |
|
else index = args[0].value_int32; |
109 |
|
int* killcount = ONgGameState + index * 0x16A0 + 0x1260 + 0x1674; |
110 |
|
ret->value_int32 = *killcount; |
111 |
|
ret->type = sl_int32; |
112 |
|
return 0; |
113 |
|
} |
114 |
+ |
|
115 |
+ |
uint16_t ONICALL bsl_powerup(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
116 |
+ |
{ |
117 |
+ |
char powerup_list[7][16] = {"ammo", "cell", "hypo", "shield", "invis" , "lsi", "bossshield"}; |
118 |
+ |
int powerup_offset[7] = { 0xE, 0x12, 0x10, 0x24, 0x26, 0x20, -1}; |
119 |
+ |
char powerup_type[16] = "\0"; |
120 |
+ |
int index; |
121 |
+ |
if (numargs < 2 || args[1].type != sl_str32) return 1; |
122 |
+ |
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
123 |
+ |
else index = args[0].value_int32; |
124 |
+ |
int i; |
125 |
+ |
|
126 |
+ |
for(i = 0; i < 6; i++) |
127 |
+ |
{ |
128 |
+ |
if(!strcmp(args[1].value_str32,powerup_list[i])) |
129 |
+ |
{ |
130 |
+ |
sprintf(powerup_type,"%s",powerup_list[i]); |
131 |
+ |
break; |
132 |
+ |
} |
133 |
+ |
} |
134 |
+ |
|
135 |
+ |
//todo, add setting |
136 |
+ |
|
137 |
+ |
if (powerup_type[0] == 0) return 1; |
138 |
+ |
Character* Chr = ONgGameState + 0x1260; |
139 |
+ |
void* returnval = &(Chr[index]) + 0x194 + powerup_offset[i]; |
140 |
+ |
//*returnval = (int)Inv |
141 |
+ |
if (numargs >= 2) |
142 |
+ |
{ |
143 |
+ |
//*health = args[1].value_int32; |
144 |
+ |
} |
145 |
+ |
ret->value_int32 = (int)*(uint16_t*)returnval; |
146 |
+ |
ret->type = sl_int32; |
147 |
+ |
return 0; |
148 |
+ |
} |
149 |
+ |
|
150 |
+ |
uint16_t ONICALL bsl_health(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
151 |
+ |
{ |
152 |
+ |
int index; |
153 |
+ |
if (numargs == 0) index = 0; |
154 |
+ |
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
155 |
+ |
else index = args[0].value_int32; |
156 |
+ |
Character* Chr = ONgGameState + 0x1260 ; |
157 |
+ |
int* health = &Chr[index].Health; |
158 |
+ |
|
159 |
+ |
ret->value_int32 = *health; |
160 |
+ |
ret->type = sl_int32; |
161 |
+ |
|
162 |
+ |
if (numargs >= 2) { |
163 |
+ |
*health = args[1].value_int32; |
164 |
+ |
} |
165 |
+ |
ret->value_int32 = *health; |
166 |
+ |
ret->type = sl_int32; |
167 |
+ |
return 0; |
168 |
+ |
} |
169 |
+ |
|
170 |
+ |
uint16_t ONICALL bsl_maxhealth(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
171 |
+ |
{ |
172 |
+ |
int index; |
173 |
+ |
if (numargs == 0) index = 0; |
174 |
+ |
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
175 |
+ |
else index = args[0].value_int32; |
176 |
+ |
Character* Chr = ONgGameState + 0x1260 ; |
177 |
+ |
int* maxhealth = &Chr[index].MaxHealth; |
178 |
+ |
int oldmaxhealth = Chr[index].MaxHealth; |
179 |
+ |
int oldhealth = Chr->Health; |
180 |
+ |
if (numargs >= 2) { |
181 |
+ |
*maxhealth = args[1].value_int32; |
182 |
+ |
} |
183 |
+ |
if (numargs >= 3 && args[2].value_bool) { |
184 |
+ |
Chr->Health = (int)(((float)args[1].value_int32 / (float)oldmaxhealth) * (float)oldhealth); |
185 |
+ |
} |
186 |
+ |
ret->value_int32 = oldmaxhealth; |
187 |
+ |
ret->type = sl_int32; |
188 |
+ |
return 0; |
189 |
+ |
} |
190 |
+ |
|
191 |
+ |
uint16_t ONICALL bsl_getattacker(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
192 |
+ |
{ |
193 |
+ |
//broken...not only does it sometimes blam, but it returns a string when i want an int so i can study it :< |
194 |
+ |
int index; |
195 |
+ |
if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
196 |
+ |
else index = args[0].value_int32; |
197 |
+ |
|
198 |
+ |
|
199 |
+ |
if(ONrGetActiveCharacter(ONgGameState + 0x1260 + index * 0x16A0)) return 1; |
200 |
+ |
|
201 |
+ |
int attacker= (int)(ONrGetActiveCharacter(ONgGameState + 0x1260 + index * 0x16A0) + 0x120); |
202 |
+ |
ret->type = sl_int32; |
203 |
+ |
ret->value_int32 = attacker; |
204 |
+ |
return 0; |
205 |
+ |
} |
206 |
+ |
|
207 |
+ |
|
208 |
+ |
uint16_t ONICALL bsl_chrname(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
209 |
+ |
{ |
210 |
+ |
int index; |
211 |
+ |
if (numargs == 0) index = 0; |
212 |
+ |
else if (args[0].type == sl_str32) index = DDrGetCharacterIndexFromName(args[0].value_str32); |
213 |
+ |
else index = args[0].value_int32; |
214 |
+ |
if (index == -1) { |
215 |
+ |
ret->type = sl_str32; |
216 |
+ |
ret->value_str32 = "NULL"; |
217 |
+ |
return 0; |
218 |
+ |
} |
219 |
+ |
char* name = ONgGameState + 0x1260 + index * 0x16A0 + 0x14; |
220 |
+ |
if (numargs == 2) { |
221 |
+ |
strncpy(name, (char*)args[1].value_str32, 31); |
222 |
+ |
} |
223 |
+ |
|
224 |
+ |
ret->type = sl_str32; |
225 |
+ |
ret->value_str32 = name; |
226 |
+ |
|
227 |
+ |
return 0; |
228 |
+ |
} |
229 |
+ |
|
230 |
+ |
|
231 |
+ |
uint16_t ONICALL bsl_count(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
232 |
+ |
{ |
233 |
+ |
//testing numargs... |
234 |
+ |
ret->type = sl_int32; |
235 |
+ |
ret->value_int32 = numargs; |
236 |
+ |
return 0; |
237 |
+ |
} |
238 |
+ |
|
239 |
+ |
uint16_t ONICALL bsl_dprintcolored(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
240 |
+ |
{ |
241 |
+ |
//TODO: figure out why our implementation of dprint shows after dev mode is turned off |
242 |
+ |
RGBA color; |
243 |
+ |
RGBA shade; |
244 |
+ |
|
245 |
+ |
if(numargs == 0) return 0; |
246 |
+ |
if(numargs > 1 ) color.R = (char)args[1].value_int32; |
247 |
+ |
else color.R = 255; |
248 |
+ |
if(numargs > 2 ) color.G = (char)args[2].value_int32; |
249 |
+ |
else color.G = 255; |
250 |
+ |
if(numargs > 3 ) color.B = (char)args[3].value_int32; |
251 |
+ |
else color.B = 255; |
252 |
+ |
color.A = 0; |
253 |
+ |
if(numargs > 5 ) shade.R = (char)args[5].value_int32; |
254 |
+ |
else shade.R = 0x3F; |
255 |
+ |
if(numargs > 6 ) shade.G = (char)args[6].value_int32; |
256 |
+ |
else shade.G = 0x3F; |
257 |
+ |
if(numargs > 7 ) shade.B = (char)args[7].value_int32; |
258 |
+ |
else shade.B = 0x3F; |
259 |
+ |
shade.A = 0; |
260 |
+ |
|
261 |
+ |
DDrConsole_PrintColored(args[0].value_str32, 1, color, shade); |
262 |
+ |
return 0; |
263 |
+ |
} |
264 |
+ |
|
265 |
+ |
|
266 |
+ |
uint16_t ONICALL bsl_nametoindex(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
267 |
+ |
{ |
268 |
+ |
ret->type = sl_int32; |
269 |
+ |
ret->value_int32 = DDrGetCharacterIndexFromName(args[0].value_str32); |
270 |
+ |
return 0; |
271 |
+ |
} |
272 |
|
/* |
273 |
|
uint16_t ONICALL bsl_sprintf(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], void* dontuse1, void* dontuse2, sl_arg* ret) |
274 |
|
{ |
353 |
|
dsfmt_gv_init_gen_rand((uint32_t)time(NULL)); |
354 |
|
SLrScript_Command_Register_ReturnType("int32rand", "Returns a pseudo-random number between two numbers (inclusive).", "start:int end:int", sl_int32, bsl_int32rand); |
355 |
|
|
356 |
< |
SLrScript_Command_Register_ReturnType("chr_getkills","Gets the number of kills a character has", "[chrindex:int]", sl_int32, bsl_getkills); |
357 |
< |
SLrScript_Command_Register_ReturnType("chr_getdamage","Gets the amount of damage a character has caused", "[chrindex:int]", sl_int32, bsl_getdamage); |
356 |
> |
SLrScript_Command_Register_ReturnType("d_getkills","Gets the number of kills a character has", "[ai_name:str | script_id:int]", sl_int32, bsl_getkills); |
357 |
> |
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); |
358 |
> |
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); |
359 |
> |
SLrScript_Command_Register_ReturnType("d_getindex","Converts a character's name to its index", "script_id:int", sl_int32, bsl_nametoindex); |
360 |
> |
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); |
361 |
> |
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); |
362 |
> |
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); |
363 |
> |
//broken. sometimes crashes, and sometimes returns a string... : / |
364 |
> |
SLrScript_Command_Register_ReturnType("d_getattacker","Gets the last person to hurt a character", "[ai_name:string | script_id:int]", sl_int32, bsl_chrname); |
365 |
|
|
366 |
|
SLrScript_Command_Register_ReturnType("sprintf", "C-style sprintf.", "format:string arg1 arg2 ...", sl_str32, bsl_sprintf); |
367 |
< |
} |
367 |
> |
|
368 |
> |
SLrScript_Command_Register_ReturnType("dprintcolor", "prints to console in color", "text:string [color: r b g] [color: r b g]", sl_void, bsl_dprintcolored); |
369 |
> |
} |