From b29a8f98b62b229ebc14642bd4de594b8af4b68f Mon Sep 17 00:00:00 2001
From: Gabriel <gbramboeck9fx@gmail.com>
Date: Tue, 22 Apr 2014 13:25:23 +0200
Subject: [PATCH] Added gfx + sfx for walljump and hangle

Now with particles for dust and little material fragments + sounds. Added Crumble1, 2 and 3.ogg
---
 .../Objects.ocd/Clonk.ocd/Animations.ocd/Script.c  | 128 ++++++++++++++++++++-
 planet/Objects.ocd/Clonk.ocd/Crumble1.ogg          | Bin 0 -> 9105 bytes
 planet/Objects.ocd/Clonk.ocd/Crumble2.ogg          | Bin 0 -> 8348 bytes
 planet/Objects.ocd/Clonk.ocd/Crumble3.ogg          | Bin 0 -> 7337 bytes
 planet/Objects.ocd/Clonk.ocd/authors.txt           |   3 +-
 5 files changed, 126 insertions(+), 5 deletions(-)
 create mode 100644 planet/Objects.ocd/Clonk.ocd/Crumble1.ogg
 create mode 100644 planet/Objects.ocd/Clonk.ocd/Crumble2.ogg
 create mode 100644 planet/Objects.ocd/Clonk.ocd/Crumble3.ogg

diff --git a/planet/Objects.ocd/Clonk.ocd/Animations.ocd/Script.c b/planet/Objects.ocd/Clonk.ocd/Animations.ocd/Script.c
index b97bbcb..57757e3 100644
--- a/planet/Objects.ocd/Clonk.ocd/Animations.ocd/Script.c
+++ b/planet/Objects.ocd/Clonk.ocd/Animations.ocd/Script.c
@@ -695,14 +695,20 @@ func StartJump()
 	//Normal forward jump
 	if(Abs(GetXDir()) >= 1)
 	PlayAnimation(Format("Jump.%s",side), 5, Anim_Linear(0, 0, GetAnimationLength("Jump.L"), 8*5, ANIM_Hold), Anim_Linear(0, 0, 1000, 5, ANIM_Remove));
+	
 	//Walk kick jump
 	if(GetEffect("WallKick",this))
 	{
 		SetAction("WallJump");
 		var side = "L";
-		if(GetDir() == DIR_Left) side = "R";
+		var get_tex_x = 7;
+		if(GetDir() == DIR_Left) { side = "R"; get_tex_x = -7; }
 		PlayAnimation(Format("JumpWall.%s", side), 5, Anim_Linear(0, 0, GetAnimationLength("JumpWall.L"), 8*5, ANIM_Hold), Anim_Linear(0, 0, 1000, 5, ANIM_Remove));
+		
+		// effects!
+		CrumbleWall(get_tex_x);
 	}
