Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Weapon displays that show ammo

#1
I've been making improvements to my game Vore Tournament in the last days. Yesterday, I managed to get the weapon display working and indicating ammo properly. Since I believe this would be an awesome feature in Xonotic, I thought to share it here.

How it's done: VT is forked from Nexuiz, so it uses server-side entities even for the view model. Each display digit consists of a flat surface, which has the same center as v_weapon but with the mesh positioned to fit the screen. In-game, the weapon spawns all of its digits when you switch to it, the digits being removed once your weapon changes. Each digit is a separate entity, attached to the same origin as the gun model. divVerent suggested I add attachment tags to the weapon and put digits on that, but my md3 exporter doesn't handle this well so I made each digit separate.

Next up, each digit contains 11 skins, consisting of numbers 0 to 9 and an empty digit. Each digit knows the character it represents in the ammo string, and uses substring(ftos(self.(self.current_ammo)), blah, blah) to get the proper value. The number is next converted back into a float and self.skin set to it. If the string returns "" (happens when your ammo goes under 3 digits, like dropping from 110 to 90) then the blank texture is used. Otherwise 60 would show as 600 and so on. Digits are shown on both the view model and exterior weapon model, which means that if you're good enough you can see the ammo on your enemy's weapon... although in practice that's nearly impossible Tongue

Like I said, I'd adore to see this in Xonotic. Weapon displays rock, and I love how UT99 used to do it. Some weapons could have hologram displays too, with transparent numbers floating above a small device on the weapon. Since my game uses reloading by default, 2 digits show the weapon load and the other 3 ammo. Since most Xonotic guns use ammo directly, we'd only need 3 digits, showing ammo normally and weapon load if reloading is enabled for that gun.

Below are screenshots and a video of how this is done in VT (you can see the ammo on the weapon matches the one on the HUD). I'm also posting the code used by the digits, in case it's of any interest. This code is located at the bottom of cl_weaponsystem.qc right before void W_DecreaseAmmo. W_Display is called in w_*.qc in the (req == WR_SETUP) check, and is compatible with any weapon.

Code:
void W_DisplayDigitThink()
{
    self.nextthink = time;

    // the owner has switched to another weapon, remove the digits
    if(self.weapon != self.owner.weapon)
    {
        self.nextthink = 0;
        remove(self);
        self = world;
        return;
    }

    entity gun;
    if(self.dmg) // exterior weapon
    {
        // keep the digit attached to the same bone as the gun
        setattachment(self, self.owner, "bip01 r hand");
        gun = self.owner.exteriorweaponentity;
    }
    else // view weapon
    {
        // keep the digit attached to the same bone as the gun
        // TODO: Does this work with self-animated weapons too?
        if(gettagindex(self.owner.weaponentity, "weapon"))
            setattachment(self, self.owner.weaponentity, "weapon");
        else if(gettagindex(self.owner.weaponentity, "tag_weapon"))
            setattachment(self, self.owner.weaponentity, "tag_weapon");
        gun = self.owner.weaponentity.weaponentity;
    }

    // copy all properties of the weapon to the digit
    self.origin = gun.origin;
    self.angles = gun.angles;
    self.scale = gun.scale;
    self.effects = gun.effects;
    self.alpha = gun.alpha;
    self.colormap = gun.colormap;
    self.colormod = gun.colormod;
    self.glowmod = gun.glowmod;

    string txt;
    if(self.team) // weapon load display
    {
        if(self.owner.weapon_load[self.owner.weapon] <= 0)
        {
            self.skin = 11; // unavailable digit
            return;
        }
        else
        {
            txt = ftos(floor(self.owner.weapon_load[self.owner.weapon]));
            txt = substring(txt, self.cnt - 1, 1);
        }
    }
    else // ammo display
    {
        txt = ftos(floor(self.owner.(self.owner.current_ammo)));
        txt = substring(txt, self.cnt - 1, 1);
    }

    if((!txt || txt == ""))
        self.skin = 10; // empty digit
    else
        self.skin = stof(txt);
}

void W_DisplayDigitSetup(entity own, float num, float load, float exterior)
{
    entity digit, e;
    digit = spawn();
    digit.owner = own;
    digit.weapon = own.weapon;
    digit.dmg = exterior;
    digit.team = load;
    digit.cnt = num;
    e = get_weaponinfo(digit.weapon);

    if(load)
    {
        // weapon load digit
        setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit1-", ftos(num) , ".md3"));
    }
    else
    {
        // ammo count digit
        setmodel(digit, strcat("models/weapons/v_", e.netname, "_digit2-", ftos(num) , ".md3"));
    }
    digit.think = W_DisplayDigitThink;
    digit.nextthink = time;
}

