Qent

a_magecone.cpp

Dec 29th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.77 KB | None | 0 0
  1. #include "actor.h"
  2. #include "gi.h"
  3. #include "m_random.h"
  4. #include "s_sound.h"
  5. #include "d_player.h"
  6. #include "a_action.h"
  7. #include "p_local.h"
  8. #include "p_enemy.h"
  9. #include "a_action.h"
  10. #include "p_pspr.h"
  11. #include "gstrings.h"
  12. #include "a_hexenglobal.h"
  13. #include "network.h"
  14.  
  15. const int SHARDSPAWN_LEFT   = 1;
  16. const int SHARDSPAWN_RIGHT  = 2;
  17. const int SHARDSPAWN_UP     = 4;
  18. const int SHARDSPAWN_DOWN   = 8;
  19.  
  20. static FRandom pr_cone ("FireConePL1");
  21.  
  22. void A_FireConePL1 (AActor *actor);
  23. void A_ShedShard (AActor *);
  24.  
  25. // The Mage's Frost Cone ----------------------------------------------------
  26.  
  27. class AMWeapFrost : public AMageWeapon
  28. {
  29.     DECLARE_ACTOR (AMWeapFrost, AMageWeapon)
  30. };
  31.  
  32. FState AMWeapFrost::States[] =
  33. {
  34. #define S_COS1 0
  35.     S_BRIGHT (WMCS, 'A',    8, NULL                     , &States[S_COS1+1]),
  36.     S_BRIGHT (WMCS, 'B',    8, NULL                     , &States[S_COS1+2]),
  37.     S_BRIGHT (WMCS, 'C',    8, NULL                     , &States[S_COS1]),
  38.  
  39. #define S_CONEREADY (S_COS1+3)
  40.     S_NORMAL (CONE, 'A',    1, A_WeaponReady            , &States[S_CONEREADY]),
  41.  
  42. #define S_CONEDOWN (S_CONEREADY+1)
  43.     S_NORMAL (CONE, 'A',    1, A_Lower                  , &States[S_CONEDOWN]),
  44.  
  45. #define S_CONEUP (S_CONEDOWN+1)
  46.     S_NORMAL (CONE, 'A',    1, A_Raise                  , &States[S_CONEUP]),
  47.  
  48. #define S_CONEATK (S_CONEUP+1)
  49.     S_NORMAL (CONE, 'B',    3, NULL                     , &States[S_CONEATK+1]),
  50.     S_NORMAL (CONE, 'C',    4, NULL                     , &States[S_CONEATK+2]),
  51.     S_NORMAL (CONE, 'D',    3, NULL                     , &States[S_CONEATK+3]),
  52.     S_NORMAL (CONE, 'E',    5, NULL                     , &States[S_CONEATK+4]),
  53.     S_NORMAL (CONE, 'F',    3, A_FireConePL1            , &States[S_CONEATK+5]),
  54.     S_NORMAL (CONE, 'G',    3, NULL                     , &States[S_CONEATK+6]),
  55.     S_NORMAL (CONE, 'A',    9, NULL                     , &States[S_CONEATK+7]),
  56.     S_NORMAL (CONE, 'A',   10, A_ReFire                 , &States[S_CONEREADY]),
  57. };
  58.  
  59. IMPLEMENT_ACTOR (AMWeapFrost, Hexen, 53, 36)
  60.     PROP_Flags (MF_SPECIAL)
  61.     PROP_Flags5 (MF5_BLOODSPLATTER)
  62.     PROP_SpawnState (S_COS1)
  63.  
  64.     PROP_Weapon_SelectionOrder (1700)
  65.     PROP_Weapon_AmmoUse1 (3)
  66.     PROP_Weapon_AmmoGive1 (25)
  67.     PROP_Weapon_UpState (S_CONEUP)
  68.     PROP_Weapon_DownState (S_CONEDOWN)
  69.     PROP_Weapon_ReadyState (S_CONEREADY)
  70.     PROP_Weapon_AtkState (S_CONEATK)
  71.     PROP_Weapon_HoldAtkState (S_CONEATK+2)
  72.     PROP_Weapon_Kickback (150)
  73.     PROP_Weapon_YAdjust (20)
  74.     PROP_Weapon_AmmoType1 ("Mana1")
  75.     PROP_Weapon_ProjectileType ("FrostMissile")
  76.     PROP_Inventory_PickupMessage("$TXT_WEAPON_M2")
  77. END_DEFAULTS
  78.  
  79. // Frost Missile ------------------------------------------------------------
  80.  
  81. class AFrostMissile : public AActor
  82. {
  83.     DECLARE_ACTOR (AFrostMissile, AActor)
  84. public:
  85.     int DoSpecialDamage (AActor *victim, int damage);
  86. };
  87.  
  88. FState AFrostMissile::States[] =
  89. {
  90.     S_BRIGHT (SHRD, 'A',    2, NULL                     , &States[1]),
  91.     S_BRIGHT (SHRD, 'A',    3, A_ShedShard              , &States[2]),
  92.     S_BRIGHT (SHRD, 'B',    3, NULL                     , &States[3]),
  93.     S_BRIGHT (SHRD, 'C',    3, NULL                     , &States[0]),
  94.  
  95. #define S_SHARDFXE1_1 (4)
  96.     S_BRIGHT (SHEX, 'A',    5, NULL                     , &States[S_SHARDFXE1_1+1]),
  97.     S_BRIGHT (SHEX, 'B',    5, NULL                     , &States[S_SHARDFXE1_1+2]),
  98.     S_BRIGHT (SHEX, 'C',    5, NULL                     , &States[S_SHARDFXE1_1+3]),
  99.     S_BRIGHT (SHEX, 'D',    5, NULL                     , &States[S_SHARDFXE1_1+4]),
  100.     S_BRIGHT (SHEX, 'E',    5, NULL                     , NULL),
  101. };
  102.  
  103. IMPLEMENT_ACTOR (AFrostMissile, Hexen, -1, 0)
  104.     PROP_SpeedFixed (25)
  105.     PROP_RadiusFixed (13)
  106.     PROP_HeightFixed (8)
  107.     PROP_Damage (1)
  108.     PROP_DamageType (MOD_ICE)
  109.     PROP_Flags (MF_NOBLOCKMAP|MF_NOGRAVITY|MF_DROPOFF|MF_MISSILE)
  110.     PROP_Flags2 (MF2_NOTELEPORT|MF2_IMPACT|MF2_PCROSS)
  111.  
  112.     PROP_SpawnState (0)
  113.     PROP_DeathState (S_SHARDFXE1_1)
  114.  
  115.     PROP_DeathSound ("MageShardsExplode")
  116. END_DEFAULTS
  117.  
  118. int AFrostMissile::DoSpecialDamage (AActor *victim, int damage)
  119. {
  120.     if (special2 > 0)
  121.     {
  122.         damage <<= special2;
  123.     }
  124.     return damage;
  125. }
  126.  
  127. // Ice Shard ----------------------------------------------------------------
  128.  
  129. class AIceShard : public AFrostMissile
  130. {
  131.     DECLARE_ACTOR (AIceShard, AFrostMissile)
  132. };
  133.  
  134. FState AIceShard::States[] =
  135. {
  136.     S_BRIGHT (SHRD, 'A',    3, NULL                     , &States[1]),
  137.     S_BRIGHT (SHRD, 'B',    3, NULL                     , &States[2]),
  138.     S_BRIGHT (SHRD, 'C',    3, NULL                     , &States[0]),
  139. };
  140.  
  141. IMPLEMENT_ACTOR (AIceShard, Hexen, -1, 65)
  142.     PROP_DamageType (MOD_ICE)
  143.     PROP_Flags2 (MF2_NOTELEPORT)
  144.     PROP_SpawnState (0)
  145. END_DEFAULTS
  146.  
  147. //============================================================================
  148. //
  149. // A_FireConePL1
  150. //
  151. //============================================================================
  152.  
  153. void A_FireConePL1 (AActor *actor)
  154. {
  155.     angle_t angle;
  156.     int damage;
  157.     int slope;
  158.     int i;
  159.     AActor *mo;
  160.     bool conedone=false;
  161.     player_t *player;
  162.  
  163.     if (NULL == (player = actor->player))
  164.     {
  165.         return;
  166.     }
  167.  
  168.     AWeapon *weapon = actor->player->ReadyWeapon;
  169.     if (weapon != NULL)
  170.     {
  171.         if (!weapon->DepleteAmmo (weapon->bAltFire))
  172.             return;
  173.     }
  174.     S_Sound (actor, CHAN_WEAPON, "MageShardsFire", 1, ATTN_NORM);
  175.  
  176.     // [BC] Weapons are handled by the server.
  177.     if ( NETWORK_GetState( ) == NETSTATE_CLIENT )
  178.         return;
  179.  
  180.     damage = 90+(pr_cone()&15);
  181.     for (i = 0; i < 16; i++)
  182.     {
  183.         angle = actor->angle+i*(ANG45/16);
  184.         slope = P_AimLineAttack (actor, angle, MELEERANGE);
  185.         if (linetarget)
  186.         {
  187.             P_DamageMobj (linetarget, actor, actor, damage, MOD_ICE);
  188.             conedone = true;
  189.             break;
  190.         }
  191.     }
  192.  
  193.     // didn't find any creatures, so fire projectiles
  194.     if (!conedone)
  195.     {
  196.         mo = P_SpawnPlayerMissile (actor, RUNTIME_CLASS(AFrostMissile));
  197.         if (mo)
  198.         {
  199.             mo->special1 = SHARDSPAWN_LEFT|SHARDSPAWN_DOWN|SHARDSPAWN_UP
  200.                 |SHARDSPAWN_RIGHT;
  201.             mo->special2 = 3; // Set sperm count (levels of reproductivity)
  202.             mo->target = actor;
  203.             mo->args[0] = 3;        // Mark Initial shard as super damage
  204.         }
  205.     }
  206. }
  207.  
  208. //============================================================================
  209. //
  210. // A_ShedShard
  211. //
  212. //============================================================================
  213.  
  214. void A_ShedShard (AActor *actor)
  215. {
  216.     AActor *mo;
  217.     int spawndir = actor->special1;
  218.     int spermcount = actor->special2;
  219.  
  220.     if (spermcount <= 0) return;                // No sperm left
  221.     actor->special2 = 0;
  222.     spermcount--;
  223.  
  224.     // every so many calls, spawn a new missile in its set directions
  225.     if (spawndir & SHARDSPAWN_LEFT)
  226.     {
  227.         mo = P_SpawnMissileAngleZSpeed (actor, actor->z, RUNTIME_CLASS(AFrostMissile), actor->angle+(ANG45/9),
  228.                                              0, (20+2*spermcount)<<FRACBITS, actor->target);
  229.         if (mo)
  230.         {
  231.             mo->special1 = SHARDSPAWN_LEFT;
  232.             mo->special2 = spermcount;
  233.             mo->momz = actor->momz;
  234.             mo->args[0] = (spermcount==3)?2:0;
  235.         }
  236.     }
  237.     if (spawndir & SHARDSPAWN_RIGHT)
  238.     {
  239.         mo = P_SpawnMissileAngleZSpeed (actor, actor->z, RUNTIME_CLASS(AFrostMissile), actor->angle-(ANG45/9),
  240.                                              0, (20+2*spermcount)<<FRACBITS, actor->target);
  241.         if (mo)
  242.         {
  243.             mo->special1 = SHARDSPAWN_RIGHT;
  244.             mo->special2 = spermcount;
  245.             mo->momz = actor->momz;
  246.             mo->args[0] = (spermcount==3)?2:0;
  247.         }
  248.     }
  249.     if (spawndir & SHARDSPAWN_UP)
  250.     {
  251.         mo = P_SpawnMissileAngleZSpeed (actor, actor->z+8*FRACUNIT, RUNTIME_CLASS(AFrostMissile), actor->angle,
  252.                                              0, (15+2*spermcount)<<FRACBITS, actor->target);
  253.         if (mo)
  254.         {
  255.             mo->momz = actor->momz;
  256.             if (spermcount & 1)         // Every other reproduction
  257.                 mo->special1 = SHARDSPAWN_UP | SHARDSPAWN_LEFT | SHARDSPAWN_RIGHT;
  258.             else
  259.                 mo->special1 = SHARDSPAWN_UP;
  260.             mo->special2 = spermcount;
  261.             mo->args[0] = (spermcount==3)?2:0;
  262.         }
  263.     }
  264.     if (spawndir & SHARDSPAWN_DOWN)
  265.     {
  266.         mo = P_SpawnMissileAngleZSpeed (actor, actor->z-4*FRACUNIT, RUNTIME_CLASS(AFrostMissile), actor->angle,
  267.                                              0, (15+2*spermcount)<<FRACBITS, actor->target);
  268.         if (mo)
  269.         {
  270.             mo->momz = actor->momz;
  271.             if (spermcount & 1)         // Every other reproduction
  272.                 mo->special1 = SHARDSPAWN_DOWN | SHARDSPAWN_LEFT | SHARDSPAWN_RIGHT;
  273.             else
  274.                 mo->special1 = SHARDSPAWN_DOWN;
  275.             mo->special2 = spermcount;
  276.             mo->target = actor->target;
  277.             mo->args[0] = (spermcount==3)?2:0;
  278.         }
  279.     }
  280. }
Advertisement
Add Comment
Please, Sign In to add comment