• 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.

[Trigger] Player Camera Location

Status
Not open for further replies.
Level 9
Joined
Nov 17, 2004
Messages
277
Hi, I'm trying to design a feature in my map in which a particular player's screen darkens when he is looking at a certain region of the map. I've found in WEU the ability to apply a filter to an individual player, but as of yet no way to initiate this trigger. Does anyone have any ideas?
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
To apply a filter to a single player, you need to use the GetLocalPlayer() command.

JASS:
if GetLocalPlayer() == YourPlayer then 
// example: GetLocalPlayer()==GetOwningPlayer(GetTriggerUnit())
      actions
endif

Notice that you can put this also in GUI with custom scripts.

As for the event, I think this will do it
  • Set RealOne = (Target X of current camera view)
  • Set RealTwo = (Target Y of current camera view)
Now check if those reals are inside your region.
 
Level 9
Joined
Nov 17, 2004
Messages
277
Ok, but how do I make it so that the filter applies when he looks at a certain region? I was going to use a WEU feature for the filter, I just need any clever event or condition (if I made a periodic check) to see if he's looking at the region.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I edited my post.

If you still don't get it, here are some guide lines:
  • Use a periodic event
  • Create a loop that uses the GetLocalPlayer() function
  • For every player the loops run for set their own two real variables to their camera's position
  • Check if those reals are in the right regions and filter if they are

Here is an rough example of the code:
JASS:
function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    local integer i = 0
    local real x
    local real y
    loop
        exitwhen i = 15 // 15 = max players in warcraft (you don't really need 15)
        if GetLocalPlayer() == Player(i) then
            set x = GetCameraEyePositionX()
            set y = GetCameraEyePositionY()
            if RectContainsCoords(some rect, x, y) == true then
                //put your filter stuff here
            endif
        endif
    endloop
endfunction

//===========================================================================
function InitTrig_Untitled_Trigger_001 takes nothing returns nothing
    set gg_trg_Untitled_Trigger_001 = CreateTrigger(  )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Untitled_Trigger_001, 0.20 )
    call TriggerAddAction( gg_trg_Untitled_Trigger_001, function Trig_Untitled_Trigger_001_Actions )
endfunction

If you don't know Jass... tough luck lol.
Making GUI triggers is just too annoying.
 
Status
Not open for further replies.
Top