00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __MISSILE_H__
00029 #define __MISSILE_H__
00030
00032
00033
00034
00035
00036
00311
00312
00313
00314
00315 #include <vector>
00316 #include "unitsound.h"
00317
00318
00319
00320
00321
00322 class CGraphic;
00323 class CUnit;
00324 class CViewport;
00325 class CFile;
00326 class LuaCallback;
00327
00328
00329
00330
00331
00332 #define MAX_MISSILES 2048
00333
00334
00337 typedef int MissileClass;
00338
00343 enum _missile_class_ {
00345 MissileClassNone,
00347 MissileClassPointToPoint,
00349 MissileClassPointToPointWithHit,
00351 MissileClassPointToPointCycleOnce,
00353 MissileClassPointToPointBounce,
00355 MissileClassStay,
00357 MissileClassCycleOnce,
00359 MissileClassFire,
00361 MissileClassHit,
00363 MissileClassParabolic,
00364 };
00365
00367 class MissileType {
00368 public:
00369 MissileType(const std::string &ident);
00370 ~MissileType();
00371
00373 void LoadMissileSprite();
00374 void Init(void);
00375 void DrawMissileType(int frame, int x, int y) const;
00376
00377
00378 std::string Ident;
00379 int Transparency;
00380 int Width;
00381 int Height;
00382 int DrawLevel;
00383 int SpriteFrames;
00384 int NumDirections;
00385
00387 SoundConfig FiredSound;
00388 SoundConfig ImpactSound;
00389
00390 bool Flip;
00391 bool CanHitOwner;
00392 bool FriendlyFire;
00393
00394 MissileClass Class;
00395 int NumBounces;
00396 int StartDelay;
00397 int Sleep;
00398 int Speed;
00399
00400 int Range;
00401 int SplashFactor;
00402 std::string ImpactName;
00403 MissileType *ImpactMissile;
00404 std::string SmokeName;
00405 MissileType *SmokeMissile;
00406 LuaCallback *ImpactParticle;
00407
00408
00409 CGraphic *G;
00410 };
00411
00412
00413
00414
00415
00417 class Missile {
00418 protected:
00419 Missile();
00420
00421 public:
00422 virtual ~Missile() {};
00423
00424 static Missile *Init(MissileType *mtype, int sx, int sy, int dx, int dy);
00425
00426 virtual void Action() = 0;
00427
00428 void DrawMissile() const;
00429 void SaveMissile(CFile *file) const;
00430
00431 int SourceX;
00432 int SourceY;
00433 int X;
00434 int Y;
00435 int DX;
00436 int DY;
00437 MissileType *Type;
00438 int SpriteFrame;
00439 int State;
00440 int AnimWait;
00441 int Wait;
00442 int Delay;
00443
00444 CUnit *SourceUnit;
00445 CUnit *TargetUnit;
00446
00447 int Damage;
00448
00449 int TTL;
00450 int Hidden;
00451
00452
00453 int CurrentStep;
00454 int TotalStep;
00455
00456 unsigned Local:1;
00457 unsigned int Slot;
00458
00459
00460 static unsigned int Count;
00461 };
00462
00463 class MissileNone : public Missile {
00464 public:
00465 virtual void Action();
00466 };
00467 class MissilePointToPoint : public Missile {
00468 public:
00469 virtual void Action();
00470 };
00471 class MissilePointToPointWithHit : public Missile {
00472 public:
00473 virtual void Action();
00474 };
00475 class MissilePointToPointCycleOnce : public Missile {
00476 public:
00477 virtual void Action();
00478 };
00479 class MissilePointToPointBounce : public Missile {
00480 public:
00481 virtual void Action();
00482 };
00483 class MissileStay : public Missile {
00484 public:
00485 virtual void Action();
00486 };
00487 class MissileCycleOnce : public Missile {
00488 public:
00489 virtual void Action();
00490 };
00491 class MissileFire : public Missile {
00492 public:
00493 virtual void Action();
00494 };
00495 class MissileHit : public Missile {
00496 public:
00497 virtual void Action();
00498 };
00499 class MissileParabolic : public Missile {
00500 public:
00501 virtual void Action();
00502 };
00503
00504 class BurningBuildingFrame {
00505 public:
00506 BurningBuildingFrame() : Percent(0), Missile(NULL) {};
00507
00508 int Percent;
00509 MissileType *Missile;
00510 } ;
00511
00512
00513
00514
00515
00516 extern std::vector<BurningBuildingFrame *> BurningBuildingFrames;
00517
00518
00519
00520
00521
00522
00523
00525 extern void MissileCclRegister(void);
00526
00527
00528
00530 extern void LoadMissileSprites();
00532 extern MissileType *NewMissileTypeSlot(const std::string& ident);
00534 extern MissileType *MissileTypeByIdent(const std::string& ident);
00536 extern Missile *MakeMissile(MissileType *mtype, int sx, int sy, int dx,
00537 int dy);
00539 extern Missile *MakeLocalMissile(MissileType *mtype, int sx, int sy, int dx,
00540 int dy);
00542 extern void FireMissile(CUnit *unit);
00543
00544 extern int FindAndSortMissiles(const CViewport *vp, Missile **table, int tablesize);
00545
00547 extern void MissileActions(void);
00549 extern int ViewPointDistanceToMissile(const Missile *missile);
00550
00552 extern MissileType *MissileBurningBuilding(int percent);
00553
00555 extern void SaveMissiles(CFile *file);
00556
00558 extern void InitMissileTypes(void);
00560 extern void CleanMissileTypes(void);
00562 extern void InitMissiles(void);
00564 extern void CleanMissiles(void);
00565 #ifdef DEBUG
00566 extern void FreeBurningBuildingFrames();
00567 #endif
00568
00570
00571 #endif // !__MISSILE_H__