From: MirceaKitsune Date: Tue, 23 Aug 2011 20:21:21 +0000 (+0300) Subject: Pieces of an attempt to make each display digit an attachable (and skinnable) entity... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=538d7c963cf2867def426a22e5a94a53e9d57192;p=voretournament%2Fvoretournament.git Pieces of an attempt to make each display digit an attachable (and skinnable) entity, which is the only way to base the screen numbers on actual ammo. Currently, I am stuck with this, because darkplaces does not see all the tags of the grabber model (maybe my md3 exporter for Blender is bad?) Code also unfinished and non-functional. --- diff --git a/data/models/weapons/v_grabber.md3 b/data/models/weapons/v_grabber.md3 index 207973bb..1d354ddd 100644 Binary files a/data/models/weapons/v_grabber.md3 and b/data/models/weapons/v_grabber.md3 differ diff --git a/data/qcsrc/server/cl_weaponsystem.qc b/data/qcsrc/server/cl_weaponsystem.qc index 06ee01e1..2590f1a1 100644 --- a/data/qcsrc/server/cl_weaponsystem.qc +++ b/data/qcsrc/server/cl_weaponsystem.qc @@ -1579,6 +1579,57 @@ void W_SetupProjectileVelocity(entity missile, float pSpeed, float spread) #define W_SETUPPROJECTILEVELOCITY_UP(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), cvar(#s "_speed_up"), cvar(#s "_speed_z"), cvar(#s "_spread")) #define W_SETUPPROJECTILEVELOCITY(m,s) W_SetupProjectileVelocityEx(m, w_shotdir, v_up, cvar(#s "_speed"), 0, 0, cvar(#s "_spread")) +.float digit_type; +void W_DisplayThink() +{ + // the owner has switched to another weapon, remove the digits + if(self.weapon != self.owner.weapon) + { + self.nextthink = 0; + remove(self); + self = world; + return; + } + self.nextthink = time; +setattachment(self, self.owner.weaponentity.weaponentity, strcat("displaydigit_", ftos(self.cnt))); + //dprint(strcat(ftos(self.cnt), " --------\n")); +} + +void W_DisplaySetup(entity own, float load_num, float load_scale, float ammo_num, float ammo_scale) +{ + float i; + for(i = 1; i <= load_num + ammo_num; i += 1) + { + entity digit; + digit = spawn(); + //setmodel(digit, "models/weapons/w_displaydigit.md3"); + setmodel(digit, "models/items/g_h1.md3"); + digit.owner = own; + digit.weapon = own.weapon; + digit.cnt = i; + + if(i <= load_num) + { + // weapon load digit + digit.digit_type = 0; + digit.scale = load_scale; + } + else + { + // ammo count digit + digit.digit_type = 1; + digit.scale = ammo_scale; + } + + digit.think = W_DisplayThink; + digit.nextthink = time; + //digit.viewmodelforclient = own; + //setattachment(digit, own.weaponentity.weaponentity, ""); + + dprint(strcat(own.weaponentity.weaponentity.classname, " --------\n")); + } +} + void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload) { if((self.items & IT_UNLIMITED_WEAPON_AMMO) && !ammo_reload) diff --git a/data/qcsrc/server/miscfunctions.qc b/data/qcsrc/server/miscfunctions.qc index d8c72f49..003cfbc0 100644 --- a/data/qcsrc/server/miscfunctions.qc +++ b/data/qcsrc/server/miscfunctions.qc @@ -1441,6 +1441,7 @@ void precache() // common weapon precaches precache_sound ("weapons/weapon_switch.wav"); precache_sound ("weapons/weaponpickup.wav"); + precache_model ("models/weapons/w_displaydigit.md3"); float i; for(i = 0; i < 8; i += 1) diff --git a/data/qcsrc/server/w_grabber.qc b/data/qcsrc/server/w_grabber.qc index 023b9e05..ad5fc984 100644 --- a/data/qcsrc/server/w_grabber.qc +++ b/data/qcsrc/server/w_grabber.qc @@ -218,6 +218,7 @@ float w_grabber(float req) weapon_setup(WEP_GRABBER); self.grabber_state &~= GRABBER_WAITING_FOR_RELEASE; self.current_ammo = ammo_fuel; + W_DisplaySetup(self, 2, 1, 3, 0.75); } else if (req == WR_CHECKAMMO1) { diff --git a/data/textures/grabber_d.tga b/data/textures/grabber_d.tga deleted file mode 100644 index 7bb6358d..00000000 Binary files a/data/textures/grabber_d.tga and /dev/null differ diff --git a/data/textures/grabber_ddigit.tga b/data/textures/grabber_ddigit.tga new file mode 100644 index 00000000..7bb6358d Binary files /dev/null and b/data/textures/grabber_ddigit.tga differ diff --git a/misc/source/media/models/weapons/v_grabber.blend b/misc/source/media/models/weapons/v_grabber.blend index 129fb502..2c89d677 100644 Binary files a/misc/source/media/models/weapons/v_grabber.blend and b/misc/source/media/models/weapons/v_grabber.blend differ