$treeview $search $mathjax
Stratagus
2.2.7
$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 00294 /*---------------------------------------------------------------------------- 00295 -- Includes 00296 ----------------------------------------------------------------------------*/ 00297 00298 #include "missileconfig.h" 00299 #include "unitptr.h" 00300 #include "unitsound.h" 00301 #include "vec2i.h" 00302 00303 /*---------------------------------------------------------------------------- 00304 -- Declarations 00305 ----------------------------------------------------------------------------*/ 00306 00307 class CGraphic; 00308 class CUnit; 00309 class CViewport; 00310 class CFile; 00311 class LuaCallback; 00312 00313 /*---------------------------------------------------------------------------- 00314 -- Missile-type 00315 ----------------------------------------------------------------------------*/ 00316 00320 enum { 00321 MissileClassNone, 00322 MissileClassPointToPoint, 00323 MissileClassPointToPointWithHit, 00324 MissileClassPointToPointCycleOnce, 00325 MissileClassPointToPointBounce, 00326 MissileClassStay, 00327 MissileClassCycleOnce, 00328 MissileClassFire, 00329 MissileClassHit, 00330 MissileClassParabolic, 00331 MissileClassLandMine, 00332 MissileClassWhirlwind, 00333 MissileClassFlameShield, 00334 MissileClassDeathCoil, 00335 MissileClassTracer, 00336 MissileClassClipToTarget 00337 }; 00338 00340 class MissileType 00341 { 00342 public: 00343 explicit MissileType(const std::string &ident); 00344 ~MissileType(); 00345 00347 void LoadMissileSprite(); 00348 void Init(); 00349 void DrawMissileType(int frame, const PixelPos &pos) const; 00350 00351 void Load(lua_State *l); 00352 00353 int Width() const { return size.x; } 00354 int Height() const { return size.y; } 00355 00356 //private: 00357 std::string Ident; 00358 int Transparency; 00359 PixelSize size; 00360 int DrawLevel; 00361 int SpriteFrames; 00362 int NumDirections; 00363 int ChangeVariable; 00364 int ChangeAmount; 00365 bool ChangeMax; 00366 00368 SoundConfig FiredSound; 00369 SoundConfig ImpactSound; 00370 00371 bool CorrectSphashDamage; 00372 bool Flip; 00373 bool CanHitOwner; 00374 bool FriendlyFire; 00375 bool AlwaysFire; 00376 bool Pierce; 00377 bool PierceOnce; 00378 00379 int Class; 00380 int NumBounces; 00381 int StartDelay; 00382 int Sleep; 00383 int Speed; 00384 00385 int Range; 00386 int SplashFactor; 00387 MissileConfig Impact; 00388 MissileConfig Smoke; 00389 LuaCallback *ImpactParticle; 00390 LuaCallback *SmokeParticle; 00391 00392 // --- FILLED UP --- 00393 CGraphic *G; 00394 }; 00395 00396 /*---------------------------------------------------------------------------- 00397 -- Missile 00398 ----------------------------------------------------------------------------*/ 00399 00401 class Missile 00402 { 00403 protected: 00404 Missile(); 00405 00406 public: 00407 virtual ~Missile(); 00408 00409 static Missile *Init(const MissileType &mtype, const PixelPos &startPos, const PixelPos &destPos); 00410 00411 virtual void Action() = 0; 00412 00413 void DrawMissile(const CViewport &vp) const; 00414 void SaveMissile(CFile &file) const; 00415 void MissileHit(CUnit *unit = NULL); 00416 bool NextMissileFrame(char sign, char longAnimation); 00417 void NextMissileFrameCycle(); 00418 void MissileNewHeadingFromXY(const PixelPos &delta); 00419 00420 00421 //private: 00422 PixelPos source; 00423 PixelPos position; 00424 PixelPos destination; 00425 const MissileType *Type; 00426 int SpriteFrame; 00427 int State; 00428 int AnimWait; 00429 int Wait; 00430 int Delay; 00431 00432 CUnitPtr SourceUnit; 00433 CUnitPtr TargetUnit; 00434 00435 std::vector<CUnit *> PiercedUnits; 00436 00437 int Damage; 00438 00439 int TTL; 00440 int Hidden; 00441 00442 // Internal use: 00443 int CurrentStep; 00444 int TotalStep; 00445 00446 unsigned Local: 1; 00447 unsigned int Slot; 00448 00449 static unsigned int Count; 00450 }; 00451 00452 extern bool MissileInitMove(Missile &missile); 00453 extern bool PointToPointMissile(Missile &missile); 00454 extern void MissileHandlePierce(Missile &missile, const Vec2i &pos); 00455 00456 class MissileNone : public Missile 00457 { 00458 public: 00459 virtual void Action(); 00460 }; 00461 class MissilePointToPoint : public Missile 00462 { 00463 public: 00464 virtual void Action(); 00465 }; 00466 class MissilePointToPointWithHit : public Missile 00467 { 00468 public: 00469 virtual void Action(); 00470 }; 00471 class MissilePointToPointCycleOnce : public Missile 00472 { 00473 public: 00474 virtual void Action(); 00475 }; 00476 class MissilePointToPointBounce : public Missile 00477 { 00478 public: 00479 virtual void Action(); 00480 }; 00481 class MissileStay : public Missile 00482 { 00483 public: 00484 virtual void Action(); 00485 }; 00486 class MissileCycleOnce : public Missile 00487 { 00488 public: 00489 virtual void Action(); 00490 }; 00491 class MissileFire : public Missile 00492 { 00493 public: 00494 virtual void Action(); 00495 }; 00496 class MissileHit : public Missile 00497 { 00498 public: 00499 virtual void Action(); 00500 }; 00501 class MissileParabolic : public Missile 00502 { 00503 public: 00504 virtual void Action(); 00505 }; 00506 class MissileLandMine : public Missile 00507 { 00508 public: 00509 virtual void Action(); 00510 }; 00511 class MissileWhirlwind : public Missile 00512 { 00513 public: 00514 virtual void Action(); 00515 }; 00516 class MissileFlameShield : public Missile 00517 { 00518 public: 00519 virtual void Action(); 00520 }; 00521 class MissileDeathCoil : public Missile 00522 { 00523 public: 00524 virtual void Action(); 00525 }; 00526 00527 class MissileTracer : public Missile 00528 { 00529 public: 00530 virtual void Action(); 00531 }; 00532 00533 class MissileClipToTarget : public Missile 00534 { 00535 public: 00536 virtual void Action(); 00537 }; 00538 00539 class BurningBuildingFrame 00540 { 00541 public: 00542 BurningBuildingFrame() : Percent(0), Missile(NULL) {}; 00543 00544 int Percent; 00545 MissileType *Missile; 00546 } ; 00547 00548 /*---------------------------------------------------------------------------- 00549 -- Variables 00550 ----------------------------------------------------------------------------*/ 00551 00552 extern std::vector<BurningBuildingFrame *> BurningBuildingFrames; 00553 00554 /*---------------------------------------------------------------------------- 00555 -- Functions 00556 ----------------------------------------------------------------------------*/ 00557 00558 // In ccl_missile.c 00559 00561 extern void MissileCclRegister(); 00562 00563 // In missile.c 00564 00566 extern void LoadMissileSprites(); 00568 extern MissileType *NewMissileTypeSlot(const std::string &ident); 00570 extern MissileType *MissileTypeByIdent(const std::string &ident); 00572 extern Missile *MakeMissile(const MissileType &mtype, const PixelPos &startPos, const PixelPos &destPos); 00574 extern Missile *MakeLocalMissile(const MissileType &mtype, const PixelPos &startPos, const PixelPos &destPos); 00575 00577 extern void FireMissile(CUnit &unit, CUnit *goal, const Vec2i &goalPos); 00578 00579 extern void FindAndSortMissiles(const CViewport &vp, std::vector<Missile *> &table); 00580 00582 extern void MissileActions(); 00584 extern int ViewPointDistanceToMissile(const Missile &missile); 00585 00587 extern MissileType *MissileBurningBuilding(int percent); 00588 00590 extern void SaveMissiles(CFile &file); 00591 00593 extern void InitMissileTypes(); 00595 extern void CleanMissileTypes(); 00597 extern void InitMissiles(); 00599 extern void CleanMissiles(); 00600 00601 #ifdef DEBUG 00602 extern void FreeBurningBuildingFrames(); 00603 #endif 00604 00606 00607 #endif // !__MISSILE_H__