+	
 	//Upwards jump
 	else if(GetXDir() == 0)
 	{
@@ -713,6 +719,7 @@ func StartJump()
 	UpdateAttach();
 	// Set proper turn type
 	SetTurnType(0);
+	
 	//Dive jump (only if not aiming)
 	if(!this->~IsAiming())
 	{
@@ -729,6 +736,51 @@ func StartJump()
 	RemoveEffect("WallKick",this);
 }
 
+func CrumbleWall(int get_tex_x)
+{
+	// These two sounds are always played
+	Sound("StepHard?");
+	Sound("Rustle?");
+	
+	// certain materials shouldn't crumble (because it doesn't look good)
+	var exception_mats = ["Gold", "Firestone", "Ore", "Granite", "Amethyst", "Ruby"];
+	var material = GetMaterial(get_tex_x, 9);
+	
+	for(element in exception_mats)
+		if(material == Material(element)) return;
+
+	// crumble effects
+	var clr = GetAverageTextureColor(GetTexture(get_tex_x, 9));
+	var dir = Sign(GetXDir());
+	
+	var dust =
+	{
+		Prototype = Particles_Dust(),
+		R = (clr >> 16) & 0xff,
+		G = (clr >> 8) & 0xff,
+		B = clr & 0xff,
+	};
+	CreateParticle("Dust", 0, Random(6)-4, PV_Random(2, -2), PV_Random(2, -2), PV_Random(36, 2 * 36), dust, 10);
+	
+	var dirt =
+	{
+		Size = PV_Random(1, 2),
+		CollisionVertex = 0,
+		OnCollision = PC_Stop(),
+		ForceX = PV_Wind(10),
+		ForceY = PV_Gravity(100),
+		Rotation = PV_Direction(PV_Random(750, 1250)),
+		Alpha = PV_KeyFrames(0, 0, 255, 900, 255, 1000, 0),
+		R = (clr >> 16) & 0xff,
+		G = (clr >> 8) & 0xff,
+		B = clr & 0xff,
+	};
+	CreateParticle("StarFlash", 0, -6, PV_Random(-3, 4), PV_Random(-2, -3), PV_Random(36, 2 * 36), dirt, RandomX(1, 3));
+	
+	Sound("Crumble?", false, 25);
+}
+
+
 func FxFallEffect(string new_name, object target)
 {
 	// reject more than one fall effects.
@@ -821,6 +873,19 @@ func FxIntHangleStop(pTarget, effect, iReasonm, fTmp)
 
 func FxIntHangleTimer(pTarget, effect, iTime)
 {
+	if (effect.crumble_ceiling_time >= 250)
+	{
+		// effects
+		CrumbleCeiling();
+		effect.crumble_ceiling_time = Random(90);
+	}
+	
+	if(effect.hangle_sound_time >= 29)
+	{
+		Sound("Rustle?");
+		effect.hangle_sound_time = 0;
+	}
+
 	// (TODO: Instead of effect.is_moving we should be able
 	// to query the current animation... maybe via a to-be-implemented
 	// GetAnimationName() engine function.
@@ -867,6 +932,10 @@ func FxIntHangleTimer(pTarget, effect, iTime)
 			effect.animation_id = PlayAnimation("HangleStand", 5, Anim_Linear(begin, begin, end, 100, ANIM_Loop), Anim_Linear(0, 0, 1000, 5, ANIM_Remove));
 			effect.is_moving = 0;
 		}
+		
+		effect.hangle_sound_time++;
+		
+		effect.crumble_ceiling_time += 4; // crumble more often when moving
 	}
 	else
 	{
@@ -875,17 +944,68 @@ func FxIntHangleTimer(pTarget, effect, iTime)
 		{
 			// Switch to move
 			effect.is_moving = 1;
+			// First sound must be triggered manually
+			Sound("Rustle?");
 			// start with frame 100 or from the back hanging pose frame 600
 			var begin = 10*(100 + 500*effect.facing_front);
 			effect.animation_id = PlayAnimation("Hangle", 5, Anim_Const(begin), Anim_Linear(0, 0, 1000, 5, ANIM_Remove));
 		}
+		
+		effect.hangle_sound_time = 0;
+		
+		effect.crumble_ceiling_time++; // crumble more rarely when just hanging there
+	}
+}
+
+func CrumbleCeiling()
+{
+	// certain materials won't crumble (because it doesn't look good)
+	var exception_mats = ["Gold", "Firestone", "Ore", "Granite", "Amethyst", "Ruby"];
+	var material = GetMaterial(0, -10);
+	
+	for(element in exception_mats)
+		if(material == Material(element)) return;
+	
+	if(Random(3))
+	{
+		var dir = Sign(GetXDir());
+		var clr = GetAverageTextureColor(GetTexture(0, -10));
+		
+		var dirt =
+		{
+			Size = PV_Random(1, 2),
+			CollisionVertex = 0,
+			OnCollision = PC_Die(),
+			ForceX = PV_Wind(10),
+			ForceY = PV_Gravity(100),
+			Rotation = PV_Direction(PV_Random(750, 1250)),
+			R = (clr >> 16) & 0xff,
+			G = (clr >> 8) & 0xff,
+			B = clr & 0xff,
+		};
+		CreateParticle("StarFlash", PV_Random(dir * -2, dir * -1), -6, PV_Random(-3, 4), PV_Random(-2, -3), 0, dirt, RandomX(1, 3));
+		
+		var dust =
+			{
+				Prototype = Particles_Dust(),
+				R = (clr >> 16) & 0xff,
+				G = (clr >> 8) & 0xff,
+				B = clr & 0xff,
+				ForceY = PV_Gravity(5),
+				Alpha = PV_KeyFrames(10, 0, 0, 500, 20, 800, 40, 1000, 0),
+				Size = PV_KeyFrames(0, 0, 7, 100, 12, 1000, 14)
+			};
+		CreateParticle("Dust", PV_Random(dir * 4, dir * 2), PV_Random(-5, -7), PV_Random(dir * 4, dir * 2), PV_Random(-4, -6), PV_Random(36, 2 * 36), dust, 7);
+			
+		Sound("Crumble?", false, 15);
 	}
 }
 
