Help needed! counting shots

I’ve used an ongoing event where I check if the event player is firing primary fire. This works well for heroes like McCree where every shot counts as an event, but with heroes that have more rapid fire weapons, it doesn’t count every shot, but rather every time you press the mouse button.

I solved this at first by looping if ammo was spent, which worked fine, but then I realized it won’t work for heroes like D.va that don’t have ammo…

I’ve been struggling with this for a while now. I cannot find a way to count shots as D.va when I’m holding left mouse button.

You might have to manually add in the time between shots in a wait function. You can find these numbers on overwatch hero wikis. D.va Has 0.15s between shots.

Example for D.va

Conditions:

Is Button Held(Event Player, Button(Primary Fire)) == True
Hero Of(Event Player) == Hero(D.Va)

Actions:

Event Player.ShotsFired = Event Player.ShotsFired + 1
Wait(0.150, Ignore Condition)
Loop If Condition Is True

Another option is to create an array and manually add every value of time between shots and then assigning the wait time to a value in the array that corresponds to a certain hero. If you dont know how arrays work id recommend taking a look at Pug’s Video on workshop arrays.
youtube com watch?v=k4iG0EaIcas

3 Likes

Part of the point of doing what I’m trying to do is to avoid doing this. I’m trying to get all the information from the game itself. It’s like an information gathering mode.

The problem is that I can’t find a way to have an “event” of d.va actually firing a shot. It only detects when she starts holding down the button.

Edit: I think the event is firing primary updates when it goes from false to true from one server tick to the next, but then it stops running the code if it stays true. I tried to disable primary fire, wait until primary fire is no longer active, then enable primary fire again, to try to trigger the event again, but I couldn’t get that to work either.

Do you think there’s a way to force it to update every server tick? Or at least make primary fire be disabled for a single server tick, then re-enable it.

Things you can do to fix this:

  • Add both Wait(0.016); and Loop if condition is true; at end of action list to ensure that if condition is true near every server tick (60hz) will execute again.
  • Using evaluate every tick(is firing primary(event player)) in conditions to prevent that is firing primary begin cached for that tick in that rule, and make new request every time from server, and rule will execute always that conditions is true.
  • If you wanna track if player shoot and hit some player, you can use damage dealt event, this rule is invoked every time you deal damage, including players that have high fire rates.
1 Like

Couldn’t you use built in stats? They have “Player Hero Stat” as a value you can use. So like you could call straight for it inside a hud.

Player Hero Stat(Local Player, Hero Of(Local Player), Shots Fired)

or if you want to save the variable somewhere you could do that too, but use Event Player obviously.

They also have stats for shots missed, and shots hit, and even scoped shots.

A few problems with these stats depending on what you want them for:

*These stats don’t track if the game is not considered in progress. (if you use skirmish, don’t worry they consider that in progress so the stats count)

*They also will stay the same on the hero they were on previously if they were to swap and then swap back, which could be useful or not, but if you wanted to reset the stats for the hero, then you could probably save this stat inside a variable, adding the difference or something every time it’s updated, then if they swap heroes, reset that variable back to 0.

*Shotgun type weapons count literally every bullet that is shot out of 1 ammo. (for these heroes you could just divide the stat by the ammo that you know each character shoots, such as d.va shoots 11 shots per gun in her mech, and reaper shoots 20 bullets per shot, so what we could do is say if reaper shot 4 times, it would say 80 shots were fired, divide that by 20, it should now say 4 shots were fired, if you were displaying this in a hud, use if-then-else, check if hero of (event or local player) = hero, d.va, then divide the stat by 11, and then do another if-then-else in the else checking for each shotgun hero.

*The display of these stats update every few frames, so it won’t see a smooth increase if you were shooting shots with bastion, but it is 100% accurate on the shots they shoot.

*These stats don’t track on dummy bots.

2 Likes

Thanks, I will try this!