• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Enter Region only working for Player 1?

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

Why is this trigger only firing for player 1? AFAIK, there's no parameter for a player argument for an Enter Region event. This trigger works perfectly for Player 1, but it won't do jack for any other player.

JASS:
    static method enterMain takes nothing returns boolean
        local player p = GetTriggerPlayer()
        local integer pid = GetPlayerId(p)
		call DisplayTimedTextToPlayer(players[pid], 0, 0, 10, "Entered a region?")
    endmethod

    method setup takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddCondition(t, Condition(function CreepRegion.enterMain))
        call TriggerRegisterEnterRegion(t, this.r, null)
        set t = null
    endmethod
 
Last edited by a moderator:

EdgeOfChaos

E

EdgeOfChaos

Are you sure the players[] array is initialized correctly?
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
That's not the problem (I just checked myself, but players[] is properly initialized and works in all other instances.). And here, I'll change it to "p."

The problem is the trigger isn't firing for anyone except Player 1. This doesn't make sense to me, since you cannot bind EnterRegionEvents to specific players without a filter. And I'm not using any filter
here.

Edit: I tried changing it to TriggerRegisterEnterRegionSimple but it didn't change squat.

JASS:
    static method enterMain takes nothing returns boolean
        local player p = GetTriggerPlayer()
        local integer pid = GetPlayerId(p)
	call DisplayTimedTextToPlayer(p, 0, 0, 10, "Entered a region?")
    endmethod

    method setup takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddCondition(t, Condition(function CreepRegion.enterMain))
        call TriggerRegisterEnterRegion(t, this.r, null)
        set t = null
    endmethod
 

EdgeOfChaos

E

EdgeOfChaos

Can you post what condition "CreepRegion.enterMain" is? That's the only thing I can see that would do it
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
This is CreepRegion.enterMain...

JASS:
    static method enterMain takes nothing returns boolean
        local player p = GetTriggerPlayer()
        local integer pid = GetPlayerId(p)
    call DisplayTimedTextToPlayer(p, 0, 0, 10, "Entered a region?")
    endmethod
 
Level 15
Joined
Aug 7, 2013
Messages
1,338
Genius purge. That was the problem. GetTriggerPlayer() returns null for these kind of events.

The reason why it worked for player 1 was because the integer pid defaults to 0 for null players?
 
The reason why it worked for player 1 was because the integer pid defaults to 0 for null players?

Yep. For future reference, GetTriggerPlayer usually works with things like TriggerRegisterPlayerEvent or TriggerRegisterPlayerUnitEvent, but for other events, I would use something else, such as GetOwningPlayer.
 
Status
Not open for further replies.
Top