+
 /*--
 	Swim
 
-	Different animation for swiming and diving. Adjusting the rotation while diving.
+	Different animation for swimming and diving. Adjusting the rotation while diving.
 --*/
 
 func StartSwim()
@@ -1131,14 +1251,14 @@ func FxRollingTimer(object target, int num, int timer)
 		var clr = GetAverageTextureColor(GetTexture(0,10));
 		var dir = GetDir()*2-1;
 		
-		var particles =
+		var dust =
 		{
 			Prototype = Particles_Dust(),
 			R = (clr >> 16) & 0xff,
 			G = (clr >> 8) & 0xff,
 			B = clr & 0xff,
 		};
-		CreateParticle("Dust", PV_Random(dir * -2, dir * -1), 8, PV_Random(dir * 2, dir * 1), PV_Random(-2, -5), PV_Random(36, 2 * 36), particles, 6);
+		CreateParticle("Dust", PV_Random(dir * -2, dir * -1), 8, PV_Random(dir * 2, dir * 1), PV_Random(-2, -5), PV_Random(36, 2 * 36), dust, 6);
 	}
 }
 
diff --git a/planet/Objects.ocd/Clonk.ocd/Crumble1.ogg b/planet/Objects.ocd/Clonk.ocd/Crumble1.ogg
new file mode 100644
index 0000000000000000000000000000000000000000..6cff61cf249070501f5829864bf0225cae45b6d5
GIT binary patch
diff --git a/planet/Objects.ocd/Clonk.ocd/Crumble2.ogg b/planet/Objects.ocd/Clonk.ocd/Crumble2.ogg
new file mode 100644
index 0000000000000000000000000000000000000000..ef5db6f4cb77515bc9aeb80fad534ff99029299e
GIT binary patch
diff --git a/planet/Objects.ocd/Clonk.ocd/Crumble3.ogg b/planet/Objects.ocd/Clonk.ocd/Crumble3.ogg
new file mode 100644
index 0000000000000000000000000000000000000000..4ca05e7eb005fbd35062195730bb44d7580bf76b
GIT binary patch
diff --git a/planet/Objects.ocd/Clonk.ocd/authors.txt b/planet/Objects.ocd/Clonk.ocd/authors.txt
index 342dc57..960ec6d 100644
--- a/planet/Objects.ocd/Clonk.ocd/authors.txt
+++ b/planet/Objects.ocd/Clonk.ocd/authors.txt
@@ -1,2 +1,3 @@
 Roll.ogg, Rustle1.ogg, Rustle2.ogg, Rustle3.ogg, Rustle4.ogg, RustleLand.ogg by Pat (http://www.freesound.org/people/pwausc1/sounds/118259/), License: CC Attribution 3.0
-StepSoft1.ogg, StepSoft2.ogg, StepSoft3.ogg, StepSoft4.ogg, StepSoft5.ogg, StepSoft6.ogg, StepHard1.ogg, StepHard2.ogg, StepHard3.ogg, StepHard4.ogg, StepHard5.ogg by HerbertBoland (http://www.freesound.org/people/HerbertBoland/sounds/31962/), License: CC Attribution 3.0
\ No newline at end of file
+StepSoft1.ogg, StepSoft2.ogg, StepSoft3.ogg, StepSoft4.ogg, StepSoft5.ogg, StepSoft6.ogg, StepHard1.ogg, StepHard2.ogg, StepHard3.ogg, StepHard4.ogg, StepHard5.ogg by HerbertBoland (http://www.freesound.org/people/HerbertBoland/sounds/31962/), License: CC Attribution 3.0
+Crumble1.ogg, Crumble2.ogg, Crumble3.ogg by Dan Oberbauer (DJ Chronos) (http://freesound.org/people/DJ%20Chronos/sounds/123563/), License: CC Attribution 3.0
\ No newline at end of file
-- 
1.8.1.msysgit.1

