• 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] Two Questions

Status
Not open for further replies.
Level 11
Joined
Aug 11, 2009
Messages
605
Why I have these questions is because I am trying to make a certain Hero Selection screen which requires a certain camera view, and I dont want the player to be able to select a certain unit.

1. How do you completely lock a camera to a certain view so it cannot be changed in any way until a trigger releases it?
- I tried setting a event "Every 0.05 sec" it sets the view to a certain camera, but if you constantly click arrow keys or the mini map the view will change for a short time.

2. How do you make a unit un-selectable until a trigger removes it?
- I have tried using event Player selects unit and then make an action which clears the selection but then you can see the unit for 0.5 sec or something.
- I also checked if I could add Locust through triggers, but it didnt.


+rep for any help on this! Thanks for taking your time
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
1) You can create a camera dummy and lock the camera to that unit.
Scrolling still works, but this is unavoidable I believe (periodic triggers can counteract it, but not prevent).

2) You can add locust to a unit by using JASS. I believe this is the code:
  • Custom script: call UnitAddAbility( udg_Unit, 'Aloc' )
This will add Locust ('Aloc') to the unit stored in the variable "Unit" (if the code is correct :p).
Removing locust is a bit harder: you have to hide the unit, then do
  • Custom script: call UnitRemoveAbility( udg_Unit, 'Aloc' )
And then unhide the unit.
 
Level 11
Joined
Aug 11, 2009
Messages
605
Will try and lock to unit combined with periodic event, thanks!

Ok, i know i have played some maps where you could spam a hero portrait and still not be able to target it, dunno if it is locust or some other trigger, Will try your custom line though :) thank you
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
Using camera lock disables the player to click onto the minimap.
You should use X/Y coordinates instead.

To make a unit unselectable, you could easily use "none.mdl" as the unit model or add locust to that unit then hide it and remove locust and then unhide it again.
This will also make the unit unselectable but it will also obey pathing and will not be invulnerable as Locust adds this effect to it.

JASS:
local unit u = GetTriggerUnit()
local location p = GetUnitLoc(u)
local real x = GetLocationX(p)
local real y = GetLocationY(p)
call PanCameraToTimedLocForPlayer( Player(0), Location(x, y), 0 )
call RemoveLocation (p)

for the first.

JASS:
local unit u = GetTriggerUnit()
call UnitAddAbility(u, 'Aloc')
call ShowUnit(u, false)
call UnitRemoveAbility, u, 'Aloc')
call ShowUnit(u, true)
for the second part.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
I wrote a camera locking library a long time ago.

