Skip to content

Commit 7318221

Browse files
authored
Merge pull request #5002 from Goober5000/beam_team
beam teams
2 parents 52455bb + c3477e8 commit 7318221

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

code/scripting/api/objs/beam.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
//
22
//
33

4-
#include <weapon/beam.h>
4+
#include "iff_defs/iff_defs.h"
5+
#include "weapon/beam.h"
6+
57
#include "beam.h"
8+
#include "mc_info.h"
69
#include "object.h"
7-
#include "weaponclass.h"
8-
#include "vecmath.h"
910
#include "subsystem.h"
10-
#include "mc_info.h"
11+
#include "team.h"
12+
#include "vecmath.h"
13+
#include "weaponclass.h"
1114

1215
namespace scripting {
1316
namespace api {
@@ -218,6 +221,24 @@ ADE_VIRTVAR(ParentSubsystem, l_Beam, "subsystem", "Subsystem that beam is fired
218221
return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(bp->objp, bp->subsys)));
219222
}
220223

224+
ADE_VIRTVAR(Team, l_Beam, "team", "Beam's team", "team", "Beam team, or invalid team handle if beam handle is invalid")
225+
{
226+
object_h* oh = nullptr;
227+
int nt = -1;
228+
if (!ade_get_args(L, "o|o", l_Beam.GetPtr(&oh), l_Team.Get(&nt)))
229+
return ade_set_error(L, "o", l_Team.Set(-1));
230+
231+
if (!oh->IsValid())
232+
return ade_set_error(L, "o", l_Team.Set(-1));
233+
234+
beam* b = &Beams[oh->objp->instance];
235+
236+
if (ADE_SETTING_VAR && nt >= 0 && nt < (int)Iff_info.size())
237+
b->team = (char)nt;
238+
239+
return ade_set_args(L, "o", l_Team.Set(b->team));
240+
}
241+
221242
ADE_FUNC(getCollisionCount, l_Beam, NULL, "Get the number of collisions in frame.", "number", "Number of beam collisions")
222243
{
223244
object_h *objh;

0 commit comments

Comments
 (0)