Page 1 of 1

Flagging melee damage

Posted: Wed Sep 04, 2019 3:38 am
by Kelly
This is mainly aimed at Nels, but anyone else is always welcome to jump in...

So I'm working on Gun Game and I'm concerned on how to deal with something. I'd like to add the ability for admins to use a single melee weapon that is given to all players for the entire match (along with the normal progression of weapon levels). If you manage to kill someone with your melee weapon you gain an extra level and if someone kills you with their melee then you lose a level.

That's all fine and good but now I am trying to work out how to filter the kills done with a melee weapon. How would you begin to go about this Nels? I need to know when melee is used no matter what the melee weapon is that's being used.

Edit: I worked this out at 2am this morning. Woke up thinking about the problem and had a potential solution so I just got up and coded it. I'm assigning a special damage type to the selected melee weapon when it's awarded to the player. Now I can monitor for that damage type on Scorekills and add the bonus/punishments when needed. The code is complex (for my skill level) but it's coming together.

Re: Flagging melee damage

Posted: Wed Sep 04, 2019 6:30 pm
by Nelsona
If I'm taking ImpactHammer in account, perhaps killer is alive 99.99% of cases - I don't think victim it's dying from a lost projectile in such a case. In this instance I will want to hunt killer's weapon.

Code: Select all

if ( Killer != None && Killer.Weapon != None )
{
	if ( Killer.Weapon.bMeleeWeapon )
	      SomethingNeeded();
}
In a quick thinking I don't know if some ammotype check (for NONE I'm guessing) or AmmoName, are not usable as alternate solutions. Pick the suitable one.
Fix me if I'm wrong.

Re: Flagging melee damage

Posted: Thu Sep 05, 2019 2:14 am
by Kelly
By changing the damage type to my custom one it seems to work just like I need it to. I looked at a bunch of melee weapons across multiple mods and there's really no clear thing that identifies all of them. I worked around this by destroying any ammo that the chosen melee weapon could have and this would force only true melee weapons to be used no matter what. If you don't then you end up with a useless item.

I then reset the damage type to "MeleeSpecial" and monitor that in Scorekill. When it sees that damage then I know it was someone using the melee and I can then make the proper awards. I have the basic framework all coded out and it does what I want it to do. I'm just trying to run down a few access nones that I'm not sure where they are coming from. I'll log it all out tonight/tomorrow.

Re: Flagging melee damage

Posted: Thu Sep 05, 2019 5:19 am
by Nelsona
That's also correct if you have in plan a new "meleeweapon", indeed it's easier to identify such a kill by using damagetype.

Re: Flagging melee damage

Posted: Sun Sep 08, 2019 5:12 am
by Kelly
There's no reason to create a new thread for a follow-up question Nels so I'll just post it here if that's OK.

I added Kill-Death Ratio to the scoreboard and set the code up so it all works right. The problem I have though is that I'd like to truncate the float value to 2 decimal places instead of 6. To be clear It now reads "2.333333" for example and I'd like to make it "2.33". I scoured the functions list and I don't see how to do this without converting to a string value and going that route. Am I missing something easier?

Re: Flagging melee damage

Posted: Sun Sep 08, 2019 1:25 pm
by Nelsona
Wow, it's beyond my maths skill, I'll stick for string conversion...

Re: Flagging melee damage

Posted: Sun Sep 08, 2019 4:14 pm
by Kelly
Yeah, mine too. I was just trying to avoid having to find the "." and parsing the entire thing out. I'll let you know if dots or MasterKent responds to me.