From 770313761870b3e68049fa894f097a8bbec80420 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Fri, 3 Aug 2007 06:35:35 +0000 Subject: [PATCH] added pickup sounds for the weapons --- ...up_laucher.wav => sfx_pickup_launcher.wav} | Bin datasrc/server.dts | 10 ++++----- datasrc/teewars.ds | 4 ++++ scripts/compiler.py | 21 ++++++++++++++++++ src/game/server/game_server.cpp | 7 ++++++ 5 files changed, 37 insertions(+), 5 deletions(-) rename data/audio/{sfx_pickup_laucher.wav => sfx_pickup_launcher.wav} (100%) diff --git a/data/audio/sfx_pickup_laucher.wav b/data/audio/sfx_pickup_launcher.wav similarity index 100% rename from data/audio/sfx_pickup_laucher.wav rename to data/audio/sfx_pickup_launcher.wav diff --git a/datasrc/server.dts b/datasrc/server.dts index aba315141..46a97bfc3 100644 --- a/datasrc/server.dts +++ b/datasrc/server.dts @@ -1,3 +1,8 @@ +const array:int sound = sounds.* +const array:int weapon = weapons.* +const array:int gametype = playerstats.* +const array:int powerup = powerups.* + struct weapon { int firedelay = firedelay@1 int meleedamage = meleedamage@1 @@ -25,8 +30,3 @@ struct data_container { array:playerstats playerinfo = playerstats.* array:powerupinf powerupinfo = powerups.* } - -const array:int sound = sounds.* -const array:int weapon = weapons.* -const array:int gametype = playerstats.* -const array:int powerup = powerups.* \ No newline at end of file diff --git a/datasrc/teewars.ds b/datasrc/teewars.ds index 921eb5846..096fc3266 100644 --- a/datasrc/teewars.ds +++ b/datasrc/teewars.ds @@ -143,6 +143,10 @@ sounds { "data/audio/sfx_pickup_sg.wav" } + pickup_ninja { + "data/audio/sfx_pickup_ninja.wav" + } + weapon_spawn { "data/audio/sfx_spawn_wpn-01.wav" "data/audio/sfx_spawn_wpn-02.wav" diff --git a/scripts/compiler.py b/scripts/compiler.py index daa74e95d..ccafdae41 100755 --- a/scripts/compiler.py +++ b/scripts/compiler.py @@ -150,6 +150,7 @@ class data_constructor: self.trans = 0 self.pointers = [] self.targets = {} + self.enums = {} def get_type(self, s): return self.trans.types[s] @@ -162,6 +163,14 @@ class data_constructor: def add_pointer(self, index, target): self.pointers += [pointer(index, target)] + def add_enum(self, name, value): + self.enums[name] = value + + def get_enum_value(self, name): + if not name in self.enums: + print "ERROR: couldn't find enum '%s'" % (name) + return self.enums[name] + def add_target(self, target, index): # TODO: warn about duplicates #print "add_target(target='%s' index=%d)" % (target, index) @@ -300,6 +309,16 @@ class variable_ptr(variable): target = src_data.get_single(self.expr) cons.add_pointer(index, target) +class variable_enum(variable): + def get_code(self): + return ["long *%s;" % (self.name)] + def size(self): + return option_intsize + def emit_data(self, cons, index, src_data): + target = src_data.get_single(self.expr) + data = struct.pack("l", cons.get_enum_value(target)) + cons.write(index, len(data), data) + class variable_instance(variable): def get_code(self): return ["%s %s;" % (self.subtype, self.name)] @@ -383,6 +402,8 @@ class translator: subtype = "" if type == "int": v = variable_int() + elif type == "enum": + v = variable_enum() elif type == "float": v = variable_float() elif type == "string": diff --git a/src/game/server/game_server.cpp b/src/game/server/game_server.cpp index 841be9b84..d5ba355f3 100644 --- a/src/game/server/game_server.cpp +++ b/src/game/server/game_server.cpp @@ -1455,6 +1455,12 @@ void powerup::tick() pplayer->weapons[subtype].got = true; pplayer->weapons[subtype].ammo = min(10, pplayer->weapons[subtype].ammo + data->powerupinfo[type].amount); respawntime = data->powerupinfo[type].respawntime; + + // TODO: data compiler should take care of stuff like this + if(subtype == WEAPON_ROCKET) + create_sound(pos, SOUND_PICKUP_ROCKET); + else if(subtype == WEAPON_SHOTGUN) + create_sound(pos, SOUND_PICKUP_SHOTGUN); } } break; @@ -1465,6 +1471,7 @@ void powerup::tick() pplayer->weapons[WEAPON_NINJA].got = true; pplayer->active_weapon = WEAPON_NINJA; respawntime = data->powerupinfo[type].respawntime; + create_sound(pos, SOUND_PICKUP_NINJA); break; } default: