strange behavior occurs when using "map"

i’ve setup a player map tracking player trigger counts to give score to player accordingly. for each x amount of trigger event, the player gets one points, the player map will then reset to 0 and continues. code works most of the time but sometime the it goes rogue and gives player a ginormous amount of score. i’ve tried to debug and replicate the scenario but it never happened when i’m testing in edit mode. it only happens in public game when there’s multiple player. can someone tell me did i do wrong here?

bug

     @editable var triggers : []trigger_device = array{}
     @editable var score_manager : score_manager_device = score_manager_device{}
 
     var PlayerHitTracker : [player]int = map{}
     var interval : float = 5.0
     var HitsPerMeter : ?int = false
 
     OnBegin<override>()<suspends>:void=
         AllPlayers := GetPlayspace().GetPlayers()
         for(Player : AllPlayers):
             if{set PlayerHitTracker[Player] = 0}
         
         set HitsPerMeter = option{Round[100.0/interval]}
 
         for(trigger: triggers):
             trigger.TriggeredEvent.Subscribe(OnTriggerHit)
 
     OnTriggerHit(Agent : ?agent): void =
         if(TriggeredAgent := Agent?, TriggeredPlayer := player[TriggeredAgent], HPM := HitsPerMeter?):
             if(PlayerHitTracker[TriggeredPlayer] < HPM):
                 if{set PlayerHitTracker[TriggeredPlayer] += 1}
             else:
                 if(set PlayerHitTracker[TriggeredPlayer] = 0):
                     score_manager.Activate(TriggeredAgent)
                     score := score_manager.GetCurrentScore(TriggeredAgent)
                     Print("{score}")
 
     OnPlayerAdded(NewPlayer : player) : void =
         if{set PlayerHitTracker[NewPlayer] = 0}

to add more to the context, the reason i think it’s “map” that causing the issue is, i have a separated gold reward system that awards gold every time the trigger devices get triggered. and it works perfectly all the time, even when player gets the abnormal high score.

1 trigger hit = 1 gold #works perfectly fine
30 trigger hit = 1 score #player gets abnormal high score randomly

Do you have some vehicles on your map? Just know that by doing trickshots with vehicles you gain a big amount of score. If you want to disable it, Set “Vehicle Trick Score Multiplier” to 0.0 in the island settings.

2 Likes

thank you so much for this!!! this is exactly what’s causing the issue. never knew vehicle trick shot counts towards score in creative. i’ve adjust the settings, hopefully it works normally now

1 Like