void W_Display(entity own, float load_num, float ammo_num)
{
    float i;
    for(i = 1; i <= load_num; i++)
    {
        W_DisplayDigitSetup(own, i, TRUE, FALSE); // weapon load digit, view model
        W_DisplayDigitSetup(own, i, TRUE, TRUE); // weapon load digit, exterior model
    }
    for(i = 1; i <= ammo_num; i++)
    {
        W_DisplayDigitSetup(own, i, FALSE, FALSE); // ammo count digit, view model
        W_DisplayDigitSetup(own, i, FALSE, TRUE); // ammo count digit, exterior model
    }
}

[Image: atwl8wi7wpu4ou9ssecj_thumb.jpg] [Image: fxdovwrrisrdn6wnwl9_thumb.jpg] [Image: k06u38t6vtgvqhglio9n_thumb.jpg] [Image: 8w5mu5flmop6on3u57v5_thumb.jpg]



Let me know what you think about this, which weapons you believe this would look good on (and how), and what your ideas for implementation are. Note that divVerent is working on csqc models, which will certainly change how this needs to be implemented.
Reply

#2
That's a cool idea. I don't wish to be offensive but isn't that game a little bit... um... weird? I mean you don't actually like it, in THAT way do you? Oh and I've always wondered... What is with the ponies?
Reply

#3
/OFF
Don't ask... that's a "furry thing" Wink
Also, everybody has the right to be a bit crazy... at least untill it's not offensive. I can't find anything offensive in this. Weird like hell, but nothing more. Big Grin
[Image: 561.png]
"One should strive to achieve; not sit in bitter regret."
Reply

#4
(11-18-2011, 12:23 PM)rocknroll237 Wrote: That's a cool idea. I don't wish to be offensive but isn't that game a little bit... um... weird? I mean you don't actually like it, in THAT way do you? Oh and I've always wondered... What is with the ponies?

Neither the ponies nor vorarephilia are furry things.

And about ponies, check this (don't click if you are epileptic, flashy gif background in that section of the forum): http://forums.xonotic.org/showthread.php?tid=2331
Reply

#5
If anything, I think this would be best for the machine gun and the rifle as both of these weapons need to reload.

It would be nice to know how much ammo you have before you reload Big Grin

This would mean that we would need different weapon models to showcase this.

Anyone else thinking the same?
Reply

#6
Seen that pony thread. And yeah, the game isn't offensive but it is about vore. I can understand people finding that weird Tongue Though I appreciate everyone here being nice and civil about it, and not like some people on Youtube when they disagree... since I can't help noticing the big difference when it comes to the quality of each community. But yes... the game itself is good and playable like any FPS, and gameplay should be rather interesting. No need to be into vore at all to enjoy it, though you need to not mind it either. Obviously, if I worked so hard to make a whole game alone about this, I do love it :3

But back on topic. Yeah, this would certainly be awesome in Xonotic too... especially if some weapons would use screens and others a holographic display. I think this adds much more depth and detail, and will make the feel of weapons a lot nicer. So far, the Electro is one of the first candidates that come to mind, since it has that black screen that no one even textured. The UZI has a screen also, which looks pretty fit for this. The Nex is good too.
(11-18-2011, 04:09 PM)Squigger Wrote: If anything, I think this would be best for the machine gun and the rifle as both of these weapons need to reload.

It would be nice to know how much ammo you have before you reload Big Grin

This would mean that we would need different weapon models to showcase this.

Anyone else thinking the same?

I don't believe this would be needed only for weapons that reload by default. Like in UT, they could show the ammo count for any gun. Also, not all weapons would need new models. Some already have textured screens, that digits could be placed in front of. I created my screen on the Nexuiz hook gun, modeling + texturing it in place. eg: For the Electro, digits could be placed in front of the existing screen with a small offset, without having to add new details to the mesh.
Reply

#7
I see, cool Big Grin
I definitely support this then Cool
Reply

#8
As I said on IRC, absolutely love the idea. Alien II MG Displays, anyone? Big Grin
Would be awesome on a darker futuristic game, but works for Xonotic also.

The only thing still missing for those then, would be directional sound distortions :O

Looks like I understand the code, too bad I probably can't make the model-related part work.
Reply

#9
That's great, I really liked that in D3. Could you do a charging display for the nex gun?
"If your killer instincts are not clean and strong you will hesitate at the moment of truth. You will not kill. You will become dead marines and then you will be in a world of shit, because marines are not allowed to die without permission. Do you maggots understand?" - Gunnery Sergeant Hartman
Reply

#10
This is pretty cool, I think I'm too used at looking at the hud for ammo/armor/health, so I don't think it would that much useful to me but I don't see why it shouldn't be added to xonotic if it doesn't slow down or break anything.

As a side note, I've always hoped that ammo shown would show how many shots you have left (ie: Firing RL uses 4 rockets, Mortar 2) instead (or along with, somehow) of actual ammo. I assume that will only be possible with CSQC?
Reply

#11
Its cool indeed, problem is its not a very "good way" of doing it - this needs one entity and 10 skins per digit to display on that "weapon screen". A bit wasteful - how much so will need to be investigated before its considered for inclusion in master.
Reply

#12
(11-22-2011, 12:53 AM)tZork Wrote: Its cool indeed, problem is its not a very "good way" of doing it - this needs one entity and 10 skins per digit to display on that "weapon screen". A bit wasteful - how much so will need to be investigated before its considered for inclusion in master.

Yes, you can put attachment tags on a model and attach the same panel to that, decreasing model and skin count. My md3 exporter wouldn't handle that well, so I made a separate mesh for each digit of my gun. Also, it would need 11 skin files not 10. numbers 0-9 plus an empty digit, so 20 ammo won't show as 200 or 020 and the text stays leftmost.

Anyway, I'm waiting for divVerent's csqc_models to be merged, then I might look into this. But like I said, my md3 exporter for Blender doesn't export multiple tags well (or DarkPlaces doesn't detect them). So I can adapt the code and do the written part, but I'd need people to send me the updated v_*.md3 models with attachment tags for the three digits (I can create the flat plane myself). If anyone does that, don't forget to send me the .blend file too so I can update the source as well.

