Fixed Camera (Holding Camera Str8)

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
This is an alternative way for anchoring the camera for a player by applying a given camerasetup. This method is "tappingproof", i.e if you tap the Mouse Wheel, Insert, Delete, Page Up and/or Page Down keys you will notice a minor flickering with the other method: Applying a given camerasetup very fast(0.03125, 0.02 etc.), which is "annoying" : P.

The script:
JASS:
library fixedcam initializer init

globals
    private timer array camera_locker
    private hashtable tripod_data
    private constant integer NAIL_ID = 'hpea' // or dummy
endglobals

private struct tripod
    camerasetup camera
    player actor
    unit nail
endstruct

function fixed_cam_start_act takes nothing returns nothing
    local tripod trp = LoadInteger(tripod_data, 0, GetHandleId(GetExpiredTimer()))
    
    if trp.actor == GetLocalPlayer() then
        call CameraSetupApplyForceDuration(trp.camera, true, 1.0)
        call SetCameraTargetController(trp.nail, 0.0, 0.0, false)
    endif
endfunction

function fixed_cam_start takes camerasetup camera, player p, real camera_targetx, real camera_targety returns nothing
    local unit nail
    local tripod trp
    local integer pid

    set nail = CreateUnit(p, NAIL_ID, camera_targetx, camera_targety, 270.0)
    call ShowUnit(nail, false)
    call SetUnitPathing(nail, false)
    call UnitAddAbility(nail, 'Avul')
    
    if p == GetLocalPlayer() then
        call CameraSetupApplyForceDuration(camera, false, 0.0)
        call SetCameraTargetController(nail, 0.0, 0.0, false)

        call SelectUnit(nail, true)
        call IssuePointOrder(nail, "move", GetUnitX(nail), GetUnitY(nail) - 16)
        call SetUnitY(nail, GetUnitY(nail) + 16)
    endif

    set trp = tripod.create()
    set trp.camera = camera
    set trp.actor = p
    set trp.nail = nail
    set pid = GetPlayerId(p)

    call SaveInteger(tripod_data, 0, GetHandleId(camera_locker[pid]), trp)
    call TimerStart(camera_locker[pid], 1.0, true, function fixed_cam_start_act)

    call SaveInteger(tripod_data, 0, pid, trp) 
endfunction

function fixed_cam_stop takes player p returns nothing
    local tripod trp = LoadInteger(tripod_data, 0, GetPlayerId(p))
    call PauseTimer(camera_locker[GetPlayerId(trp.actor)])
    call RemoveUnit(trp.nail)
    call trp.destroy()
endfunction

function init takes nothing returns nothing
    local integer i
    
    set i = 0
    loop
        exitwhen i >= bj_MAX_PLAYERS
        set camera_locker<i> = CreateTimer()
        set i = i + 1
    endloop
    
    set tripod_data = InitHashtable()
endfunction

endlibrary
</i>



The provided functions are:

[lJASS]function fixed_cam_start takes camerasetup camera, player p, real camera_targetx, real camera_targety returns nothing[/lJASS]

and

[lJASS]function fixed_cam_stop takes player p returns nothing[/lJASS]

If the above made no sense then just check the map.
 

Attachments

  • fixed camera.w3x
    20.1 KB · Views: 291

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
Oops sry then.

Where should you post a demo/example map?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Learn from those maps in demo map section.
I meant your format of posting, not place of posting.
 

tooltiperror

Super Moderator
Reaction score
231
I vote for Graveyard.

It's undeniably simple, runs a function every one second, and even if you don't mind those, Acehart's Camera System is more customizable and serves the same purposes.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top