|
65 | 65 | #include "scripting/api/objs/ship.h" |
66 | 66 | #include "scripting/api/objs/shipclass.h" |
67 | 67 | #include "scripting/api/objs/sound.h" |
| 68 | +#include "scripting/api/objs/support_rearm_pool.h" |
68 | 69 | #include "scripting/api/objs/team.h" |
69 | 70 | #include "scripting/api/objs/vecmath.h" |
70 | 71 | #include "scripting/api/objs/volumetric.h" |
@@ -262,67 +263,40 @@ ADE_FUNC(runSEXP, l_Mission, "string", "Runs the defined SEXP script within a `w |
262 | 263 | return ADE_RETURN_FALSE; |
263 | 264 | } |
264 | 265 |
|
265 | | -//****SUBLIBRARY: Mission/SupportRearmPool |
266 | | -ADE_LIB_DERIV(l_Mission_SupportRearmPool, "SupportRearmPool", nullptr, |
267 | | - "Array of mission support rearm pool values. Index is weapon class index.", l_Mission); |
| 266 | +//****SUBLIBRARY: Mission/SupportRearmPools |
| 267 | +ADE_LIB_DERIV(l_Mission_SupportRearmPools, |
| 268 | + "SupportRearmPools", |
| 269 | + nullptr, |
| 270 | + "Per-team mission support rearm pools (team indexed).", |
| 271 | + l_Mission); |
268 | 272 |
|
269 | | -ADE_INDEXER(l_Mission_SupportRearmPool, |
270 | | - "number/weaponclass IndexOrClass, number amount", |
271 | | - "Gets/sets support rearm pool value for a weapon class.\n" |
272 | | - "Values: -1 = unlimited, 0 = unavailable, >0 = limited amount.\n" |
273 | | - "If a weapon has $Disallow Support Rearm, this always returns 0 and ignores writes.", |
274 | | - "number", |
275 | | - "Current pool value for the weapon class.") |
| 273 | +ADE_INDEXER(l_Mission_SupportRearmPools, |
| 274 | + "number TeamIndex", |
| 275 | + "Gets support rearm pool handle for a specific team.", |
| 276 | + "support_rearm_pool_team", |
| 277 | + "Support rearm pool team handle, or invalid handle if index is out of range.") |
276 | 278 | { |
277 | 279 | int idx = -1; |
278 | | - int amount; |
279 | | - if (lua_isnumber(L, 2)) { |
280 | | - if (!ade_get_args(L, "*i|i", &idx, &amount)) { |
281 | | - return ADE_RETURN_NIL; |
282 | | - } |
283 | | - |
284 | | - if (idx < 1 || idx > weapon_info_size()) { |
285 | | - return ADE_RETURN_NIL; |
286 | | - } |
287 | | - |
288 | | - idx--; // Lua to C++ index |
289 | | - } else { |
290 | | - if (!ade_get_args(L, "*o|i", l_Weaponclass.Get(&idx), &amount)) { |
291 | | - return ADE_RETURN_NIL; |
292 | | - } |
293 | | - |
294 | | - if (idx < 0 || idx >= weapon_info_size()) { |
295 | | - return ADE_RETURN_NIL; |
296 | | - } |
| 280 | + if (!ade_get_args(L, "*i", &idx)) { |
| 281 | + return ade_set_error(L, "o", l_SupportRearmPoolTeam.Set(-1)); |
297 | 282 | } |
298 | 283 |
|
299 | | - if (ADE_SETTING_VAR) { |
300 | | - if (!Weapon_info[idx].disallow_rearm) { |
301 | | - if (amount < 0) { |
302 | | - The_mission.support_ships.rearm_weapon_pool[idx] = -1; |
303 | | - } else { |
304 | | - The_mission.support_ships.rearm_weapon_pool[idx] = amount; |
305 | | - } |
306 | | - } else { |
307 | | - The_mission.support_ships.rearm_weapon_pool[idx] = 0; |
308 | | - } |
309 | | - } |
310 | | - |
311 | | - if (Weapon_info[idx].disallow_rearm) { |
312 | | - return ade_set_args(L, "i", 0); |
| 284 | + idx--; // Lua to C++ index |
| 285 | + if (idx < 0 || idx >= Num_teams || idx >= MAX_TVT_TEAMS) { |
| 286 | + return ade_set_error(L, "o", l_SupportRearmPoolTeam.Set(-1)); |
313 | 287 | } |
314 | 288 |
|
315 | | - return ade_set_args(L, "i", The_mission.support_ships.rearm_weapon_pool[idx]); |
| 289 | + return ade_set_args(L, "o", l_SupportRearmPoolTeam.Set(idx)); |
316 | 290 | } |
317 | 291 |
|
318 | 292 | ADE_FUNC(__len, |
319 | | - l_Mission_SupportRearmPool, |
| 293 | + l_Mission_SupportRearmPools, |
320 | 294 | nullptr, |
321 | | - "The number of weapon classes in the support rearm pool array", |
| 295 | + "The number of support rearm pool teams.", |
322 | 296 | "number", |
323 | | - "The number of weapon classes.") |
| 297 | + "The number of TVT/loadout teams with support rearm pools.") |
324 | 298 | { |
325 | | - return ade_set_args(L, "i", weapon_info_size()); |
| 299 | + return ade_set_args(L, "i", MIN(Num_teams, MAX_TVT_TEAMS)); |
326 | 300 | } |
327 | 301 |
|
328 | 302 | //****SUBLIBRARY: Mission/Asteroids |
|
0 commit comments