$treeview $search $mathjax
Stratagus
2.2.6
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 1998-2005 by Lutz Sammer 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; only version 2 of the License. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00029 00030 #ifndef __MISSILE_H__ 00031 #define __MISSILE_H__ 00032 00034 00035 /*---------------------------------------------------------------------------- 00036 -- Documentation 00037 ----------------------------------------------------------------------------*/ 00038 00313 /*---------------------------------------------------------------------------- 00314 -- Includes 00315 ----------------------------------------------------------------------------*/ 00316 00317 #include "unitsound.h" 00318 #include "vec2i.h" 00319 00320 /*---------------------------------------------------------------------------- 00321 -- Declarations 00322 ----------------------------------------------------------------------------*/ 00323 00324 class CGraphic; 00325 class CUnit; 00326 class CViewport; 00327 class CFile; 00328 class LuaCallback; 00329 00330 /*---------------------------------------------------------------------------- 00331 -- Missile-type 00332 ----------------------------------------------------------------------------*/ 00333 00334 #define MAX_MISSILES 2048 00335 #define MAX_LOCAL_MISSILES 4096 00336 00337 00340 typedef int MissileClass; 00341 00346 enum _missile_class_ { 00348 MissileClassNone, 00350 MissileClassPointToPoint, 00352 MissileClassPointToPointWithHit, 00354 MissileClassPointToPointCycleOnce, 00356 MissileClassPointToPointBounce, 00358 MissileClassStay, 00360 MissileClassCycleOnce, 00362 MissileClassFire, 00364 MissileClassHit, 00366 MissileClassParabolic, 00368 MissileClassLandMine, 00370 MissileClassWhirlwind, 00372 MissileClassFlameShield, 00374 MissileClassDeathCoil 00375 }; 00376 00378 class MissileType { 00379 public: 00380 MissileType(const std::string &ident); 00381 ~MissileType(); 00382 00384 void LoadMissileSprite(); 00385 void Init(); 00386 void DrawMissileType(int frame, const PixelPos &pos) const; 00387 void DrawMissileType(int frame, int x, int y) const { 00388 PixelPos pos = {x, y}; 00389 00390 DrawMissileType(frame, pos); 00391 } 00392 00393 int Width() const { return size.x; } 00394 int Height() const { return size.y; } 00395 00396 std::string Ident; 00397 int Transparency; 00398 PixelSize size; 00399 int DrawLevel; 00400 int SpriteFrames; 00401 int NumDirections; 00402 00404 SoundConfig FiredSound; 00405 SoundConfig ImpactSound; 00406 00407 bool Flip; 00408 bool CanHitOwner; 00409 bool FriendlyFire; 00410 00411 MissileClass Class; 00412 int NumBounces; 00413 int StartDelay; 00414 int Sleep; 00415 int Speed; 00416 00417 int Range; 00418 int SplashFactor; 00419 std::string ImpactName; 00420 MissileType *ImpactMissile; 00421 std::string SmokeName; 00422 MissileType *SmokeMissile; 00423 LuaCallback *ImpactParticle; 00424 00425 // --- FILLED UP --- 00426 CGraphic *G; 00427 }; 00428 00429 /*---------------------------------------------------------------------------- 00430 -- Missile 00431 ----------------------------------------------------------------------------*/ 00432 00434 class Missile { 00435 protected: 00436 Missile(); 00437 00438 public: 00439 virtual ~Missile() {}; 00440 00441 static Missile *Init(MissileType *mtype, const PixelPos &startPos, const PixelPos &destPos); 00442 static Missile *Init(MissileType *mtype, int sx, int sy, int dx, int dy) { 00443 PixelPos startPos = {sx, sy}; 00444 PixelPos destPos = {dx, dy}; 00445 00446 return Init(mtype, startPos, destPos); 00447 } 00448 00449 virtual void Action() = 0; 00450 00451 void DrawMissile(const CViewport *vp) const; 00452 void SaveMissile(CFile *file) const; 00453 00454 PixelPos source; 00455 PixelPos position; 00456 PixelPos destination; 00457 MissileType *Type; 00458 int SpriteFrame; 00459 int State; 00460 int AnimWait; 00461 int Wait; 00462 int Delay; 00463 00464 CUnit *SourceUnit; 00465 CUnit *TargetUnit; 00466 00467 int Damage; 00468 00469 int TTL; 00470 int Hidden; 00471 00472 // Internal use: 00473 int CurrentStep; 00474 int TotalStep; 00475 00476 unsigned Local:1; 00477 unsigned int Slot; 00478 00479 static unsigned int Count; 00480 }; 00481 00482 struct MissileDrawProxy 00483 { 00484 MissileType *Type; 00485 union { 00486 int Damage; 00487 int SpriteFrame; 00488 } data; 00489 short X; 00490 short Y; 00491 00492 void DrawMissile(const CViewport *vp) const; 00493 00494 void operator=(const Missile* missile); 00495 00496 }; 00497 00498 class MissileNone : public Missile { 00499 public: 00500 virtual void Action(); 00501 }; 00502 class MissilePointToPoint : public Missile { 00503 public: 00504 virtual void Action(); 00505 }; 00506 class MissilePointToPointWithHit : public Missile { 00507 public: 00508 virtual void Action(); 00509 }; 00510 class MissilePointToPointCycleOnce : public Missile { 00511 public: 00512 virtual void Action(); 00513 }; 00514 class MissilePointToPointBounce : public Missile { 00515 public: 00516 virtual void Action(); 00517 }; 00518 class MissileStay : public Missile { 00519 public: 00520 virtual void Action(); 00521 }; 00522 class MissileCycleOnce : public Missile { 00523 public: 00524 virtual void Action(); 00525 }; 00526 class MissileFire : public Missile { 00527 public: 00528 virtual void Action(); 00529 }; 00530 class MissileHit : public Missile { 00531 public: 00532 virtual void Action(); 00533 }; 00534 class MissileParabolic : public Missile { 00535 public: 00536 virtual void Action(); 00537 }; 00538 class MissileLandMine : public Missile { 00539 public: 00540 virtual void Action(); 00541 }; 00542 class MissileWhirlwind : public Missile { 00543 public: 00544 virtual void Action(); 00545 }; 00546 class MissileFlameShield : public Missile { 00547 public: 00548 virtual void Action(); 00549 }; 00550 class MissileDeathCoil : public Missile { 00551 public: 00552 virtual void Action(); 00553 }; 00554 00555 class BurningBuildingFrame { 00556 public: 00557 BurningBuildingFrame() : Percent(0), Missile(NULL) {}; 00558 00559 int Percent; 00560 MissileType *Missile; 00561 } ; 00562 00563 /*---------------------------------------------------------------------------- 00564 -- Variables 00565 ----------------------------------------------------------------------------*/ 00566 00567 extern std::vector<BurningBuildingFrame *> BurningBuildingFrames; 00568 00569 /*---------------------------------------------------------------------------- 00570 -- Functions 00571 ----------------------------------------------------------------------------*/ 00572 00573 // In ccl_missile.c 00574 00576 extern void MissileCclRegister(); 00577 00578 // In missile.c 00579 00581 extern void LoadMissileSprites(); 00583 extern MissileType *NewMissileTypeSlot(const std::string& ident); 00585 extern MissileType *MissileTypeByIdent(const std::string& ident); 00587 extern Missile *MakeMissile(MissileType *mtype, const PixelPos &startPos, const PixelPos &destPos); 00588 inline Missile *MakeMissile(MissileType *mtype, int sx, int sy, int dx, int dy) { 00589 const PixelPos startPos = {sx, sy}; 00590 const PixelPos destPos = {dx, dy}; 00591 00592 return MakeMissile(mtype, startPos, destPos); 00593 } 00595 extern Missile *MakeLocalMissile(MissileType *mtype, const PixelPos &startPos, const PixelPos &destPos); 00596 inline Missile *MakeLocalMissile(MissileType *mtype, int sx, int sy, int dx, int dy) { 00597 const PixelPos startPos = {sx, sy}; 00598 const PixelPos destPos = {dx, dy}; 00599 00600 return MakeLocalMissile(mtype, startPos, destPos); 00601 } 00602 00604 extern void FireMissile(CUnit &unit); 00605 00606 extern int FindAndSortMissiles(const CViewport *vp, 00607 Missile *table[], const int tablesize); 00608 extern int FindAndSortMissiles(const CViewport *vp, 00609 MissileDrawProxy table[], const int tablesize); 00610 00612 extern void MissileActions(); 00614 extern int ViewPointDistanceToMissile(const Missile *missile); 00615 00617 extern MissileType *MissileBurningBuilding(int percent); 00618 00620 extern void SaveMissiles(CFile *file); 00621 00623 extern void InitMissileTypes(); 00625 extern void CleanMissileTypes(); 00627 extern void InitMissiles(); 00629 extern void CleanMissiles(); 00630 00631 #ifdef DEBUG 00632 extern void FreeBurningBuildingFrames(); 00633 #endif 00634 00636 00637 #endif // !__MISSILE_H__