Timer Bug

Status
Not open for further replies.
I'm having an issue with a Timer in my map, Hostile Territory.

Basically, when you fire a weapon, it is supposed to start a Timer (it's MPI, ie. there's a Timer for each player). This action is found in the triggers:
Character Control\Fire
Character Control\Switch
Character Control\Action
  • Set wep_reloading[(Player number of (Owner of (Triggering unit)))] = True
Another trigger that activates at Map Initialisation;
Map systems\Map Setup
will add all the MPI 'Timer[] Expires' events to this trigger;
Character Control\Reload
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • -------- Actions... --------
      • Trigger - Add to Reload <gen> the event (Time - wep_reloadtimer[(Integer A)] expires)
  • Reload
    • Events
    • Conditions
    • Actions
      • For each (Integer B) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set temp_int = (Integer B)
          • Custom script: if GetExpiredTimer() == udg_wep_reloadtimer[udg_temp_int] then
          • Game - Display to (All players) the text: hey
          • Set wep_reloading[temp_int] = False
          • Custom script: endif
The problem:
Somehow, whenever you're not playing as Player 1 Red, the first time you shoot/switch weapons/pick up a weapon, is the ONLY time you can ever get a bullet out of your unit within that round.
I know it is linked to the trigger Character Control\Reload. I discovered this by placing a debug message, which only appears for Player 1 Red.

Helpers will receive +4 rep.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Nope, it's not that.

Then where is the trigger where you init the timers?

If I test with this

  • Untitled Trigger 001
    • Events
      • Player - Player 1 (Red) types a chat message containing test as An exact match
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Trigger - Add to Untitled Trigger 002 <gen> the event (Time - wep_reloadtimer[(Integer A)] expires)
          • Countdown Timer - Start wep_reloadtimer[(Integer A)] as a One-shot timer that will expire in 1.00 seconds
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Custom script: if udg_wep_reloadtimer[bj_forLoopAIndex] == null then
          • Game - Display to Player Group - Player 1 (Red) the text: ((String((Integer A))) + is null)
          • Custom script: endif
  • Untitled Trigger 002
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: Expire


It will display null for everyone else but P1 and the 002 trig will only trigger once which makes sense since only P1 timer is initialized, the initial size for wep_reloadtimer is 1.

Did you try it with setting the size to 12 for example?

Oh and instead of looping through all the timers like this:

  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • Custom script: if GetExpiredTimer() == udg_wep_reloadtimer[GetForLoopIndexA()] then
      • Set wep_reloading[(Integer A)] = False
      • Custom script: endif

you should break out of the loop when the correct one is found. Or skip the loop altogether by saving a integer index for the timer in a hashtable at initialization, and the loading then index with the timer handle -> Set wep_reloading[*Load value from hashtable*] = False
 
Status
Not open for further replies.
Top