|
1 | 1 | // |
2 | 2 | // |
3 | 3 |
|
4 | | -#include <weapon/beam.h> |
| 4 | +#include "iff_defs/iff_defs.h" |
| 5 | +#include "weapon/beam.h" |
| 6 | + |
5 | 7 | #include "beam.h" |
| 8 | +#include "mc_info.h" |
6 | 9 | #include "object.h" |
7 | | -#include "weaponclass.h" |
8 | | -#include "vecmath.h" |
9 | 10 | #include "subsystem.h" |
10 | | -#include "mc_info.h" |
| 11 | +#include "team.h" |
| 12 | +#include "vecmath.h" |
| 13 | +#include "weaponclass.h" |
11 | 14 |
|
12 | 15 | namespace scripting { |
13 | 16 | namespace api { |
@@ -218,6 +221,24 @@ ADE_VIRTVAR(ParentSubsystem, l_Beam, "subsystem", "Subsystem that beam is fired |
218 | 221 | return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(bp->objp, bp->subsys))); |
219 | 222 | } |
220 | 223 |
|
| 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 | + |
221 | 242 | ADE_FUNC(getCollisionCount, l_Beam, NULL, "Get the number of collisions in frame.", "number", "Number of beam collisions") |
222 | 243 | { |
223 | 244 | object_h *objh; |
|
0 commit comments