Anyway, here are some BADLY PHOTOSHOPPED screenshots to give an idea of what I'd like to see. They look rather horrible, but they're only to give an idea of how I'd them for some guns (RL and UZI are better with a non-hologram screen).

[Image: 8u3sx3f33a7g85nll2kr_thumb.jpg] [Image: 9m19uswgyl7f735xfy1m_thumb.jpg] [Image: 6s3kjctzqt84ab7y4raa_thumb.jpg]
Reply

#13
From a gameplay point of view, the only real weapons that would benefit from an ammo display are ones that need to be reloaded or ones that charge. Specifically I think the rifle and machinegun should display how many rounds are in a magazine since the only other thing onscreen that shows it is the crosshair, which some old school players (like myself) might disable. The nex might benefit from a charge meter, though it glowing red makes it's charge pretty obvious already.
ECKZBAWKZ HUGE LIST OF ACHIEVEMENTS GOES HERE....


Oh wait.
Reply

#14
I play without weapon models nowadays anyway... but every little piece of added detail can enhance the atmosphere.
My Xonstats Profile
Latest track on soundcloud: Farewell - to a better Place (piano improvisation)
New to Xonotic? Check out the Newbie Corner!

Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Where are Weapon skins? NoClue 0 1,493 07-07-2022, 01:26 PM
Last Post: NoClue
  Can I adjust the weapon model size and stuff? Molnija 1 2,280 03-13-2019, 12:28 AM
Last Post: BuddyFriendGuy
  weapon size Molnija 0 2,153 12-03-2018, 05:22 AM
Last Post: Molnija
  Custom Weapon Balance - Live on /v/ server Antares* 30 19,318 09-30-2016, 11:52 AM
Last Post: Antares*
Rainbow curvegun (custom weapon) dingus 8 8,840 08-03-2016, 02:35 PM
Last Post: dingus
  Weapon models WIP help. Beagle 1 3,495 05-17-2015, 06:52 PM
Last Post: Beagle
  Weapon and Lightning Gun Testing Mario 18 16,199 11-11-2014, 08:02 PM
Last Post: Lee_Stricklin
  weapon with different effects according to team soukaina 23 19,107 06-06-2013, 01:20 PM
Last Post: Mr. Bougo
Information Spawn Weapon Concept: "Blaster" Samual 85 85,554 03-27-2013, 01:18 PM
Last Post: Samual
  Weapon Settings Question? kidx 22 17,937 08-30-2012, 08:04 PM
Last Post: Mr. Bougo

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB original theme © iAndrew 2016, remixed by -z-