1 /*-- Target Balloon --*/
2
3 local ysin;
4 local load;
5
Initialize()6 protected func Initialize()
7 {
8 ysin = 0;
9 SetAction("Float");
10 SetComDir(COMD_None);
11 AddEffect("Float",this,1,1,this);
12 }
13
FxFloatTimer(object target,effect,int time)14 func FxFloatTimer(object target, effect, int time)
15 {
16 if(ysin >= 360) ysin = 0;
17 if(ysin <= 360)
18 {
19 ++ysin;
20 }
21 target->SetYDir(Sin(ysin,2));
22 }
23
FxHorizontalMovingTimer(object target,effect,int time)24 global func FxHorizontalMovingTimer(object target, effect, int time)
25 {
26 if(target->GetX()<100) target->SetXDir(Min(target->GetXDir()+1,6));
27 if(target->GetX()>810) target->SetXDir(Max(target->GetXDir()-1,-7));
28 return 1;
29 }
30
IsProjectileTarget(object projectile,object shooter)31 public func IsProjectileTarget(object projectile, object shooter)
32 {
33 return true;
34 }
35
OnProjectileHit(object projectile)36 public func OnProjectileHit(object projectile)
37 {
38 CreateParticle("Air", 0, -10, PV_Random(-30, 30), PV_Random(-30,30), PV_Random(30, 120), Particles_Air(), 10);
39 Sound("Objects::Balloon::Pop");
40 if(load) load->~Fall(projectile->GetController());
41 RemoveObject();
42 }
43
FxFlyOffTimer(target,effect,time)44 func FxFlyOffTimer(target, effect, time)
45 {
46 RemoveEffect("Float", this);
47 RemoveEffect("HorizontalMoving", this);
48 if(GetYDir()>-30)
49 {
50 SetYDir(GetYDir()-1);
51 }
52
53 if(GetY()<0)
54 {
55 RemoveObject();
56 return -1;
57 }
58 }
59
Definition(def)60 func Definition(def) {
61 SetProperty("Name", "$Name$", def);
62 SetProperty("ActMap", {
63
64 Float = {
65 Prototype = Action,
66 Name = "Float",
67 Procedure = DFA_FLOAT,
68 Directions = 1,
69 FlipDir = 0,
70 Length = 1,
71 Delay = 1,
72 X = 0,
73 Y = 0,
74 Wdt = 64,
75 Hgt = 64,
76 NextAction = "Float",
77 },
78 }, def);}
79