(svn r26872) -Change: give the disaster vehicles the same treatment as aircraft in r26866; make the ascend and descend if needed to cross high mountains (based on patch by ic111)

pull/155/head
rubidium 10 years ago
parent c709953a3b
commit 3dfb423446

@ -36,6 +36,7 @@
#include "core/random_func.hpp"
#include "core/backup_type.hpp"
#include "zoom_func.h"
#include "disaster_vehicle.h"
#include "table/strings.h"
@ -763,6 +764,8 @@ int GetAircraftFlightLevel(T *v, bool takeoff)
return z;
}
template int GetAircraftFlightLevel(DisasterVehicle *v, bool takeoff = false);
/**
* Find the entry point to an airport depending on direction which
* the airport is being approached from. Each airport can have up to

@ -55,8 +55,6 @@
/** Delay counter for considering the next disaster. */
uint16 _disaster_delay;
static const uint INITIAL_DISASTER_VEHICLE_ZPOS = 135; ///< Initial Z position of flying disaster vehicles.
static void DisasterClearSquare(TileIndex tile)
{
if (EnsureNoVehicleOnGround(tile).Failed()) return;
@ -137,11 +135,12 @@ DisasterVehicle::DisasterVehicle(int x, int y, Direction direction, DisasterSubT
case ST_HELICOPTER:
case ST_BIG_UFO:
case ST_BIG_UFO_DESTROYER:
this->z_pos = INITIAL_DISASTER_VEHICLE_ZPOS;
GetAircraftFlightLevelBounds(this, &this->z_pos, NULL);
break;
case ST_HELICOPTER_ROTORS:
this->z_pos = INITIAL_DISASTER_VEHICLE_ZPOS + ROTOR_Z_OFFSET;
GetAircraftFlightLevelBounds(this, &this->z_pos, NULL);
this->z_pos += ROTOR_Z_OFFSET;
break;
case ST_SMALL_SUBMARINE:
@ -229,7 +228,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
v->UpdatePosition(gp.x, gp.y, v->z_pos);
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
if (v->current_order.GetDestination() == 1) {
if (++v->age == 38) {
@ -267,7 +266,7 @@ static bool DisasterTick_Zeppeliner(DisasterVehicle *v)
AI::NewEvent(GetTileOwner(v->tile), new ScriptEventDisasterZeppelinerCleared(st->index));
}
v->UpdatePosition(v->x_pos, v->y_pos, v->z_pos);
v->UpdatePosition(v->x_pos, v->y_pos, GetAircraftFlightLevel(v));
delete v;
return false;
}
@ -323,7 +322,7 @@ static bool DisasterTick_Ufo(DisasterVehicle *v)
if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) {
v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
v->UpdatePosition(gp.x, gp.y, v->z_pos);
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
return true;
}
if (++v->age < 6) {
@ -426,7 +425,7 @@ static bool DisasterTick_Aircraft(DisasterVehicle *v, uint16 image_override, boo
v->image_override = (v->current_order.GetDestination() == 1 && HasBit(v->tick_counter, 2)) ? image_override : 0;
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
v->UpdatePosition(gp.x, gp.y, v->z_pos);
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
if ((leave_at_top && gp.x < (-10 * (int)TILE_SIZE)) || (!leave_at_top && gp.x > (int)(MapSizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1)) {
delete v;
@ -523,7 +522,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
v->UpdatePosition(gp.x, gp.y, v->z_pos);
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
return true;
}
@ -568,7 +567,7 @@ static bool DisasterTick_Big_Ufo(DisasterVehicle *v)
if (Delta(x, v->x_pos) + Delta(y, v->y_pos) >= (int)TILE_SIZE) {
v->direction = GetDirectionTowards(v, x, y);
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
v->UpdatePosition(gp.x, gp.y, v->z_pos);
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
return true;
}
@ -603,7 +602,7 @@ static bool DisasterTick_Big_Ufo_Destroyer(DisasterVehicle *v)
v->tick_counter++;
GetNewVehiclePosResult gp = GetNewVehiclePos(v);
v->UpdatePosition(gp.x, gp.y, v->z_pos);
v->UpdatePosition(gp.x, gp.y, GetAircraftFlightLevel(v));
if (gp.x > (int)(MapSizeX() * TILE_SIZE + 9 * TILE_SIZE) - 1) {
delete v;
@ -965,7 +964,7 @@ void ReleaseDisastersTargetingVehicle(VehicleID vehicle)
/* Revert to target-searching */
v->current_order.SetDestination(0);
v->dest_tile = RandomTile();
v->z_pos = INITIAL_DISASTER_VEHICLE_ZPOS;
GetAircraftFlightLevelBounds(v, &v->z_pos, NULL);
v->age = 0;
}
}

@ -39,6 +39,7 @@ enum DisasterSubType {
struct DisasterVehicle FINAL : public SpecializedVehicle<DisasterVehicle, VEH_DISASTER> {
SpriteID image_override; ///< Override for the default disaster vehicle sprite.
VehicleID big_ufo_destroyer_target; ///< The big UFO that this destroyer is supposed to bomb.
byte flags; ///< Flags about the state of the vehicle, @see AirVehicleFlags
/** For use by saveload. */
DisasterVehicle() : SpecializedVehicleBase() {}

@ -845,6 +845,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_CONDVAR(DisasterVehicle, image_override, SLE_UINT32, 191, SL_MAX_VERSION),
SLE_CONDVAR(DisasterVehicle, big_ufo_destroyer_target, SLE_FILE_U16 | SLE_VAR_U32, 0, 190),
SLE_CONDVAR(DisasterVehicle, big_ufo_destroyer_target, SLE_UINT32, 191, SL_MAX_VERSION),
SLE_CONDVAR(DisasterVehicle, flags, SLE_UINT8, 194, SL_MAX_VERSION),
SLE_CONDNULL(16, 2, 143), // old reserved space

Loading…
Cancel
Save