1 /*
2 #include "actor.h"
3 #include "info.h"
4 #include "p_local.h"
5 #include "s_sound.h"
6 #include "p_enemy.h"
7 #include "gstrings.h"
8 #include "a_action.h"
9 #include "thingdef/thingdef.h"
10 */
11 
12 //
13 // PIT_VileCheck
14 // Detect a corpse that could be raised.
15 //
16 void A_Fire(AActor *self, int height);
17 
18 
19 //
20 // A_VileStart
21 //
DEFINE_ACTION_FUNCTION(AActor,A_VileStart)22 DEFINE_ACTION_FUNCTION(AActor, A_VileStart)
23 {
24 	S_Sound (self, CHAN_VOICE, "vile/start", 1, ATTN_NORM);
25 }
26 
27 
28 //
29 // A_Fire
30 // Keep fire in front of player unless out of sight
31 //
DEFINE_ACTION_FUNCTION(AActor,A_StartFire)32 DEFINE_ACTION_FUNCTION(AActor, A_StartFire)
33 {
34 	S_Sound (self, CHAN_BODY, "vile/firestrt", 1, ATTN_NORM);
35 	A_Fire (self, 0);
36 }
37 
DEFINE_ACTION_FUNCTION(AActor,A_FireCrackle)38 DEFINE_ACTION_FUNCTION(AActor, A_FireCrackle)
39 {
40 	S_Sound (self, CHAN_BODY, "vile/firecrkl", 1, ATTN_NORM);
41 	A_Fire (self, 0);
42 }
43 
DEFINE_ACTION_FUNCTION_PARAMS(AActor,A_Fire)44 DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Fire)
45 {
46 	ACTION_PARAM_START(1);
47 	ACTION_PARAM_FIXED(height,0);
48 
49 	A_Fire(self, height);
50 }
51 
A_Fire(AActor * self,int height)52 void A_Fire(AActor *self, int height)
53 {
54 	AActor *dest;
55 
56 	dest = self->tracer;
57 	if (dest == NULL || self->target == NULL)
58 		return;
59 
60 	// don't move it if the vile lost sight
61 	if (!P_CheckSight (self->target, dest, 0) )
62 		return;
63 
64 	fixedvec3 newpos = dest->Vec3Angle(24 * FRACUNIT, dest->angle, height);
65 	self->SetOrigin(newpos, true);
66 }
67 
68 
69 
70 //
71 // A_VileTarget
72 // Spawn the hellfire
73 //
DEFINE_ACTION_FUNCTION_PARAMS(AActor,A_VileTarget)74 DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileTarget)
75 {
76 	ACTION_PARAM_START(1);
77 	ACTION_PARAM_CLASS(fire,0);
78 	AActor *fog;
79 
80 	if (!self->target)
81 		return;
82 
83 	A_FaceTarget (self);
84 
85 	fog = Spawn (fire, self->target->Pos(), ALLOW_REPLACE);
86 
87 	self->tracer = fog;
88 	fog->target = self;
89 	fog->tracer = self->target;
90 	A_Fire(fog, 0);
91 }
92 
93 
94 
95 
96 //
97 // A_VileAttack
98 //
99 
100 // A_VileAttack flags
101 #define VAF_DMGTYPEAPPLYTODIRECT 1
102 
DEFINE_ACTION_FUNCTION_PARAMS(AActor,A_VileAttack)103 DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack)
104 {
105 	ACTION_PARAM_START(7);
106 	ACTION_PARAM_SOUND(snd,0);
107 	ACTION_PARAM_INT(dmg,1);
108 	ACTION_PARAM_INT(blastdmg,2);
109 	ACTION_PARAM_INT(blastrad,3);
110 	ACTION_PARAM_FIXED(thrust,4);
111 	ACTION_PARAM_NAME(dmgtype,5);
112 	ACTION_PARAM_INT(flags,6);
113 
114 	AActor *fire, *target;
115 
116 	if (NULL == (target = self->target))
117 		return;
118 
119 	A_FaceTarget (self);
120 
121 	if (!P_CheckSight (self, target, 0) )
122 		return;
123 
124 	S_Sound (self, CHAN_WEAPON, snd, 1, ATTN_NORM);
125 
126 	int newdam;
127 
128 	if (flags & VAF_DMGTYPEAPPLYTODIRECT)
129 		newdam = P_DamageMobj (target, self, self, dmg, dmgtype);
130 
131 	else
132 		newdam = P_DamageMobj (target, self, self, dmg, NAME_None);
133 
134 	P_TraceBleed (newdam > 0 ? newdam : dmg, target);
135 
136 	fire = self->tracer;
137 
138 	if (fire != NULL)
139 	{
140 		// move the fire between the vile and the player
141 		fixedvec3 pos = target->Vec3Angle(-24 * FRACUNIT, self->angle, 0);
142 		fire->SetOrigin (pos, true);
143 
144 		P_RadiusAttack (fire, self, blastdmg, blastrad, dmgtype, 0);
145 	}
146 	if (!(target->flags7 & MF7_DONTTHRUST))
147 		target->velz = Scale(thrust, 1000, target->Mass);
148 }
149