5 * Created by Alyssa Milburn on 02/02/2005.
6 * Copyright 2005 Alyssa Milburn. All rights reserved.
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
25 #include "AgentHelpers.h" // agentsTouching
28 CABN (command) left (integer) top (integer) right (integer) bottom (integer)
30 %pragma variants c1 c2 cv c3
32 void caosVM::c_CABN() {
34 VM_PARAM_INTEGER(bottom
)
35 VM_PARAM_INTEGER(right
)
37 VM_PARAM_INTEGER(left
)
40 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
42 v
->setCabinRect(left
, top
, right
, bottom
);
46 CABW (command) cap (integer)
49 void caosVM::c_CABW() {
54 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
60 SPAS (command) vehicle (agent) passenger (agent)
62 %pragma variants c1 c2 cv c3
64 make specified vehicle agent pick up specified passenger
66 void caosVM::c_SPAS() {
68 VM_PARAM_AGENT(passenger
)
69 VM_PARAM_AGENT(vehicle
)
72 valid_agent(passenger
);
74 // TODO: ensure passenger is a creature for c1/c2?
76 Vehicle
*v
= dynamic_cast<Vehicle
*>(vehicle
.get());
78 v
->addCarried(passenger
);
82 GPAS (command) family (integer) genus (integer) species (integer) options (integer)
85 pick up all nearby agents matching classifier, as passengers to target vehicle
86 options = 0 to pick up based on agent bounding rect, or 1 to pick up based on cabin rect
88 void caosVM::c_GPAS() {
90 VM_PARAM_INTEGER(options
)
91 // TODO: assert ranges for these
92 VM_PARAM_INTEGER(species
)
93 VM_PARAM_INTEGER(genus
)
94 VM_PARAM_INTEGER(family
)
97 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
100 // TODO: see other GPAS below
101 // TODO: are we sure c2e grabs passengers by agent rect?
102 // TODO: do we need to check greedycabin attr for anything?
103 for (std::list
<boost::shared_ptr
<Agent
> >::iterator i
= world
.agents
.begin(); i
!= world
.agents
.end(); i
++) {
104 boost::shared_ptr
<Agent
> a
= (*i
);
106 if (a
.get() == v
) continue;
107 if (family
&& family
!= a
->family
) continue;
108 if (genus
&& genus
!= a
->genus
) continue;
109 if (species
&& species
!= a
->species
) continue;
111 if (agentsTouching(a
.get(), v
)) {
120 %pragma variants c1 c2
121 %pragma implementation caosVM::c_GPAS_c2
123 void caosVM::c_GPAS_c2() {
125 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
128 // TODO: are we sure c1/c2 grab passengers by agent rect?
129 // TODO: do we need to check greedycabin attr for anything?
130 for (std::list
<boost::shared_ptr
<Agent
> >::iterator i
= world
.agents
.begin(); i
!= world
.agents
.end(); i
++) {
131 boost::shared_ptr
<Agent
> a
= (*i
);
133 if (a
.get() == v
) continue;
134 if (a
->family
!= 4) continue; // only pickup creatures (TODO: good check?)
136 if (agentsTouching(a
.get(), v
)) {
143 DPAS (command) family (integer) genus (integer) species (integer)
146 drop all agents matching classifier from target vehicle
148 void caosVM::c_DPAS() {
150 // TODO: assert ranges for these
151 VM_PARAM_INTEGER(species
)
152 VM_PARAM_INTEGER(genus
)
153 VM_PARAM_INTEGER(family
)
156 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
159 for (unsigned int i
= 0; i
< v
->passengers
.size(); i
++) {
160 AgentRef a
= v
->passengers
[i
];
162 if (a
.get() == v
) continue;
163 if (family
&& family
!= a
->family
) continue;
164 if (genus
&& genus
!= a
->genus
) continue;
165 if (species
&& species
!= a
->species
) continue;
167 i
--; // since we dropped the last one out of the list
174 %pragma variants c1 c2
175 %pragma implementation caosVM::c_DPAS_c2
177 void caosVM::c_DPAS_c2() {
179 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
182 for (unsigned int i
= 0; i
< v
->passengers
.size(); i
++) {
183 AgentRef a
= v
->passengers
[i
];
185 if (a
.get() == v
) continue;
186 if (a
->family
!= 4) continue; // only drop creatures (TODO: good check?)
188 i
--; // since we dropped the last one out of the list
193 CABP (command) plane (integer)
196 void caosVM::c_CABP() {
197 VM_PARAM_INTEGER(plane
)
200 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
203 v
->cabinplane
= plane
;
207 CABV (command) room_id (integer)
210 void caosVM::c_CABV() {
211 VM_PARAM_INTEGER(room_id
)
214 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
224 void caosVM::v_CABV() {
226 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
229 result
.setInt(-1); // TODO
233 RPAS (command) vehicle (agent) passenger (agent)
236 void caosVM::c_RPAS() {
237 VM_PARAM_AGENT(passenger
)
238 VM_PARAM_AGENT(vehicle
)
246 %pragma variants c1 c2
248 CAOS_LVALUE_TARG(XVEC
,
249 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get()); caos_assert(v
)
257 %pragma variants c1 c2
259 CAOS_LVALUE_TARG(YVEC
,
260 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get()); caos_assert(v
)
268 %pragma variants c1 c2
270 void caosVM::v_BUMP() {
272 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
275 result
.setInt(v
->getBump());
279 TELE (command) x (integer) y (integer)
281 %pragma variants c1 c2
283 Teleport occupants of target vehicle to (x, y).
285 void caosVM::c_TELE() {
290 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());
297 DPS2 (command) gravity (integer)
301 Drop passengers of targ vehicle, like DPAS. If gravity is zero, passengers do not get gravity activated.
303 void caosVM::c_DPS2() {
304 VM_PARAM_INTEGER(gravity
)
307 Vehicle
*v
= dynamic_cast<Vehicle
*>(targ
.get());