1 /*--
2 	Ruins
3 	Author: Mimmo_O
4 
5 	An arena like last man standing round for up to 12 players.
6 --*/
7 
8 static const RUINS_RAIN_PERIOD_TIME=3200;
9 
Initialize()10 protected func Initialize()
11 {
12 	// Goal.
13 	CreateObject(Goal_LastManStanding, 0, 0, NO_OWNER);
14 	CreateObject(Rule_KillLogs);
15 	CreateObject(Rule_Gravestones);
16 	GetRelaunchRule()->SetLastWeaponUse(false);
17 
18 	// Mood.
19 	SetSkyAdjust(RGBa(255, 255, 255, 127), RGB(255, 200, 150));
20 	SetGamma(109, 105, 101);
21 
22 	// Chests with weapons.
23 	CreateObjectAbove(Chest, 230, 224, NO_OWNER)->MakeInvincible();
24 	CreateObjectAbove(Chest, 500, 64, NO_OWNER)->MakeInvincible();
25 	CreateObjectAbove(Chest, 124, 128, NO_OWNER)->MakeInvincible();
26 	CreateObjectAbove(Chest, 340, 440, NO_OWNER)->MakeInvincible();
27 	AddEffect("IntFillChests", nil, 100, 2 * 36);
28 
29 	// Ropeladders to get to the upper part.
30 
31 	CreateObjectAbove(Ropeladder, 380, 112, NO_OWNER)->Unroll(-1,0,19);
32 	CreateObjectAbove(Ropeladder, 135, 135, NO_OWNER)->Unroll(1,0,16);
33 
34 	// Objects fade after 5 seconds.
35 	CreateObject(Rule_ObjectFade)->DoFadeTime(5 * 36);
36 
37 	AddEffect("DryTime",nil,100,2);
38 	return;
39 }
40 
41 
FxRainTimer(object pTarget,effect,int timer)42 global func FxRainTimer(object pTarget, effect, int timer)
43 {
44 	if(timer<400)
45 	{
46 		InsertMaterial(Material("Water"),Random(LandscapeWidth()-60)+30,1,Random(7)-3,100+Random(100));
47 		return 1;
48 	}
49 		for(var i=0; i<(6+Random(3)); i++)
50 	{
51 		InsertMaterial(Material("Water"),Random(LandscapeWidth()-60)+30,1,Random(7)-3,100+Random(100));
52 	}
53 	if(timer>(RUINS_RAIN_PERIOD_TIME+Random(800)))
54 	{
55 	AddEffect("DryTime",nil,100,2);
56 	return -1;
57 	}
58 
59 	return 1;
60 }
FxDryTimeTimer(object pTarget,effect,int timer)61 global func FxDryTimeTimer(object pTarget, effect, int timer)
62 {
63 	if(timer<(380+Random(300))){
64 	InsertMaterial(Material("Water"),Random(LandscapeWidth()-60)+30,1,Random(7)-3,100+Random(100));
65 		return 1;
66 	}
67 	ExtractLiquidAmount(310+Random(50),430+Random(10),6+Random(4));
68 
69 	if(!GBackLiquid(335,430))
70 	{
71 		AddEffect("Rain",nil,100,2);
72 		return -1;
73 	}
74 }
75 
76 
77 
78 // Refill/fill chests.
FxIntFillChestsStart(object target,effect,int temporary)79 global func FxIntFillChestsStart(object target, effect, int temporary)
80 {
81 	if(temporary) return 1;
82 	var chests = FindObjects(Find_ID(Chest));
83 	var w_list = [Bow, Blunderbuss, Shield, Sword, Club, GrenadeLauncher, Bow, Blunderbuss, Shield, Sword, Club, GrenadeLauncher, DynamiteBox];
84 
85 	for(var chest in chests)
86 		for(var i=0; i<4; ++i)
87 			chest->CreateChestContents(w_list[Random(GetLength(w_list))]);
88 	return 1;
89 }
90 
FxIntFillChestsTimer()91 global func FxIntFillChestsTimer()
92 {
93 	SetTemperature(100);
94 	var chest = FindObjects(Find_ID(Chest), Sort_Random())[0];
95 	var w_list = [Boompack, IronBomb, IronBomb, Firestone, Bow, Blunderbuss, Sword, Javelin];
96 
97 	if (chest->ContentsCount() < 5)
98 		chest->CreateChestContents(w_list[Random(GetLength(w_list))]);
99 	return 1;
100 }
101 
CreateChestContents(id obj_id)102 global func CreateChestContents(id obj_id)
103 {
104 	if (!this)
105 		return;
106 	var obj = CreateObjectAbove(obj_id);
107 	if (obj_id == Bow)
108 		obj->CreateContents(Arrow);
109 	if (obj_id == Blunderbuss)
110 		obj->CreateContents(LeadBullet);
111 	obj->Enter(this);
112 	return;
113 }
114 
115 // GameCall from RelaunchContainer.
OnClonkLeftRelaunch(object clonk)116 func OnClonkLeftRelaunch(object clonk)
117 {
118 	clonk->SetPosition(RandomX(200, LandscapeWidth() - 200), -20);
119 }
120 
KillsToRelaunch()121 func KillsToRelaunch() { return 0; }
RelaunchWeaponList()122 func RelaunchWeaponList() { return [Bow, Shield, Sword, Club, Javelin, Blunderbuss]; }
123