/* spawn a single drone */ void hs_spawn(dbref player, char *which) { dbref obj; hship *ship; obj = match_result(player, which, TYPE_THING, MAT_NEAR_THINGS); if (!RealGoodObject(obj)) { notify(player, "HSPACE: Unable to find that drone template."); return; } if (!IsDrone(obj)) { notify(player, "HSPACE: That is not a valid drone template."); return; } ship = create_drone(obj); if (!ship) { notify(player, "HSPACE: Failed to create the drone."); return; } notify_format(player, "HSPACE: Drone created at %s(#%d) %.0f %.0f %.0f.", Name(ship->uid->objnum), ship->uid->objnum, ship->x, ship->y, ship->z); return; }
bool Weapon::CanLockPoint(const Point& test, double& az, double& el, Point* obj) { Point pt = Transform(test); bool locked = true; // first compute az: if (fabs(pt.z) < 0.1) pt.z = 0.1; az = atan(pt.x / pt.z); if (pt.z < 0) az -= PI; if (az < -PI) az += 2*PI; // then, rotate target into az-coords to compute el: Camera tmp; tmp.Clone(aim_cam); aim_cam.Yaw(az); pt = Transform(test); aim_cam.Clone(tmp); if (fabs(pt.z) < 0.1) pt.z = 0.1; el = atan(pt.y / pt.z); if (obj) *obj = pt; // is the target in the basket? // clamp if necessary: if (az > aim_az_max) { az = aim_az_max; locked = false; } else if (az < aim_az_min) { az = aim_az_min; locked = false; } if (el > aim_el_max) { el = aim_el_max; locked = false; } else if (el < aim_el_min) { el = aim_el_min; locked = false; } if (IsDrone() && guided) { double firing_cone = 10*DEGREES; if (orders == MANUAL) firing_cone = 20*DEGREES; if (az < firing_cone && el < firing_cone) locked = true; } return locked; }