1 /*--
2 Molten Monarch
3 Author: Mimmo_O
4
5 A king of the hill in a lava cave.
6 --*/
7
8
9
Initialize()10 protected func Initialize()
11 {
12 // Goal.
13 var goal = CreateObject(Goal_KingOfTheHill, 555, 250, NO_OWNER);
14 goal->SetRadius(80);
15 goal->SetPointLimit(6);
16 AddEffect("BlessTheKing",goal,100,1,nil);
17 // Objects fade after 7 seconds.
18 CreateObject(Rule_ObjectFade)->DoFadeTime(7 * 36);
19 CreateObject(Rule_KillLogs);
20 CreateObject(Rule_Gravestones)->SetFadeOut(3 * 36);
21 GetRelaunchRule()->SetLastWeaponUse(false);
22
23 //make lava collapse
24 CreateObjectAbove(Firestone,625,480);
25
26 // Chests with weapons.
27 CreateObjectAbove(Chest, 320, 80, NO_OWNER)->MakeInvincible();
28 CreateObjectAbove(Chest, 720, 192, NO_OWNER)->MakeInvincible();
29 CreateObjectAbove(Chest, 668, 336, NO_OWNER)->MakeInvincible();
30 CreateObjectAbove(Chest, 320, 440, NO_OWNER)->MakeInvincible();
31 CreateObjectAbove(Chest, 48, 256, NO_OWNER)->MakeInvincible();
32 AddEffect("IntFillChests", nil, 100, 5 * 36);
33
34 // Moving bricks.
35 var brick;
36 brick = CreateObjectAbove(MovingBrick, 542, 176);
37 brick->SetSize(3);
38 brick->MoveVertical(168, 472, 8);
39 brick = CreateObjectAbove(MovingBrick, 588, 192);
40 brick->SetSize(3);
41 brick->MoveVertical(160, 464, 8);
42
43 brick = CreateObjectAbove(MovingBrick, 77, 0);
44 brick->MoveVertical(0, LandscapeHeight(), 6);
45 AddEffect("LavaBrickReset", brick, 100, 10);
46 brick = CreateObjectAbove(MovingBrick, 77, LandscapeHeight() / 3);
47 brick->MoveVertical(0, LandscapeHeight(), 6);
48 AddEffect("LavaBrickReset", brick, 100, 10);
49 brick = CreateObjectAbove(MovingBrick, 77, 2 * LandscapeHeight() / 3);
50 brick->MoveVertical(0, LandscapeHeight(), 6);
51 AddEffect("LavaBrickReset", brick, 100, 10);
52
53 AddEffect("DeathByFire",nil,100,2,nil);
54 return;
55 }
56
FxBlessTheKingStart(target,effect fx,temp)57 global func FxBlessTheKingStart(target, effect fx, temp)
58 {
59 if (temp) return;
60 fx.particles =
61 {
62 Prototype = Particles_Fire(),
63 Attach = ATTACH_Back
64 };
65 fx.koth_location = nil;
66 }
67
FxBlessTheKingTimer(object target,effect fx,int timer)68 global func FxBlessTheKingTimer(object target, effect fx, int timer)
69 {
70 if (!fx.koth_location)
71 {
72 fx.koth_location = FindObject(Find_ID(KingOfTheHill_Location));
73 if (!fx.koth_location) return FX_OK;
74 }
75 var king = fx.koth_location->GetKing();
76 if(king == nil) return 1;
77
78 var item = king->GetHandItem(0);
79 if (item) item->~MakeKingSize();
80
81 king->CreateParticle("Fire", PV_Random(-4, 4), PV_Random(-11, 8), PV_Random(-10, 10), PV_Random(-10, 10), PV_Random(10, 30), fx.particles, 10);
82 return 1;
83 }
84
FxDeathByFireStart(object target,effect fx,bool temp)85 global func FxDeathByFireStart(object target, effect fx, bool temp)
86 {
87 if (temp) return;
88 fx.particles = Particles_Fire();
89 }
90
FxDeathByFireTimer(object target,effect fx,int timer)91 global func FxDeathByFireTimer(object target, effect fx, int timer)
92 {
93 for(var obj in FindObjects(Find_InRect(55,0,50,70), Find_Category(C4D_Object | C4D_Living)))
94 {
95 if (obj->GetAlive())
96 obj->Kill();
97
98 if (obj && obj->GetY() <= 30 && obj->GetID() != MovingBrick)
99 {
100 obj->RemoveObject();
101 }
102 }
103
104 CreateParticle("Fire", PV_Random(55, 95), PV_Random(0, 40), PV_Random(-1, 1), PV_Random(0, 20), PV_Random(10, 40), fx.particles, 20);
105 }
106
FxLavaBrickResetTimer(object target,effect,int timer)107 global func FxLavaBrickResetTimer(object target, effect, int timer)
108 {
109 if(target->GetY() < 10)
110 target->SetPosition(target->GetX(),LandscapeHeight()-10);
111 return 1;
112 }
113
114 // Refill/fill chests.
FxIntFillChestsStart(object target,effect,int temporary)115 global func FxIntFillChestsStart(object target, effect, int temporary)
116 {
117 if(temporary) return 1;
118 var chests = FindObjects(Find_ID(Chest));
119 var w_list = [Bow, Blunderbuss, Shield, Sword, Club, Javelin, Bow, Blunderbuss, Shield, Sword, Club, Javelin, DynamiteBox];
120
121 for(var chest in chests)
122 for(var i=0; i<4; ++i)
123 chest->CreateChestContents(w_list[Random(GetLength(w_list))]);
124 return 1;
125 }
126
FxIntFillChestsTimer()127 global func FxIntFillChestsTimer()
128 {
129 SetTemperature(100);
130 var chests = FindObjects(Find_ID(Chest));
131 var w_list = [IronBomb, Rock, IronBomb, Firestone, Firestone, Bow, Blunderbuss, Sword, Javelin];
132 for(var chest in chests)
133 if (chest->ContentsCount() < 5 )
134 chest->CreateChestContents(w_list[Random(GetLength(w_list))]);
135 return 1;
136 }
137
CreateChestContents(id obj_id)138 global func CreateChestContents(id obj_id)
139 {
140 if (!this)
141 return;
142 var obj = CreateObjectAbove(obj_id);
143 if (obj_id == Bow)
144 obj->CreateContents(Arrow);
145 if (obj_id == Blunderbuss)
146 obj->CreateContents(LeadBullet);
147 obj->Enter(this);
148 return;
149 }
150
RelaunchPosition()151 public func RelaunchPosition()
152 {
153 return [[420,200],[300,440],[130,176],[140,368],[700,192],[670,336],[750,440],[440,392],[45,256]];
154 }
155
RelaunchWeaponList()156 func RelaunchWeaponList() { return [Bow, Shield, Sword, Javelin, Blunderbuss, Club]; }
157