2008-04-20 11:12:07 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file effectvehicle.cpp Implementation of everything generic to vehicles. */
|
2008-04-20 11:12:07 +00:00
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "landscape.h"
|
|
|
|
#include "industry_map.h"
|
|
|
|
#include "vehicle_func.h"
|
|
|
|
#include "sound_func.h"
|
|
|
|
#include "animated_tile_func.h"
|
|
|
|
#include "effectvehicle_base.h"
|
|
|
|
#include "effectvehicle_func.h"
|
|
|
|
|
|
|
|
#include "table/sprites.h"
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void ChimneySmokeInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
uint32 r = Random();
|
|
|
|
v->cur_image = SPR_CHIMNEY_SMOKE_0 + GB(r, 0, 3);
|
|
|
|
v->progress = GB(r, 16, 3);
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool ChimneySmokeTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
if (v->progress > 0) {
|
|
|
|
v->progress--;
|
|
|
|
} else {
|
|
|
|
TileIndex tile = TileVirtXY(v->x_pos, v->y_pos);
|
|
|
|
if (!IsTileType(tile, MP_INDUSTRY)) {
|
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (v->cur_image != SPR_CHIMNEY_SMOKE_7) {
|
|
|
|
v->cur_image++;
|
|
|
|
} else {
|
|
|
|
v->cur_image = SPR_CHIMNEY_SMOKE_0;
|
|
|
|
}
|
|
|
|
v->progress = 7;
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void SteamSmokeInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->cur_image = SPR_STEAM_SMOKE_0;
|
|
|
|
v->progress = 12;
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool SteamSmokeTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
bool moved = false;
|
|
|
|
|
|
|
|
v->progress++;
|
|
|
|
|
|
|
|
if ((v->progress & 7) == 0) {
|
|
|
|
v->z_pos++;
|
|
|
|
moved = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((v->progress & 0xF) == 4) {
|
|
|
|
if (v->cur_image != SPR_STEAM_SMOKE_4) {
|
|
|
|
v->cur_image++;
|
|
|
|
} else {
|
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
moved = true;
|
|
|
|
}
|
|
|
|
|
2009-03-11 20:43:14 +00:00
|
|
|
if (moved) VehicleMove(v, true);
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void DieselSmokeInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->cur_image = SPR_DIESEL_SMOKE_0;
|
|
|
|
v->progress = 0;
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool DieselSmokeTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->progress++;
|
|
|
|
|
|
|
|
if ((v->progress & 3) == 0) {
|
|
|
|
v->z_pos++;
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2008-04-20 11:12:07 +00:00
|
|
|
} else if ((v->progress & 7) == 1) {
|
|
|
|
if (v->cur_image != SPR_DIESEL_SMOKE_5) {
|
|
|
|
v->cur_image++;
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2008-04-20 11:12:07 +00:00
|
|
|
} else {
|
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void ElectricSparkInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->cur_image = SPR_ELECTRIC_SPARK_0;
|
|
|
|
v->progress = 1;
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool ElectricSparkTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
if (v->progress < 2) {
|
|
|
|
v->progress++;
|
|
|
|
} else {
|
|
|
|
v->progress = 0;
|
|
|
|
if (v->cur_image != SPR_ELECTRIC_SPARK_5) {
|
|
|
|
v->cur_image++;
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2008-04-20 11:12:07 +00:00
|
|
|
} else {
|
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void SmokeInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->cur_image = SPR_SMOKE_0;
|
|
|
|
v->progress = 12;
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool SmokeTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
bool moved = false;
|
|
|
|
|
|
|
|
v->progress++;
|
|
|
|
|
|
|
|
if ((v->progress & 3) == 0) {
|
|
|
|
v->z_pos++;
|
|
|
|
moved = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((v->progress & 0xF) == 4) {
|
|
|
|
if (v->cur_image != SPR_SMOKE_4) {
|
|
|
|
v->cur_image++;
|
|
|
|
} else {
|
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
moved = true;
|
|
|
|
}
|
|
|
|
|
2009-03-11 20:43:14 +00:00
|
|
|
if (moved) VehicleMove(v, true);
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void ExplosionLargeInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->cur_image = SPR_EXPLOSION_LARGE_0;
|
|
|
|
v->progress = 0;
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool ExplosionLargeTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->progress++;
|
|
|
|
if ((v->progress & 3) == 0) {
|
|
|
|
if (v->cur_image != SPR_EXPLOSION_LARGE_F) {
|
|
|
|
v->cur_image++;
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2008-04-20 11:12:07 +00:00
|
|
|
} else {
|
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void BreakdownSmokeInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->cur_image = SPR_BREAKDOWN_SMOKE_0;
|
|
|
|
v->progress = 0;
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool BreakdownSmokeTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->progress++;
|
|
|
|
if ((v->progress & 7) == 0) {
|
|
|
|
if (v->cur_image != SPR_BREAKDOWN_SMOKE_3) {
|
|
|
|
v->cur_image++;
|
|
|
|
} else {
|
|
|
|
v->cur_image = SPR_BREAKDOWN_SMOKE_0;
|
|
|
|
}
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
v->animation_state--;
|
|
|
|
if (v->animation_state == 0) {
|
2008-04-20 11:12:07 +00:00
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void ExplosionSmallInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->cur_image = SPR_EXPLOSION_SMALL_0;
|
|
|
|
v->progress = 0;
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool ExplosionSmallTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->progress++;
|
|
|
|
if ((v->progress & 3) == 0) {
|
|
|
|
if (v->cur_image != SPR_EXPLOSION_SMALL_B) {
|
|
|
|
v->cur_image++;
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2008-04-20 11:12:07 +00:00
|
|
|
} else {
|
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void BulldozerInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->cur_image = SPR_BULLDOZER_NE;
|
|
|
|
v->progress = 0;
|
2009-05-22 18:56:25 +00:00
|
|
|
v->animation_state = 0;
|
|
|
|
v->animation_substate = 0;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct BulldozerMovement {
|
|
|
|
byte direction:2;
|
|
|
|
byte image:2;
|
|
|
|
byte duration:3;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BulldozerMovement _bulldozer_movement[] = {
|
|
|
|
{ 0, 0, 4 },
|
|
|
|
{ 3, 3, 4 },
|
|
|
|
{ 2, 2, 7 },
|
|
|
|
{ 0, 2, 7 },
|
|
|
|
{ 1, 1, 3 },
|
|
|
|
{ 2, 2, 7 },
|
|
|
|
{ 0, 2, 7 },
|
|
|
|
{ 1, 1, 3 },
|
|
|
|
{ 2, 2, 7 },
|
|
|
|
{ 0, 2, 7 },
|
|
|
|
{ 3, 3, 6 },
|
|
|
|
{ 2, 2, 6 },
|
|
|
|
{ 1, 1, 7 },
|
|
|
|
{ 3, 1, 7 },
|
|
|
|
{ 0, 0, 3 },
|
|
|
|
{ 1, 1, 7 },
|
|
|
|
{ 3, 1, 7 },
|
|
|
|
{ 0, 0, 3 },
|
|
|
|
{ 1, 1, 7 },
|
|
|
|
{ 3, 1, 7 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
int8 x;
|
|
|
|
int8 y;
|
|
|
|
} _inc_by_dir[] = {
|
|
|
|
{ -1, 0 },
|
|
|
|
{ 0, 1 },
|
|
|
|
{ 1, 0 },
|
|
|
|
{ 0, -1 }
|
|
|
|
};
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool BulldozerTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->progress++;
|
|
|
|
if ((v->progress & 7) == 0) {
|
2009-05-22 18:56:25 +00:00
|
|
|
const BulldozerMovement *b = &_bulldozer_movement[v->animation_state];
|
2008-04-20 11:12:07 +00:00
|
|
|
|
|
|
|
v->cur_image = SPR_BULLDOZER_NE + b->image;
|
|
|
|
|
|
|
|
v->x_pos += _inc_by_dir[b->direction].x;
|
|
|
|
v->y_pos += _inc_by_dir[b->direction].y;
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
v->animation_substate++;
|
|
|
|
if (v->animation_substate >= b->duration) {
|
|
|
|
v->animation_substate = 0;
|
|
|
|
v->animation_state++;
|
|
|
|
if (v->animation_state == lengthof(_bulldozer_movement)) {
|
2008-04-20 11:12:07 +00:00
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static void BubbleInit(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
v->cur_image = SPR_BUBBLE_GENERATE_0;
|
|
|
|
v->spritenum = 0;
|
|
|
|
v->progress = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct BubbleMovement {
|
|
|
|
int8 x:4;
|
|
|
|
int8 y:4;
|
|
|
|
int8 z:4;
|
|
|
|
byte image:4;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define MK(x, y, z, i) { x, y, z, i }
|
|
|
|
#define ME(i) { i, 4, 0, 0 }
|
|
|
|
|
|
|
|
static const BubbleMovement _bubble_float_sw[] = {
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(1, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(1, 0, 1, 2),
|
|
|
|
ME(1)
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static const BubbleMovement _bubble_float_ne[] = {
|
|
|
|
MK( 0, 0, 1, 0),
|
|
|
|
MK(-1, 0, 1, 1),
|
|
|
|
MK( 0, 0, 1, 0),
|
|
|
|
MK(-1, 0, 1, 2),
|
|
|
|
ME(1)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BubbleMovement _bubble_float_se[] = {
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 1, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 1, 1, 2),
|
|
|
|
ME(1)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BubbleMovement _bubble_float_nw[] = {
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, -1, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, -1, 1, 2),
|
|
|
|
ME(1)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BubbleMovement _bubble_burst[] = {
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 7),
|
|
|
|
MK(0, 0, 1, 8),
|
|
|
|
MK(0, 0, 1, 9),
|
|
|
|
ME(0)
|
|
|
|
};
|
|
|
|
|
|
|
|
static const BubbleMovement _bubble_absorb[] = {
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(0, 0, 1, 1),
|
|
|
|
MK(2, 1, 3, 0),
|
|
|
|
MK(1, 1, 3, 1),
|
|
|
|
MK(2, 1, 3, 0),
|
|
|
|
MK(1, 1, 3, 2),
|
|
|
|
MK(2, 1, 3, 0),
|
|
|
|
MK(1, 1, 3, 1),
|
|
|
|
MK(2, 1, 3, 0),
|
|
|
|
MK(1, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(1, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(1, 0, 1, 2),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(1, 0, 1, 1),
|
|
|
|
MK(0, 0, 1, 0),
|
|
|
|
MK(1, 0, 1, 2),
|
|
|
|
ME(2),
|
|
|
|
MK(0, 0, 0, 0xA),
|
|
|
|
MK(0, 0, 0, 0xB),
|
|
|
|
MK(0, 0, 0, 0xC),
|
|
|
|
MK(0, 0, 0, 0xD),
|
|
|
|
MK(0, 0, 0, 0xE),
|
|
|
|
ME(0)
|
|
|
|
};
|
|
|
|
#undef ME
|
|
|
|
#undef MK
|
|
|
|
|
|
|
|
static const BubbleMovement * const _bubble_movement[] = {
|
|
|
|
_bubble_float_sw,
|
|
|
|
_bubble_float_ne,
|
|
|
|
_bubble_float_se,
|
|
|
|
_bubble_float_nw,
|
|
|
|
_bubble_burst,
|
|
|
|
_bubble_absorb,
|
|
|
|
};
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
static bool BubbleTick(EffectVehicle *v)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
2009-01-09 09:50:33 +00:00
|
|
|
uint anim_state;
|
2008-04-20 11:12:07 +00:00
|
|
|
|
|
|
|
v->progress++;
|
2009-05-22 13:53:14 +00:00
|
|
|
if ((v->progress & 3) != 0) return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
|
|
|
|
if (v->spritenum == 0) {
|
|
|
|
v->cur_image++;
|
|
|
|
if (v->cur_image < SPR_BUBBLE_GENERATE_3) {
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2009-05-22 13:53:14 +00:00
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
2009-05-22 18:56:25 +00:00
|
|
|
if (v->animation_substate != 0) {
|
2008-08-20 16:51:08 +00:00
|
|
|
v->spritenum = GB(Random(), 0, 2) + 1;
|
2008-04-20 11:12:07 +00:00
|
|
|
} else {
|
|
|
|
v->spritenum = 6;
|
|
|
|
}
|
2009-01-09 09:50:33 +00:00
|
|
|
anim_state = 0;
|
2008-04-20 11:12:07 +00:00
|
|
|
} else {
|
2009-05-22 18:56:25 +00:00
|
|
|
anim_state = v->animation_state + 1;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:50:33 +00:00
|
|
|
const BubbleMovement *b = &_bubble_movement[v->spritenum - 1][anim_state];
|
2008-04-20 11:12:07 +00:00
|
|
|
|
|
|
|
if (b->y == 4 && b->x == 0) {
|
|
|
|
delete v;
|
2009-05-22 13:53:14 +00:00
|
|
|
return false;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (b->y == 4 && b->x == 1) {
|
2008-08-20 16:51:08 +00:00
|
|
|
if (v->z_pos > 180 || Chance16I(1, 96, Random())) {
|
2008-04-20 11:12:07 +00:00
|
|
|
v->spritenum = 5;
|
|
|
|
SndPlayVehicleFx(SND_2F_POP, v);
|
|
|
|
}
|
2009-01-09 09:50:33 +00:00
|
|
|
anim_state = 0;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (b->y == 4 && b->x == 2) {
|
|
|
|
TileIndex tile;
|
|
|
|
|
2009-01-09 09:50:33 +00:00
|
|
|
anim_state++;
|
2008-04-20 11:12:07 +00:00
|
|
|
SndPlayVehicleFx(SND_31_EXTRACT, v);
|
|
|
|
|
|
|
|
tile = TileVirtXY(v->x_pos, v->y_pos);
|
|
|
|
if (IsTileType(tile, MP_INDUSTRY) && GetIndustryGfx(tile) == GFX_BUBBLE_CATCHER) AddAnimatedTile(tile);
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
v->animation_state = anim_state;
|
2009-01-09 09:50:33 +00:00
|
|
|
b = &_bubble_movement[v->spritenum - 1][anim_state];
|
2008-04-20 11:12:07 +00:00
|
|
|
|
|
|
|
v->x_pos += b->x;
|
|
|
|
v->y_pos += b->y;
|
|
|
|
v->z_pos += b->z;
|
|
|
|
v->cur_image = SPR_BUBBLE_0 + b->image;
|
|
|
|
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, true);
|
2009-05-22 13:53:14 +00:00
|
|
|
|
|
|
|
return true;
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
typedef void EffectInitProc(EffectVehicle *v);
|
|
|
|
typedef bool EffectTickProc(EffectVehicle *v);
|
2008-04-20 11:12:07 +00:00
|
|
|
|
|
|
|
static EffectInitProc * const _effect_init_procs[] = {
|
|
|
|
ChimneySmokeInit,
|
|
|
|
SteamSmokeInit,
|
|
|
|
DieselSmokeInit,
|
|
|
|
ElectricSparkInit,
|
|
|
|
SmokeInit,
|
|
|
|
ExplosionLargeInit,
|
|
|
|
BreakdownSmokeInit,
|
|
|
|
ExplosionSmallInit,
|
|
|
|
BulldozerInit,
|
|
|
|
BubbleInit,
|
|
|
|
};
|
|
|
|
|
|
|
|
static EffectTickProc * const _effect_tick_procs[] = {
|
|
|
|
ChimneySmokeTick,
|
|
|
|
SteamSmokeTick,
|
|
|
|
DieselSmokeTick,
|
|
|
|
ElectricSparkTick,
|
|
|
|
SmokeTick,
|
|
|
|
ExplosionLargeTick,
|
|
|
|
BreakdownSmokeTick,
|
|
|
|
ExplosionSmallTick,
|
|
|
|
BulldozerTick,
|
|
|
|
BubbleTick,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
EffectVehicle *CreateEffectVehicle(int x, int y, int z, EffectVehicleType type)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
2009-01-09 14:59:02 +00:00
|
|
|
if (!Vehicle::CanAllocateItem()) return NULL;
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
EffectVehicle *v = new EffectVehicle();
|
2009-01-09 14:59:02 +00:00
|
|
|
v->subtype = type;
|
|
|
|
v->x_pos = x;
|
|
|
|
v->y_pos = y;
|
|
|
|
v->z_pos = z;
|
|
|
|
v->tile = 0;
|
|
|
|
v->UpdateDeltaXY(INVALID_DIR);
|
|
|
|
v->vehstatus = VS_UNCLICKABLE;
|
2008-04-20 11:12:07 +00:00
|
|
|
|
2009-01-09 14:59:02 +00:00
|
|
|
_effect_init_procs[type](v);
|
|
|
|
|
2009-03-11 20:43:14 +00:00
|
|
|
VehicleMove(v, false);
|
|
|
|
MarkSingleVehicleDirty(v);
|
2008-04-20 11:12:07 +00:00
|
|
|
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
EffectVehicle *CreateEffectVehicleAbove(int x, int y, int z, EffectVehicleType type)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
int safe_x = Clamp(x, 0, MapMaxX() * TILE_SIZE);
|
|
|
|
int safe_y = Clamp(y, 0, MapMaxY() * TILE_SIZE);
|
|
|
|
return CreateEffectVehicle(x, y, GetSlopeZ(safe_x, safe_y) + z, type);
|
|
|
|
}
|
|
|
|
|
2009-05-22 18:56:25 +00:00
|
|
|
EffectVehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVehicleType type)
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
|
|
|
return CreateEffectVehicle(v->x_pos + x, v->y_pos + y, v->z_pos + z, type);
|
|
|
|
}
|
|
|
|
|
2009-05-22 13:53:14 +00:00
|
|
|
bool EffectVehicle::Tick()
|
2008-04-20 11:12:07 +00:00
|
|
|
{
|
2009-05-22 13:53:14 +00:00
|
|
|
return _effect_tick_procs[this->subtype](this);
|
2008-04-20 11:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EffectVehicle::UpdateDeltaXY(Direction direction)
|
|
|
|
{
|
|
|
|
this->x_offs = 0;
|
|
|
|
this->y_offs = 0;
|
|
|
|
this->x_extent = 1;
|
|
|
|
this->y_extent = 1;
|
|
|
|
this->z_extent = 1;
|
|
|
|
}
|