Exemplo n.º 1
0
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);
    }
}
Exemplo n.º 2
0
/*
 * Update cargo of @carrier for movement or destruction.
 * If the carrier is destroyed, destroy its cargo (planes, land units,
 * nukes).
 * Else update their location to the carrier's.  Any op sectors equal
 * to location get updated, too.
 * Return number of units updated.
 */
int
unit_update_cargo(struct empobj *carrier)
{
    int cargo_type;
    struct nstr_item ni;
    union empobj_storage obj;
    int n = 0;

    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)
		unit_teleport(&obj.gen, carrier->x, carrier->y);
	    else {
		mpr(obj.gen.own, "%s lost!\n", unit_nameof(&obj.gen));
		obj.gen.effic = 0;
	    }
	    put_empobj(cargo_type, obj.gen.uid, &obj);
	    n++;
	}
    }
    return n;
}