added pickup sounds for the weapons

This commit is contained in:
Magnus Auvinen 2007-08-03 06:35:35 +00:00
parent 681fbaf011
commit 7703137618
5 changed files with 37 additions and 5 deletions

View file

@ -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.*

View file

@ -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"

View file

@ -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":

View file

@ -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: