about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-17 11:23:21 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2008-10-17 11:23:21 +0000
commit35bcd41aa281325112dd09f12dce89236cca937d (patch)
treee1256dae0dce1e1183e309a4883a3dc609da61dd
parenta6be56dbdcbcd7b7a3ebf7dae7cd0537027486ea (diff)
downloadzcatch-35bcd41aa281325112dd09f12dce89236cca937d.tar.gz
zcatch-35bcd41aa281325112dd09f12dce89236cca937d.zip
added hammer hit effect. added reset of all systems on state change. solves a lot of possible memory errors
-rw-r--r--data/mapres/grass_doodads.pngbin95439 -> 93687 bytes
-rw-r--r--data/mapres/grass_main.pngbin68627 -> 80099 bytes
-rw-r--r--datasrc/network.py1
-rw-r--r--src/game/client/components/effects.cpp17
-rw-r--r--src/game/client/components/effects.hpp1
-rw-r--r--src/game/client/gameclient.cpp12
-rw-r--r--src/game/server/entities/character.cpp2
-rw-r--r--src/game/server/gamecontext.cpp12
-rw-r--r--src/game/server/gamecontext.hpp1
9 files changed, 44 insertions, 2 deletions
diff --git a/data/mapres/grass_doodads.png b/data/mapres/grass_doodads.png
index 5fd6db49..68bbff3f 100644
--- a/data/mapres/grass_doodads.png
+++ b/data/mapres/grass_doodads.png
Binary files differdiff --git a/data/mapres/grass_main.png b/data/mapres/grass_main.png
index 5a7c25b2..17eba7c6 100644
--- a/data/mapres/grass_main.png
+++ b/data/mapres/grass_main.png
Binary files differdiff --git a/datasrc/network.py b/datasrc/network.py
index c1fc974a..ac380140 100644
--- a/datasrc/network.py
+++ b/datasrc/network.py
@@ -170,6 +170,7 @@ Objects = [
 
 	NetEvent("Explosion:Common", []),
 	NetEvent("Spawn:Common", []),
+	NetEvent("HammerHit:Common", []),
 	
 	NetEvent("Death:Common", [
 		NetIntRange("cid", 0, 'MAX_CLIENTS-1'),
diff --git a/src/game/client/components/effects.cpp b/src/game/client/components/effects.cpp
index 282da6f8..5e2e25e3 100644
--- a/src/game/client/components/effects.cpp
+++ b/src/game/client/components/effects.cpp
@@ -6,6 +6,7 @@
 #include <game/client/components/skins.hpp>
 #include <game/client/components/flow.hpp>
 #include <game/client/components/damageind.hpp>
+#include <game/client/components/sounds.hpp>
 #include <game/client/gameclient.hpp>
 
 #include "effects.hpp"
@@ -215,6 +216,22 @@ void EFFECTS::explosion(vec2 pos)
 	}
 }
 
+
+void EFFECTS::hammerhit(vec2 pos)
+{
+	// add the explosion
+	PARTICLE p;
+	p.set_default();
+	p.spr = SPRITE_PART_EXPL01;
+	p.pos = pos;
+	p.life_span = 0.4f;
+	p.start_size = 150.0f;
+	p.end_size = 0;
+	p.rot = frandom()*pi*2;
+	gameclient.particles->add(PARTICLES::GROUP_EXPLOSIONS, &p);	
+	gameclient.sounds->play(SOUNDS::CHN_WORLD, SOUND_HAMMER_HIT, 1.0f, pos);
+}
+
 void EFFECTS::on_render()
 {
 	static int64 last_update_100hz = 0;
diff --git a/src/game/client/components/effects.hpp b/src/game/client/components/effects.hpp
index 13af8947..8574bf60 100644
--- a/src/game/client/components/effects.hpp
+++ b/src/game/client/components/effects.hpp
@@ -13,6 +13,7 @@ public:
 	void smoketrail(vec2 pos, vec2 vel);
 	void skidtrail(vec2 pos, vec2 vel);
 	void explosion(vec2 pos);
+	void hammerhit(vec2 pos);
 	void air_jump(vec2 pos);
 	void damage_indicator(vec2 pos, vec2 dir);
 	void playerspawn(vec2 pos);
diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp
index 22800a7a..4ac9c50a 100644
--- a/src/game/client/gameclient.cpp
+++ b/src/game/client/gameclient.cpp
@@ -432,7 +432,12 @@ void GAMECLIENT::on_statechange(int new_state, int old_state)
 {
 	// clear out the invalid pointers
 	mem_zero(&gameclient.snap, sizeof(gameclient.snap));
-		
+	
+	// first issue a reset to all
+	for(int i = 0; i < all.num; i++)
+		all.components[i]->on_reset();
+	
+	// then change the state
 	for(int i = 0; i < all.num; i++)
 		all.components[i]->on_statechange(new_state, old_state);
 }
@@ -463,6 +468,11 @@ void GAMECLIENT::process_events()
 			NETEVENT_EXPLOSION *ev = (NETEVENT_EXPLOSION *)data;
 			gameclient.effects->explosion(vec2(ev->x, ev->y));
 		}
+		else if(item.type == NETEVENTTYPE_HAMMERHIT)
+		{
+			NETEVENT_HAMMERHIT *ev = (NETEVENT_HAMMERHIT *)data;
+			gameclient.effects->hammerhit(vec2(ev->x, ev->y));
+		}
 		else if(item.type == NETEVENTTYPE_SPAWN)
 		{
 			NETEVENT_SPAWN *ev = (NETEVENT_SPAWN *)data;
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index cc0145b0..539e250d 100644
--- a/src/game/server/entities/character.cpp
+++ b/src/game/server/entities/character.cpp
@@ -306,7 +306,7 @@ void CHARACTER::fire_weapon()
 				vec2 fdir = normalize(ents[i]->pos - pos);
 
 				// set his velocity to fast upward (for now)
-				game.create_sound(pos, SOUND_HAMMER_HIT);
+				game.create_hammerhit(pos);
 				ents[i]->take_damage(vec2(0,-1.0f), data->weapons.hammer.base->damage, player->client_id, active_weapon);
 				vec2 dir;
 				if (length(target->pos - pos) > 0.0f)
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index a36a9144..76609fe6 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -45,6 +45,18 @@ void GAMECONTEXT::create_damageind(vec2 p, float angle, int amount)
 	}
 }
 
+void GAMECONTEXT::create_hammerhit(vec2 p)
+{
+	// create the event
+	NETEVENT_HAMMERHIT *ev = (NETEVENT_HAMMERHIT *)events.create(NETEVENTTYPE_HAMMERHIT, sizeof(NETEVENT_HAMMERHIT));
+	if(ev)
+	{
+		ev->x = (int)p.x;
+		ev->y = (int)p.y;
+	}
+}
+
+
 void GAMECONTEXT::create_explosion(vec2 p, int owner, int weapon, bool bnodamage)
 {
 	// create the event
diff --git a/src/game/server/gamecontext.hpp b/src/game/server/gamecontext.hpp
index 6e833178..106efd5f 100644
--- a/src/game/server/gamecontext.hpp
+++ b/src/game/server/gamecontext.hpp
@@ -58,6 +58,7 @@ public:
 	void create_damageind(vec2 p, float angle_mod, int amount);
 	void create_explosion(vec2 p, int owner, int weapon, bool bnodamage);
 	void create_smoke(vec2 p);
+	void create_hammerhit(vec2 p);
 	void create_playerspawn(vec2 p);
 	void create_death(vec2 p, int who);
 	void create_sound(vec2 pos, int sound, int mask=-1);