Skip to content

Commit c6cd2de

Browse files
authored
Merge pull request #6357 from Goober5000/swarminfo_corkscrewinfo_functions
use functions for getting swarm info and corkscrew info
2 parents 466995a + 24555ac commit c6cd2de

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

code/scripting/api/objs/weaponclass.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,7 @@ ADE_VIRTVAR(FreeFlightTime, l_Weaponclass, "number", "The time the weapon will f
336336
return ade_set_args(L, "f", Weapon_info[idx].free_flight_time);
337337
}
338338

339-
ADE_VIRTVAR(SwarmInfo, l_Weaponclass, nullptr, nullptr, "boolean, number, number",
340-
"If the weapon has the swarm flag , the number of swarm missiles, the swarm wait. Returns nil if the handle is invalid.")
339+
static int swarm_info_helper(lua_State* L)
341340
{
342341
int idx;
343342
if (!ade_get_args(L, "o", l_Weaponclass.Get(&idx)))
@@ -357,8 +356,20 @@ ADE_VIRTVAR(SwarmInfo, l_Weaponclass, nullptr, nullptr, "boolean, number, number
357356
return ade_set_args(L, "bii", flag, Weapon_info[idx].swarm_count, Weapon_info[idx].SwarmWait);
358357
}
359358

360-
ADE_VIRTVAR(CorkscrewInfo, l_Weaponclass, nullptr, nullptr, "boolean, number, number, number, boolean, number",
361-
"If the weapon has the corkscrew flag, the number of corkscrew missiles fired, the radius, the fire delay, counter rotate settings, the twist value. Returns nil if the handle is invalid.")
359+
ADE_VIRTVAR_DEPRECATED(SwarmInfo, l_Weaponclass, nullptr, nullptr, "boolean",
360+
"Returns whether the weapon has the swarm flag, or nil if the handle is invalid.",
361+
gameversion::version(24, 2), "Deprecated in favor of weaponclass:getSwarmInfo(), since virtvars can only return a single value.")
362+
{
363+
return swarm_info_helper(L);
364+
}
365+
366+
ADE_FUNC(getSwarmInfo, l_Weaponclass, nullptr, nullptr, "boolean, number, number",
367+
"Returns three values: a) whether the weapon has the swarm flag, b) the number of swarm missiles fired, c) the swarm wait. Returns nil if the handle is invalid.")
368+
{
369+
return swarm_info_helper(L);
370+
}
371+
372+
static int corkscrew_info_helper(lua_State* L)
362373
{
363374
int idx;
364375
if (!ade_get_args(L, "o", l_Weaponclass.Get(&idx)))
@@ -389,6 +400,19 @@ ADE_VIRTVAR(CorkscrewInfo, l_Weaponclass, nullptr, nullptr, "boolean, number, nu
389400
Weapon_info[idx].cs_twist);
390401
}
391402

403+
ADE_VIRTVAR_DEPRECATED(CorkscrewInfo, l_Weaponclass, nullptr, nullptr, "boolean, number, number, number, boolean, number",
404+
"Returns whether the weapon has the corkscrew flag, or nil if the handle is invalid.",
405+
gameversion::version(24, 2), "Deprecated in favor of weaponclass:getCorkscrewInfo(), since virtvars can only return a single value.")
406+
{
407+
return corkscrew_info_helper(L);
408+
}
409+
410+
ADE_FUNC(getCorkscrewInfo, l_Weaponclass, nullptr, nullptr, "boolean, number, number, number, boolean, number",
411+
"Returns five values: a) whether the weapon has the corkscrew flag, b) the number of corkscrew missiles fired, c) the radius, d) the fire delay, e) whether the weapon counter-rotations, f) the twist value. Returns nil if the handle is invalid.")
412+
{
413+
return corkscrew_info_helper(L);
414+
}
415+
392416
ADE_VIRTVAR(LifeMax, l_Weaponclass, "number", "Life of weapon in seconds", "number", "Life of weapon, or 0 if handle is invalid")
393417
{
394418
int idx;

0 commit comments

Comments
 (0)