JASS:
library CamFreeze initializer InitTrig_CF

    globals
        private constant    real                TOUT    = 0.1           // Camera update rate
        private constant    real                TPAN    = 0.1           // Camera pan time
        private constant    integer             PLRS    = 1             // Max number of players
    endglobals

    globals
        private             integer             P       = 0
        private             timer               TMR     = CreateTimer()
        private             force               FOR     = CreateForce()   
        private             trigger             TRG     = CreateTrigger()
        private             camerasetup array   CSA
        private             hashtable           ht      = InitHashtable()
    endglobals
    
    function CF_LoadCam takes player p returns nothing
        local integer pid = GetPlayerId(p)
        if GetLocalPlayer() == p then
            call SetCameraPosition(LoadReal(ht, pid, StringHash("camX")), LoadReal(ht, pid, StringHash("camY")))
            call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, bj_RADTODEG*LoadReal(ht, pid, StringHash("camAOA")), 0)
            call SetCameraField(CAMERA_FIELD_FARZ, LoadReal(ht, pid, StringHash("camFarZ")), 0)
            call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, bj_RADTODEG*LoadReal(ht, pid, StringHash("camFOW")), 0)
            call SetCameraField(CAMERA_FIELD_ROTATION, bj_RADTODEG*LoadReal(ht, pid, StringHash("camRot")), 0)
            call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, LoadReal(ht, pid, StringHash("camDist")), 0)
            call SetCameraField(CAMERA_FIELD_ZOFFSET, LoadReal(ht, pid, StringHash("camZOff")), 0)
        endif
    endfunction
    
    function CF_SaveCam takes player p returns nothing
        local integer pid = GetPlayerId(p)
        if GetLocalPlayer() == p then
            if not LoadBoolean(ht, GetPlayerId(p), 0) then
                call SaveReal(ht, pid, StringHash("camX"), GetCameraTargetPositionX())
                call SaveReal(ht, pid, StringHash("camY"), GetCameraTargetPositionY())
                call SaveReal(ht, pid, StringHash("camAOA"), GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK))
                call SaveReal(ht, pid, StringHash("camFarZ"), GetCameraField(CAMERA_FIELD_FARZ))
                call SaveReal(ht, pid, StringHash("camFOW"), GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW))
                call SaveReal(ht, pid, StringHash("camRot"), GetCameraField(CAMERA_FIELD_ROTATION))
                call SaveReal(ht, pid, StringHash("camDist"), GetCameraField(CAMERA_FIELD_TARGET_DISTANCE))
                call SaveReal(ht, pid, StringHash("camZOff"), GetCameraField(CAMERA_FIELD_ZOFFSET))
            endif
        endif
    endfunction
    
    private function Updt takes nothing returns boolean
        if GetLocalPlayer() == GetFilterPlayer() then
            call CameraSetupApplyForceDuration(CSA[GetPlayerId(GetFilterPlayer())], true, TPAN)
        endif
        return false
    endfunction

    private function Loop takes nothing returns nothing
        call ForceEnumPlayers(FOR, function Updt)
    endfunction
    
    function CF_Release takes player p returns nothing
        if LoadBoolean(ht, GetPlayerId(p), 0) then
            set P = P - 1
            if 0 == P then
                call PauseTimer(TMR)
            endif
            //call EnableSelect(true, true)
            call ForceRemovePlayer(FOR, p)
            call SaveBoolean(ht, GetPlayerId(p), 0, false)
        endif
    endfunction
    
    function CF_LockPos takes player p, real x, real y returns nothing
        local integer id = GetPlayerId(p)
        set CSA[id] = CSA[id+PLRS]
        if not(LoadBoolean(ht, GetPlayerId(p), 0)) then
            call ForceAddPlayer(FOR, p)
            call SaveBoolean(ht, GetPlayerId(p), 0, true)
            set P = P + 1
            if 1 == P then
                call TimerStart(TMR, TOUT, true, function Loop)
            endif
        endif
        //call EnableSelect(false, false)
    endfunction
    
    function CF_LockCam takes player p, camerasetup c returns nothing
        local integer id = GetPlayerId(p)
        set CSA[id+PLRS] = CSA[id]
        set CSA[id] = c
        if not(LoadBoolean(ht, GetPlayerId(p), 0)) then
            call ForceAddPlayer(FOR, p)
            call SaveBoolean(ht, GetPlayerId(p), 0, true)
            set P = P + 1
            if 1 == P then
                call TimerStart(TMR, TOUT, true, function Loop)
            endif
        endif
        //call EnableSelect(false, false)
    endfunction
    
    private function InitTrig_CF takes nothing returns nothing
        local integer i
        local integer j
        
        set i = 0
        loop
            exitwhen i == PLRS
            set CSA[i] = CreateCameraSetup()
            set CSA[i+PLRS] = CSA[i]
            call CameraSetupSetField(CSA[i], CAMERA_FIELD_ANGLE_OF_ATTACK, 270, 0)
            call CameraSetupSetField(CSA[i], CAMERA_FIELD_FARZ, 2000, 0)
            call CameraSetupSetField(CSA[i], CAMERA_FIELD_FIELD_OF_VIEW, 90, 0)
            call CameraSetupSetField(CSA[i], CAMERA_FIELD_ROLL, 0, 0)
            call CameraSetupSetField(CSA[i], CAMERA_FIELD_ROTATION, 90, 0)
            call CameraSetupSetField(CSA[i], CAMERA_FIELD_TARGET_DISTANCE, 800, 0)
            call CameraSetupSetField(CSA[i], CAMERA_FIELD_ZOFFSET, 0, 0)
            call CameraSetupSetDestPosition(CSA[i], 0, 0, 0)
            set i = i + 1
        endloop
    endfunction
    
endlibrary

It should be easy to use:

  • Lock to point
    • Events
      • Player - Player 1 (Red) types a chat message containing 1 as An exact match
    • Conditions
    • Actions
      • Custom script: call CF_SaveCam(GetTriggerPlayer())
      • Custom script: call CF_LockPos(GetTriggerPlayer(), GetRandomReal(-2000, 2000), GetRandomReal(-2000, 2000))
  • Lock to camera
    • Events
      • Player - Player 1 (Red) types a chat message containing 2 as An exact match
    • Conditions
    • Actions
      • Custom script: call CF_SaveCam(GetTriggerPlayer())
      • Custom script: call CF_LockCam(GetTriggerPlayer(), gg_cam_1)
  • Free
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Custom script: call CF_Release(GetTriggerPlayer())
      • Custom script: call CF_LoadCam(GetTriggerPlayer())
 

Attachments

  • CamLock.w3x
    20.2 KB · Views: 61
Level 37
Joined
Mar 6, 2006
Messages
9,243
Yeah, it is vjass. Basically you want to do it like this:
  • Untitled Trigger 005
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Camera - Apply Camera 001 <gen> for Player 1 (Red) over 0.00 seconds
      • Camera - Apply Camera 001 Copy <gen> for Player 1 (Red) over 10.00 seconds
They are the same cameras basically, but the copy has target x that is 0.05 greater than the other one.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
@apo
Remember, it's not that easy to remove Locust from a unit.
What you did there was acceptable BUT, it doesn't remove the Locust completely from that unit, why ?

1. You can no longer click-select the unit, you must drag-select it
2. You can no longer target that unit with any Target-unit type spells

The only way to remove it completely ?
Yes, Passive Transformation would do (Bear Form).
 
Status
Not open for further replies.
Top