Commit e1828b9b authored by Romain Bignon's avatar Romain Bignon

add the "Boeing 767 (suicide plane)" entity (Al-Quaida special unit)

parent 67926aa4
...@@ -41,8 +41,6 @@ Note: Lire le fichier DEVELOPPEURS pour participer à des discussions. ...@@ -41,8 +41,6 @@ Note: Lire le fichier DEVELOPPEURS pour participer à des discussions.
- lance missile marin - lance missile marin
- URSS - URSS
- Goulags où il est possible de mettre les prisoniers et qui font rapporter de l'argent - Goulags où il est possible de mettre les prisoniers et qui font rapporter de l'argent
- France
- De Villepin ?
- Noisy - Noisy
- Réseau de cavernes - Réseau de cavernes
- Espagne - Espagne
......
...@@ -329,7 +329,7 @@ public: ...@@ -329,7 +329,7 @@ public:
virtual bool CanAttaq(const ECBEntity* e) virtual bool CanAttaq(const ECBEntity* e)
{ {
return e->Level() <= L_GROUND; return (e->Level() <= L_GROUND && !e->IsCountryMaker());
} }
virtual void Init(); virtual void Init();
...@@ -689,6 +689,7 @@ public: ...@@ -689,6 +689,7 @@ public:
switch(e->Type()) switch(e->Type())
{ {
case ECBEntity::E_PLANE: case ECBEntity::E_PLANE:
case ECBEntity::E_BOEING:
return true; return true;
default: default:
return false; return false;
......
...@@ -142,8 +142,8 @@ protected: ...@@ -142,8 +142,8 @@ protected:
* ECBEntity * * ECBEntity *
********************************************************************************************/ ********************************************************************************************/
/* Documentation is in server/Channels.h:EChannel::SendArm() */ /* Documentation is in server/Channels.h:EChannel::SendArm() */
#define ThereIsAttaq(a, b) ((a)->CanAttaq(b) && !(a)->Like(b) || \ #define ThereIsAttaq(a, b) (((a)->CanAttaq(b) && !(a)->Like(b)) || \
(b)->CanAttaq(a) && !(b)->Like(a)) ((b)->CanAttaq(a) && !(b)->Like(a)))
#define ARM_MOVE 0x0001 #define ARM_MOVE 0x0001
#define ARM_UNUSED 0x0002 /* ARM_UNUSED is unused */ #define ARM_UNUSED 0x0002 /* ARM_UNUSED is unused */
#define ARM_ATTAQ 0x0004 #define ARM_ATTAQ 0x0004
...@@ -208,6 +208,7 @@ public: ...@@ -208,6 +208,7 @@ public:
/*25*/E_AIRPORT, /*25*/E_AIRPORT,
/*26*/E_RADAR, /*26*/E_RADAR,
/*27*/E_EIFFELTOWER, /*27*/E_EIFFELTOWER,
/*28*/E_BOEING,
/*XX*/E_END /*XX*/E_END
}; };
......
...@@ -205,7 +205,7 @@ public: ...@@ -205,7 +205,7 @@ public:
virtual uint Cost() const { return 5000; } virtual uint Cost() const { return 5000; }
virtual uint InitNb() const { return 10; } virtual uint InitNb() const { return 10; }
virtual uint Step() const { return 7; } virtual uint Step() const { return 7; }
virtual uint Visibility() const { return 7; } virtual uint Visibility() const { return 5; }
virtual bool CanWalkOn(ECBCase *c) const { return true; } virtual bool CanWalkOn(ECBCase *c) const { return true; }
virtual e_level Level() const { return (!Deployed() ^ !!(EventType() & ARM_DEPLOY)) ? L_AIR : L_GROUND; } virtual e_level Level() const { return (!Deployed() ^ !!(EventType() & ARM_DEPLOY)) ? L_AIR : L_GROUND; }
virtual uint UnitaryCapacity() const { return 100; } virtual uint UnitaryCapacity() const { return 100; }
...@@ -231,6 +231,45 @@ public: ...@@ -231,6 +231,45 @@ public:
virtual bool WantAttaq(uint x, uint y, bool) { return false; } virtual bool WantAttaq(uint x, uint y, bool) { return false; }
}; };
/********************************************************************************************
* ECBBoeing *
********************************************************************************************/
class ECBBoeing : public virtual ECBEntity
{
public:
ENTITY_EMPTY_CONSTRUCTOR(ECBBoeing) {}
ENTITY_CONSTRUCTOR(ECBBoeing) {}
virtual void Init() { ECBEntity::Init(); SetDeployed(true); }
virtual e_type Type() const { return E_BOEING; }
virtual uint Cost() const { return 10000; }
virtual uint InitNb() const { return 10; }
virtual uint Step() const { return 5; }
virtual uint Visibility() const { return 5; }
virtual bool CanWalkOn(ECBCase *c) const { return true; }
virtual e_level Level() const { return (!Deployed() ^ !!(EventType() & ARM_DEPLOY)) ? L_AIR : L_GROUND; }
virtual uint Porty() const { return 5; }
virtual bool CanBeCreated(uint nation) const { return (nation == ECBPlayer::N_ALQUAIDA); }
virtual bool CanInvest(const ECBEntity* e) const { return false; }
bool CanAttaq(const ECBEntity *e)
{
if(e->IsCountryMaker() || e->Case() == Case())
return false;
else
return true;
}
bool CanCreate(const ECBEntity*) { return false; }
virtual bool IsPlane() const { return true; }
virtual bool WantDeploy() { return (DestCase()->Entities()->Find(E_AIRPORT).empty() == false); }
virtual bool WantAttaq(uint, uint, bool) { return Level() >= L_AIR; }
virtual bool WantMove(ECBMove::E_Move, int) { return !(EventType() & ARM_ATTAQ); }
};
/******************************************************************************************** /********************************************************************************************
* ECBMissiLauncher * * ECBMissiLauncher *
********************************************************************************************/ ********************************************************************************************/
......
...@@ -36,4 +36,5 @@ U_DECL(ECBarbedWire) ...@@ -36,4 +36,5 @@ U_DECL(ECBarbedWire)
U_DECL(ECAirPort) U_DECL(ECAirPort)
U_DECL(ECRadar) U_DECL(ECRadar)
U_DECL(ECEiffelTower) U_DECL(ECEiffelTower)
U_DECL(ECBoeing)
U_END U_END
/* server/Map.h - Header of Map.cpp /* server/Map.h - Header of Map.cpp
* *
* Copyright (C) 2005-2006 Romain Bignon <Progs@headfucking.net> * Copyright (C) 2005-2011 Romain Bignon <romain@menareants.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -105,7 +105,7 @@ public: ...@@ -105,7 +105,7 @@ public:
* @param c attaqued case * @param c attaqued case
* @return a vector of entities I will attaq * @return a vector of entities I will attaq
*/ */
virtual std::vector<ECBEntity*> GetAttaquedEntities(ECBCase* c) const { return c->Entities()->List(); } virtual std::vector<ECBEntity*> GetAttaquedEntities(ECBCase* c) { return c->Entities()->List(); }
/** Get an array of owners of there entities */ /** Get an array of owners of there entities */
static std::nrvector<TClient*> EntitiesToClients(std::vector<ECEntity*>); static std::nrvector<TClient*> EntitiesToClients(std::vector<ECEntity*>);
......
/* server/Units.cpp - Units in server /* server/Units.cpp - Units in server
* *
* Copyright (C) 2005-2006 Romain Bignon <Progs@headfucking.net> * Copyright (C) 2005-2011 Romain Bignon <romain@menareants.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -64,6 +64,87 @@ int ECPlane::TurnMoney(ECBPlayer* pl) ...@@ -64,6 +64,87 @@ int ECPlane::TurnMoney(ECBPlayer* pl)
return - (Containing()->Nb() * VolCost()); return - (Containing()->Nb() * VolCost());
} }
/********************************************************************************************
* ECBoeing *
********************************************************************************************/
bool ECBoeing::WantDeploy()
{
if(EventType() & (ARM_DEPLOY|ARM_ATTAQ))
return false;
/** \note On switch sur ce qu'on VEUT mettre */
switch(!Deployed())
{
case false:
if(EventType() & ARM_ATTAQ)
return false;
break;
case true:
if(!ECBBoeing::WantDeploy())
return false;
break;
}
return true;
}
bool ECBoeing::WantAttaq(uint mx, uint my, bool force)
{
if (Level() != L_AIR)
return false;
/* On n'attaque pas sur notre case */
if(DestCase()->X() == mx && DestCase()->Y() == my)
return false;
uint d = abs(DestCase()->X() - mx) + abs(DestCase()->Y() - my);
if(d > Porty())
return false;
return true;
}
std::vector<ECBEntity*> ECBoeing::GetAttaquedEntities(ECBCase* c)
{
std::vector<ECBEntity*> ents = ECEntity::GetAttaquedEntities(c);
ents.push_back(this);
return ents;
}
bool ECBoeing::Attaq(std::vector<ECEntity*> entities, ECEvent* event)
{
if (Level() != L_AIR)
return false;
for(std::vector<ECEntity*>::iterator it = entities.begin(); it != entities.end(); ++it)
if(*it != this && !Like(*it) && CanAttaq(*it) && (*it)->Case() != Case() && (*it)->Nb())
{
uint killed = 0;
if((*it)->IsBuilding()) killed = uint(Nb() * 50);
else if((*it)->IsInfantry()) killed = uint(Nb() * 100);
else if((*it)->IsPlane()) killed = uint(Nb() * 80);
else if((*it)->IsVehicule() || (*it)->IsNaval()) killed = uint(Nb() * 30);
else
{
FDebug(W_WARNING, "Shoot d'un type non supporté");
continue;
}
Shoot(*it, killed);
if(Owner())
Channel()->send_info(Owner(), EChannel::I_SHOOT, ECArgs(LongName(), (*it)->LongName(), TypToStr(killed)));
if((*it)->Owner())
Channel()->send_info((*it)->Owner(), EChannel::I_SHOOT, ECArgs(LongName(), (*it)->LongName(), TypToStr(killed)));
}
/* Suicide */
SetNb(0);
return false;
}
/******************************************************************************************** /********************************************************************************************
* ECJouano * * ECJouano *
********************************************************************************************/ ********************************************************************************************/
...@@ -134,7 +215,7 @@ bool ECJouano::Attaq(std::vector<ECEntity*> entities, ECEvent* event) ...@@ -134,7 +215,7 @@ bool ECJouano::Attaq(std::vector<ECEntity*> entities, ECEvent* event)
return false; return false;
} }
std::vector<ECBEntity*> ECJouano::GetAttaquedEntities(ECBCase* c) const std::vector<ECBEntity*> ECJouano::GetAttaquedEntities(ECBCase* c)
{ {
std::vector<ECBEntity*> entities; std::vector<ECBEntity*> entities;
ECBCase* cc = c->MoveLeft(Porty())->MoveUp(Porty()); ECBCase* cc = c->MoveLeft(Porty())->MoveUp(Porty());
...@@ -242,7 +323,7 @@ void ECMcDo::Played() ...@@ -242,7 +323,7 @@ void ECMcDo::Played()
Channel()->SendArm(0, new_caserne, ARM_CREATE, Case()->X(), Case()->Y()); Channel()->SendArm(0, new_caserne, ARM_CREATE, Case()->X(), Case()->Y());
new_caserne->SetNb(Nb()); new_caserne->SetNb(Nb());
Map()->AddAnEntity(new_caserne); Map()->AddAnEntity(new_caserne);
new_caserne->Create(false); new_caserne->Created(false);
SetZombie(); // Et on supprime notre brave McDo qui a rendu de mauvais services SetZombie(); // Et on supprime notre brave McDo qui a rendu de mauvais services
} }
...@@ -366,7 +447,7 @@ bool EContainer::Contain(ECBEntity* entity) ...@@ -366,7 +447,7 @@ bool EContainer::Contain(ECBEntity* entity)
bool EContainer::WantContain(ECEntity* entity, ECMove::Vector& moves) bool EContainer::WantContain(ECEntity* entity, ECMove::Vector& moves)
{ {
if(Containing() && Containing()->Type() != entity->Type() || entity->Locked() || entity->IsZombie() || !CanContain(entity)) if((Containing() && Containing()->Type() != entity->Type()) || entity->Locked() || entity->IsZombie() || !CanContain(entity))
return false; return false;
ECMove::E_Move move; ECMove::E_Move move;
...@@ -631,7 +712,10 @@ bool ECUnit::WantMove(ECBMove::E_Move move, int flags) ...@@ -631,7 +712,10 @@ bool ECUnit::WantMove(ECBMove::E_Move move, int flags)
{ {
/* J'ai déjà fait tous mes pas /* J'ai déjà fait tous mes pas
* Si on est deployé on ne peut pas bouger */ * Si on est deployé on ne peut pas bouger */
if(!RestStep() && !(flags & MOVE_SIMULE) || Deployed() ^ !!(EventType() & ARM_DEPLOY) || !Case() || Locked() && !(flags & MOVE_FORCE)) if((!RestStep() && !(flags & MOVE_SIMULE)) ||
(Deployed() ^ !!(EventType() & ARM_DEPLOY)) ||
!Case() ||
(Locked() && !(flags & MOVE_FORCE)))
return false; return false;
ECBCase *c = 0, *here = DestCase(); ECBCase *c = 0, *here = DestCase();
......
/* server/Units.h - Header of Units.cpp /* server/Units.h - Header of Units.cpp
* *
* Copyright (C) 2005-2006 Romain Bignon <Progs@headfucking.net> * Copyright (C) 2005-2011 Romain Bignon <romain@menareants.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -111,6 +111,24 @@ public: ...@@ -111,6 +111,24 @@ public:
virtual bool WantAttaq(uint x, uint y, bool) { return false; } virtual bool WantAttaq(uint x, uint y, bool) { return false; }
}; };
/********************************************************************************************
* ECBoeing *
********************************************************************************************/
class ECBoeing: public ECUnit, public ECBBoeing
{
/* Constructeur/Destructeur */
public:
ENTITY_CONSTRUCTOR(ECBoeing) {}
virtual bool WantDeploy();
virtual bool WantMove(ECBMove::E_Move m, int i) { return Level() >= L_AIR ? ECUnit::WantMove(m,i) : false; }
virtual bool WantAttaq(uint x, uint y, bool);
virtual bool Attaq(std::vector<ECEntity*> entities, ECEvent* event);
std::vector<ECBEntity*> GetAttaquedEntities(ECBCase* c);
};
/******************************************************************************************** /********************************************************************************************
* ECMissiLauncher * * ECMissiLauncher *
********************************************************************************************/ ********************************************************************************************/
...@@ -164,7 +182,7 @@ public: ...@@ -164,7 +182,7 @@ public:
virtual bool Attaq(std::vector<ECEntity*> entities, ECEvent* event); virtual bool Attaq(std::vector<ECEntity*> entities, ECEvent* event);
virtual void Invest(ECBEntity* e); virtual void Invest(ECBEntity* e);
std::vector<ECBEntity*> GetAttaquedEntities(ECBCase* c) const; std::vector<ECBEntity*> GetAttaquedEntities(ECBCase* c);
}; };
/******************************************************************************************** /********************************************************************************************
......
...@@ -256,7 +256,7 @@ void ECMine::Init() ...@@ -256,7 +256,7 @@ void ECMine::Init()
activeimg = new ECSpriteBase(Resources::Mine_ActFace()->path.c_str()); activeimg = new ECSpriteBase(Resources::Mine_ActFace()->path.c_str());
if(Owner() && Owner()->Color()) if(Owner() && Owner()->Color())
activeimg->ChangeColor(white_color, color_eq[Owner()->Color()]); activeimg->Gray2Color(color_eq[Owner()->Color()]);
} }
void ECMine::RecvData(ECData data) void ECMine::RecvData(ECData data)
......
...@@ -60,7 +60,7 @@ void ECPlayer::AddBreakPoint(BreakPoint bp) ...@@ -60,7 +60,7 @@ void ECPlayer::AddBreakPoint(BreakPoint bp)
{ {
assert(Channel()->Map()->ShowMap()->Window()); assert(Channel()->Map()->ShowMap()->Window());
ECSpriteBase* sprbase = new ECSpriteBase(Resources::Balise()->path.c_str()); ECSpriteBase* sprbase = new ECSpriteBase(Resources::Balise()->path.c_str());
sprbase->ChangeColor(white_color, color_eq[Color()]); sprbase->Gray2Color(color_eq[Color()]);
bp.sprite = new ECSprite(sprbase, Channel()->Map()->ShowMap()->Window()); bp.sprite = new ECSprite(sprbase, Channel()->Map()->ShowMap()->Window());
bp.text = Font::GetInstance(Font::Normal)->CreateSurface(bp.message, black_color); bp.text = Font::GetInstance(Font::Normal)->CreateSurface(bp.message, black_color);
breakpoints.push_back(bp); breakpoints.push_back(bp);
......
...@@ -397,7 +397,7 @@ void ECEntity::SetOwner(ECBPlayer* player) ...@@ -397,7 +397,7 @@ void ECEntity::SetOwner(ECBPlayer* player)
UpdateImages(); // Call the virtual method to update image list. UpdateImages(); // Call the virtual method to update image list.
} }
void ECEntity::PutImage(imgs_t i, ECSpriteBase* b) void ECEntity::PutImage(imgs_t i, ECSpriteBase* b, ECEntity::colorize_t colorize)
{ {
if (Owner()) if (Owner())
{ {
...@@ -405,15 +405,21 @@ void ECEntity::PutImage(imgs_t i, ECSpriteBase* b) ...@@ -405,15 +405,21 @@ void ECEntity::PutImage(imgs_t i, ECSpriteBase* b)
b = Owner()->GetSprite(Type(), i); b = Owner()->GetSprite(Type(), i);
else else
{ {
b = new ECSpriteBase(b->path.c_str()); b = b->Copy();
if(Owner()->Color())
switch(colorize) {
case GRAY2COLOR:
b->Gray2Color(color_eq[Owner()->Color()]);
break;
case WHITE2COLOR:
b->ChangeColor(white_color, color_eq[Owner()->Color()]);
break;
}
Owner()->SetSprite(Type(), i, b); Owner()->SetSprite(Type(), i, b);
} }
} }
images.insert(ImgList::value_type(i, b)); images.insert(ImgList::value_type(i, b));
if(Owner() && Owner()->Color())
images[i]->ChangeColor(white_color, color_eq[Owner()->Color()]);
if(images.size() == 1) SetImage(b); if(images.size() == 1) SetImage(b);
} }
......
...@@ -107,6 +107,11 @@ public: ...@@ -107,6 +107,11 @@ public:
}; };
typedef std::map<imgs_t, ECSpriteBase*> ImgList; typedef std::map<imgs_t, ECSpriteBase*> ImgList;
enum colorize_t {
GRAY2COLOR,
WHITE2COLOR
};
ECEntity(); ECEntity();
ECEntity(const Entity_ID _name, ECBPlayer* _owner, ECBCase* _case); ECEntity(const Entity_ID _name, ECBPlayer* _owner, ECBCase* _case);
...@@ -213,7 +218,7 @@ protected: ...@@ -213,7 +218,7 @@ protected:
uint max_nb; uint max_nb;
ImgList images; ImgList images;
void PutImage(imgs_t i, ECSpriteBase* b); void PutImage(imgs_t i, ECSpriteBase* b, colorize_t colorize = WHITE2COLOR);
ECSpriteBase* GetSprite(imgs_t t) { return images[t]; } ECSpriteBase* GetSprite(imgs_t t) { return images[t]; }
}; };
......
/* src/Resources.cpp - Struct which define all resources. /* src/Resources.cpp - Struct which define all resources.
* *
* Copyright (C) 2005-2007 Romain Bignon <Progs@headfucking.net> * Copyright (C) 2005-2011 Romain Bignon <romain@menareants.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -258,6 +258,13 @@ ...@@ -258,6 +258,13 @@
R_RESOURCE(ECSpriteBase, Plane_Dos, "units/plane/dos"); R_RESOURCE(ECSpriteBase, Plane_Dos, "units/plane/dos");
R_RESOURCE(ECSpriteBase, Plane_Deployed, "units/plane/deployed"); R_RESOURCE(ECSpriteBase, Plane_Deployed, "units/plane/deployed");
R_RESOURCE(ECSpriteBase, Plane_Reployed, "units/plane/reployed"); R_RESOURCE(ECSpriteBase, Plane_Reployed, "units/plane/reployed");
R_RESOURCE(ECImage, Boeing_Icon, PKGDATADIR_PICS "units/boeing_icon.png");
R_RESOURCE(ECSpriteBase, Boeing_Face, "units/boeing/face");
R_RESOURCE(ECSpriteBase, Boeing_Left, "units/boeing/left");
R_RESOURCE(ECSpriteBase, Boeing_Right, "units/boeing/right");
R_RESOURCE(ECSpriteBase, Boeing_Dos, "units/boeing/dos");
R_RESOURCE(ECSpriteBase, Boeing_Deployed, "units/boeing/deployed");
R_RESOURCE(ECSpriteBase, Boeing_Reployed, "units/boeing/reployed");
R_RESOURCE(ECImage, BarbedWire_Icon, PKGDATADIR_PICS "units/barbedwire_icon.png"); R_RESOURCE(ECImage, BarbedWire_Icon, PKGDATADIR_PICS "units/barbedwire_icon.png");
R_RESOURCE(ECSpriteBase, BarbedWire_Horiz, "units/barbedwire/horiz"); R_RESOURCE(ECSpriteBase, BarbedWire_Horiz, "units/barbedwire/horiz");
R_RESOURCE(ECSpriteBase, BarbedWire_Verti, "units/barbedwire/verti"); R_RESOURCE(ECSpriteBase, BarbedWire_Verti, "units/barbedwire/verti");
......
/* src/Resources.h - Header of Resources.cpp /* src/Resources.h - Header of Resources.cpp
* *
* Copyright (C) 2005-2007 Romain Bignon <Progs@headfucking.net> * Copyright (C) 2005-2011 Romain Bignon <romain@menareants.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -293,6 +293,13 @@ public: ...@@ -293,6 +293,13 @@ public:
R_RESOURCE(ECSpriteBase, Plane_Dos); R_RESOURCE(ECSpriteBase, Plane_Dos);
R_RESOURCE(ECSpriteBase, Plane_Deployed); R_RESOURCE(ECSpriteBase, Plane_Deployed);
R_RESOURCE(ECSpriteBase, Plane_Reployed); R_RESOURCE(ECSpriteBase, Plane_Reployed);
R_RESOURCE(ECImage, Boeing_Icon);
R_RESOURCE(ECSpriteBase, Boeing_Face);
R_RESOURCE(ECSpriteBase, Boeing_Left);
R_RESOURCE(ECSpriteBase, Boeing_Right);
R_RESOURCE(ECSpriteBase, Boeing_Dos);
R_RESOURCE(ECSpriteBase, Boeing_Deployed);
R_RESOURCE(ECSpriteBase, Boeing_Reployed);
R_RESOURCE(ECImage, BarbedWire_Icon); R_RESOURCE(ECImage, BarbedWire_Icon);
R_RESOURCE(ECSpriteBase, BarbedWire_Horiz); R_RESOURCE(ECSpriteBase, BarbedWire_Horiz);
R_RESOURCE(ECSpriteBase, BarbedWire_Verti); R_RESOURCE(ECSpriteBase, BarbedWire_Verti);
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
* $Id$ * $Id$
*/ */
#include "Debug.h"
#include "Units.h" #include "Units.h"
#include "gui/ShowMap.h" #include "gui/ShowMap.h"
#include "gui/ColorEdit.h" #include "gui/ColorEdit.h"
...@@ -186,6 +187,77 @@ void ECTourist::ChangeCase(ECBCase* newcase) ...@@ -186,6 +187,77 @@ void ECTourist::ChangeCase(ECBCase* newcase)
SetShowedCases(true); SetShowedCases(true);
} }
/********************************************************************************************
* ECBoeing *
********************************************************************************************/
std::string ECBoeing::SpecialInfo()
{
return !Deployed() ? _("Flying") : _("On ground");
}
bool ECBoeing::BeforeEvent(const std::vector<ECEntity*>& entities, ECase* c, EC_Client* me)
{
if (EventType() & ARM_ATTAQ)
{
int dx = c->X() - Case()->X() + 1;
int dy = c->Y() - Case()->Y();
if (!Case()->Visible() && !c->Visible())
return true;
switch(anim_state)
{
case AN_NONE:
if (dx > 0) {
if (dy > 0)
SetImage(GetSprite(dx >= dy ? I_Right : I_Down));
else
SetImage(GetSprite(dx >= -dy ? I_Right : I_Up));
} else {
if (dy > 0)
SetImage(GetSprite(-dx >= dy ? I_Left : I_Down));
else
SetImage(GetSprite(-dx >= -dy ? I_Left : I_Up));
}
SetAnim(true);
anim_state = AN_MOVING;
case AN_MOVING:
ImageSetXY(Image()->X() + dx, Image()->Y() + dy);
SDL_Delay(10);
if ((dx >= 0 ? (Image()->X() >= (c->Image()->X() + CASE_WIDTH)) : (Image()->X() < (c->Image()->X() + CASE_WIDTH))) &&
(dy >= 0 ? (Image()->Y() >= c->Image()->Y()) : (Image()->Y() < c->Image()->Y())))
{
anim_state = AN_DOWN;
if(c->Visible() && dynamic_cast<ECMap*>(c->Map())->ShowMap())
dynamic_cast<ECMap*>(c->Map())->ShowMap()->CenterTo(c);
SetImage(GetSprite(I_Left));
Image()->CopySpriteBase();
Image()->Gray2Color(color_eq[Owner()->Color()]);
ImageSetXY(c->Image()->X() + CASE_WIDTH, c->Image()->Y());
}
break;
case AN_DOWN:
Image()->RotoZoom(5, (double)CASE_WIDTH / Image()->GetWidth(),
(double)CASE_HEIGHT / Image()->GetHeight(),
true);
ImageSetXY(Image()->X() - 10, Image()->Y());
SDL_Delay(50);
if (Image()->X() < c->Image()->X())
{
anim_state = AN_NONE;
return true;
}
break;
}
return false;
}
return ECUnit::BeforeEvent(entities, c, me);
}
/******************************************************************************************** /********************************************************************************************
* ECPlane * * ECPlane *
********************************************************************************************/ ********************************************************************************************/
...@@ -275,7 +347,7 @@ bool ECMissiLauncher::AfterEvent(const std::vector<ECEntity*>& entities, ECase* ...@@ -275,7 +347,7 @@ bool ECMissiLauncher::AfterEvent(const std::vector<ECEntity*>& entities, ECase*
} }
/******************************************************************************************** /********************************************************************************************
* ECUnit * * ECUnit *
********************************************************************************************/ ********************************************************************************************/
bool ECUnit::BeforeEvent(const std::vector<ECEntity*>&, ECase*, EC_Client*) bool ECUnit::BeforeEvent(const std::vector<ECEntity*>&, ECase*, EC_Client*)
...@@ -382,7 +454,6 @@ bool ECUnit::MakeEvent(const std::vector<ECEntity*>& entities, ECase*, EC_Client ...@@ -382,7 +454,6 @@ bool ECUnit::MakeEvent(const std::vector<ECEntity*>& entities, ECase*, EC_Client
Image()->SetAnim(false); Image()->SetAnim(false);
SDL_Delay(20); SDL_Delay(20);
} }
SetImage(images[I_Right]);
} }
/* C'est un reploiement sans tirer, donc on utilise l'image du déploiement avec missile, mais dans l'ordre /* C'est un reploiement sans tirer, donc on utilise l'image du déploiement avec missile, mais dans l'ordre
* inverse */ * inverse */
...@@ -403,7 +474,6 @@ bool ECUnit::MakeEvent(const std::vector<ECEntity*>& entities, ECase*, EC_Client ...@@ -403,7 +474,6 @@ bool ECUnit::MakeEvent(const std::vector<ECEntity*>& entities, ECase*, EC_Client
Image()->SetOrder(true); Image()->SetOrder(true);
SDL_Delay(20); SDL_Delay(20);
} }
SetImage(images[I_Right]);
} }
break; break;
} }
...@@ -444,10 +514,3 @@ bool ECUnit::AfterEvent(const std::vector<ECEntity*>&, ECase* c, EC_Client*) ...@@ -444,10 +514,3 @@ bool ECUnit::AfterEvent(const std::vector<ECEntity*>&, ECase* c, EC_Client*)
SetAnim(false); SetAnim(false);
return true; return true;
} }
void ECUnit::SetDeployed(bool d)
{
ECBEntity::SetDeployed(d);
if(Deployed() && images[I_Deployed])
SetImage(images[I_Deployed]);
}
/* src/Units.h - Header of Units.cpp /* src/Units.h - Header of Units.cpp
* *
* Copyright (C) 2005-2007 Romain Bignon <Progs@headfucking.net> * Copyright (C) 2005-2011 Romain Bignon <romain@menareants.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -52,8 +52,6 @@ public: ...@@ -52,8 +52,6 @@ public:
virtual bool AfterEvent(const std::vector<ECEntity*>&, ECase* c, EC_Client*); virtual bool AfterEvent(const std::vector<ECEntity*>&, ECase* c, EC_Client*);
virtual void SetDeployed(bool d = true);
/* Mathodes protégées */ /* Mathodes protégées */
protected: