*
* Known contributors to this file:
* Ron Koenderink, 2006-2007
- * Markus Armbruster, 2006-2011
+ * Markus Armbruster, 2006-2013
*/
#ifndef UNIT_H
extern void unit_put(struct emp_qelem *list, natid actor);
extern char *unit_path(int, struct empobj *, char *, size_t);
extern void unit_view(struct emp_qelem *);
+extern void unit_teleport(struct empobj *, coord, coord);
extern int unit_update_cargo(struct empobj *);
extern void unit_drop_cargo(struct empobj *, natid);
extern void unit_give_away(struct empobj *, natid, natid);
void
divine_load(struct empobj *unit, int type, int uid)
{
+ union empobj_storage carrier;
+
divine_load_unload(unit, type, uid, "loaded onto");
+ if (get_empobj(type, uid, &carrier)
+ && (unit->x != carrier.gen.x || unit->y != carrier.gen.y)) {
+ pr("%s teleported from %s to %s!",
+ unit_nameof(unit), xyas(unit->x, unit->y, player->cnum),
+ xyas(carrier.gen.x, carrier.gen.y, player->cnum));
+ unit_teleport(unit, carrier.gen.x, carrier.gen.y);
+ }
}
void
*
* Known contributors to this file:
* Ron Koenderink, 2007
- * Markus Armbruster, 2009-2011
+ * Markus Armbruster, 2009-2013
*/
#include <config.h>
}
}
+/*
+ * Teleport UNIT to X,Y.
+ * If UNIT's mission op-area is centered on it, keep it centered.
+ */
+void
+unit_teleport(struct empobj *unit, coord x, coord y)
+{
+ if (unit->opx == unit->x && unit->opy == unit->y) {
+ unit->opx = x;
+ unit->opy = y;
+ }
+ unit->x = x;
+ unit->y = y;
+}
+
/*
* Update cargo of CARRIER for movement or destruction.
* If the carrier is destroyed, destroy its cargo (planes, land units,
for (cargo_type = EF_PLANE; cargo_type <= EF_NUKE; cargo_type++) {
snxtitem_cargo(&ni, cargo_type, carrier->ef_type, carrier->uid);
while (nxtitem(&ni, &obj)) {
- if (!carrier->own) {
+ if (carrier->own)
+ unit_teleport(&obj.gen, carrier->x, carrier->y);
+ else {
mpr(obj.gen.own, "%s lost!\n", unit_nameof(&obj.gen));
obj.gen.effic = 0;
- } else {
- /* mission op-area centered on the obj travels with it */
- if (obj.gen.opx == obj.gen.x && obj.gen.opy == obj.gen.y) {
- obj.gen.opx = carrier->x;
- obj.gen.opy = carrier->y;
- }
- obj.gen.x = carrier->x;
- obj.gen.y = carrier->y;
}
put_empobj(cargo_type, obj.gen.uid, &obj);
n++;
1 98 1 -1 0 10 0 0 100 0 0 none 0 "" 9 0 -1 -1 () 0 0.00000
2 2 3 -1 0 10 -127 0 50 0 0 none 0 "" 0 0 -1 -1 (airburst) 0 0.00000
3 3 1 -1 0 10 -127 0 50 0 0 none 0 "a" 0 0 3 -1 () 0 0.00000
-4 3 1 -1 0 100 127 0 32767 0 0 none 0 "" 18 0 -1 4 () 0 0.00000
+4 3 3 -1 0 100 127 0 32767 0 0 none 0 "" 18 0 -1 4 () 0 0.00000
5 3 1 -1 0 100 127 0 32767 0 0 none 0 "" 18 0 -1 -1 () 0 0.00000
6 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000
7 0 0 0 0 0 0 0 0 0 0 none 0 "" 0 0 -1 -1 () 0 0.00000
1 98 1 -1 6 10 0 0 100 0 0 none 0 "" -1 0 42 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
2 2 3 -1 6 10 -127 0 50 0 0 none 0 "" -1 0 0 (group) "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
3 3 1 -1 6 10 -127 0 50 0 0 none 0 "a" 3 0 0 (injured) "jj" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
-4 3 1 -1 6 100 127 0 32767 0 0 none 0 "" -1 127 100 () "" 0 25 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 4 0
+4 3 3 -1 6 100 127 0 32767 0 0 none 0 "" 2 127 100 () "" 0 25 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
5 3 1 -1 6 100 127 0 32767 0 0 none 0 "" -1 127 100 () "" 0 25 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
6 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
7 0 0 0 0 0 0 0 0 0 0 none 0 "" -1 0 0 () "" 0 0 0 0 0 0 0 0 0 0 0 0 0 0 healthy 0 -1 0
# special case: move carrier's cargo away
edit('plane', 4, 'l', '5,1');
+# special case: load teleports to carrier
+edit('land', 4, 'S', 2);
+
# interactive edit
iedit('ship', 0, 'M 2', 'm 1', 'f 1');
iedit('ship', 0, 'R n', 'R ""');
Play#0 output Play#0 1 Can't move f1 Sopwith Camel #4 while it's loaded
Play#0 output Play#0 1 command failed
Play#0 output Play#0 6 0 640
+ Play#0 input edit u 4 S 2
+ Play#0 command edit
+ Play#0 output Play#0 1 sup supply #4 unloaded from land #4
+ Play#0 output Play#0 1 sup supply #4 loaded onto ship #2
+ Play#0 output Play#0 1 sup supply #4 teleported from 1,-1 to 3,-1!
+ Play#0 output Play#0 6 0 640
Play#0 input edit s 0
Play#0 command edit
Play#0 output Play#0 1 POGO (#0) cs cargo ship (#0)
Play#0 output Play#0 1 sup supply #4 loaded onto ship #4 by an act of POGO!
Play#0 output Play#0 1 sup supply #4 unloaded from ship #4 by an act of POGO!
Play#0 output Play#0 1 sup supply #4 loaded onto land #4 by an act of POGO!
+ Play#0 output Play#0 1 sup supply #4 unloaded from land #4 by an act of POGO!
+ Play#0 output Play#0 1 sup supply #4 loaded onto ship #2 by an act of POGO!
Play#0 output Play#0 1 Military reserves changed from 0 to 2147483647 by an act of POGO
Play#0 output Play#0 1 Money changed from 0 to 2147483647 by an act of POGO
Play#0 output Play#0 6 0 640