lbebusiness
New Member
- Reaction score
- 3
To get flying unit height AND terrain height
Okay for those of you asking about having the camera that can go up and down hills cliffs etc with the unit AND adjust with a units height and/or flying height change this part of code of AceHeart's system :
with this:
For those of you who want what I just posted and the settings for a "above but behind the unit" look just replace the enitre system with this:
Btw here is an attachment of a map that I am making in which I used aceheart's system (with many other systems)
His system has been changed and made modular and made so camera changes everytime you select a new unit. Also for some reason if you select more than one unit it seems to default pan to the highest ranking unit...
just copy the trigger folder called "Camera System [Modular]" to your map
*thanks aceheart for map header info. moved code and reposted map. much simpler for others to copy and past too!
Okay for those of you asking about having the camera that can go up and down hills cliffs etc with the unit AND adjust with a units height and/or flying height change this part of code of AceHeart's system :
JASS:
call SetCameraField(CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET) + GetLocationZ(l) + CameraHeight - GetCameraEyePositionZ(), Period)
with this:
JASS:
call SetCameraField(CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET) + GetLocationZ(l) + CameraHeight + (GetUnitFlyHeight(u) ) - GetCameraEyePositionZ(), Period)
For those of you who want what I just posted and the settings for a "above but behind the unit" look just replace the enitre system with this:
JASS:
library TPC initializer Init
globals
// How often the camera is adjusted. Every 0.15 seconds is plenty fast enough
private constant real Period = 0.15
// General camera options
private constant real CameraHeight = 290
private constant real CameraAngle = 347
private constant real CameraDistance = 600
// Arrow keys can be used to rotate and zoom
private constant boolean AllowArrowKeys = true
// Escape resets the camera to "general camera options"
private constant boolean AllowEscape = true
// Wan't to be able to turn it on or off?
private constant string Command = "-camera"
private constant boolean AllowCommand = true
// Optionally stops the camera if the current camera unit dies
private constant boolean RemoveOnDeath = true
// Rotation is either free...
private constant boolean AllowFreeRotation = false
// ... or limited to +/- this:
private constant real CameraMaxRotate = 120
// You can change this... but should just leave them
private constant real CameraMaxDistance = 1200
private constant real CameraMinDistance = 150
// DON'T touch anything here
private group CameraUnits = CreateGroup()
private group CameraUnits_start = CreateGroup()
private real array Rotate
private real array Distance
private real array Angle
private boolean array DoLeft
private boolean array DoRight
private boolean array DoDown
private boolean array DoUp
endglobals
private function CameraRemovePlayer_function takes nothing returns nothing
if GetOwningPlayer(GetEnumUnit()) == bj_forceRandomCurrentPick then
call GroupRemoveUnit(CameraUnits_start, GetEnumUnit())
call GroupRemoveUnit(CameraUnits, GetEnumUnit())
endif
endfunction
function TPCRemovePlayer takes player p returns nothing
set bj_forceRandomCurrentPick = p
call ForGroup(CameraUnits, function CameraRemovePlayer_function)
call ForGroup(CameraUnits_start, function CameraRemovePlayer_function)
if GetLocalPlayer() == p then
call ResetToGameCamera(1.5)
endif
endfunction
function TPCAdd takes unit u returns nothing
local player p = GetOwningPlayer(u)
local integer i = GetPlayerId(p)
call TPCRemovePlayer(p)
set Rotate<i> = 0
set Angle<i> = CameraAngle
set Distance<i> = CameraDistance
call GroupAddUnit(CameraUnits_start, u)
call GroupAddUnit(CameraUnits, u)
set p = null
endfunction
function TPCRemove takes unit u returns nothing
call GroupRemoveUnit(CameraUnits_start, u)
call GroupRemoveUnit(CameraUnits, u)
if GetLocalPlayer() == GetOwningPlayer(u) then
call ResetToGameCamera(1.5)
endif
endfunction
function TPCRemoveAll takes nothing returns nothing
call GroupClear(CameraUnits)
call GroupClear(CameraUnits_start)
endfunction
private function Death takes nothing returns nothing
if IsUnitInGroup(GetTriggerUnit(), CameraUnits_start) or IsUnitInGroup(GetTriggerUnit(), CameraUnits) then
call TPCRemove(GetTriggerUnit())
endif
endfunction
private function Movement takes nothing returns nothing
local unit u = GetEnumUnit()
local location l = GetUnitLoc(u)
if GetLocalPlayer() == GetOwningPlayer(u) then
call PanCameraToTimed(GetUnitX(u), GetUnitY(u), Period)
call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(u) + Rotate[GetPlayerId(GetOwningPlayer(u))], Period)
call SetCameraField(CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET) + GetLocationZ(l) + CameraHeight + (GetUnitFlyHeight(u) ) - GetCameraEyePositionZ(), Period)
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, Angle[GetPlayerId(GetOwningPlayer(u))], Period)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, Distance[GetPlayerId(GetOwningPlayer(u))], Period)
endif
call RemoveLocation(l)
set u = null
set l = null
endfunction
private function Actions takes nothing returns nothing
call ForGroup(CameraUnits, function Movement)
endfunction
private function usesCamera takes nothing returns nothing
if GetOwningPlayer(GetEnumUnit()) == GetTriggerPlayer() then
set bj_isUnitGroupDeadResult = false
endif
endfunction
private function CameraOn takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
if GetOwningPlayer(GetEnumUnit()) == GetTriggerPlayer() then
set Rotate<i> = 0
set Angle<i> = CameraAngle
set Distance<i> = CameraDistance
call GroupAddUnit(CameraUnits, GetEnumUnit())
endif
endfunction
private function CameraOff takes nothing returns nothing
if GetOwningPlayer(GetEnumUnit()) == GetTriggerPlayer() then
call GroupRemoveUnit(CameraUnits, GetEnumUnit())
endif
endfunction
private function ChatActions takes nothing returns nothing
set bj_isUnitGroupDeadResult = true
call ForGroup(CameraUnits, function usesCamera)
if bj_isUnitGroupDeadResult then
call ForGroup(CameraUnits_start, function CameraOn)
else
call ForGroup(CameraUnits, function CameraOff)
if GetLocalPlayer() == GetTriggerPlayer() then
call ResetToGameCamera(1.5)
endif
endif
endfunction
private function KeyLeft takes nothing returns nothing
set DoLeft[GetPlayerId(GetTriggerPlayer())] = not DoLeft[GetPlayerId(GetTriggerPlayer())]
endfunction
private function KeyRight takes nothing returns nothing
set DoRight[GetPlayerId(GetTriggerPlayer())] = not DoRight[GetPlayerId(GetTriggerPlayer())]
endfunction
private function KeyDown takes nothing returns nothing
set DoDown[GetPlayerId(GetTriggerPlayer())] = not DoDown[GetPlayerId(GetTriggerPlayer())]
endfunction
private function KeyUp takes nothing returns nothing
set DoUp[GetPlayerId(GetTriggerPlayer())] = not DoUp[GetPlayerId(GetTriggerPlayer())]
endfunction
private function DoKeys takes nothing returns nothing
local integer i = 0
loop
if DoLeft<i> then
if AllowFreeRotation or Rotate<i> < CameraMaxRotate then
set Rotate<i> = Rotate<i> + 8
if Rotate<i> > 360 then
set Rotate<i> = Rotate<i> - 360
endif
endif
endif
if DoRight<i> then
if AllowFreeRotation or Rotate<i> > -CameraMaxRotate then
set Rotate<i> = Rotate<i> - 8
if Rotate<i> < -360 then
set Rotate<i> = Rotate<i> + 360
endif
endif
endif
if DoDown<i> then
if Distance<i> < CameraMaxDistance then
set Distance<i> = Distance<i> + 25
set Angle<i> = Angle<i> + 0.35
endif
endif
if DoUp<i> then
if Distance<i> > CameraMinDistance then
set Distance<i> = Distance<i> - 25
set Angle<i> = Angle<i> - 0.35
endif
endif
set i = i + 1
exitwhen i >= 12
endloop
endfunction
private function Escape takes nothing returns nothing
local integer i = GetPlayerId(GetTriggerPlayer())
set Rotate<i> = 0
set Angle<i> = CameraAngle
set Distance<i> = CameraDistance
endfunction
private function Init takes nothing returns nothing
local integer i
local trigger t = CreateTrigger()
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
local trigger t3 = CreateTrigger()
local trigger t4 = CreateTrigger()
local timer m
local player p
call TriggerRegisterTimerEventPeriodic(t, Period)
call TriggerAddAction(t, function Actions)
if AllowCommand then
set t = CreateTrigger()
call TriggerAddAction(t, function ChatActions)
set i = 0
loop
call TriggerRegisterPlayerChatEvent(t, Player(i), Command, true)
set i = i + 1
exitwhen i >= 12
endloop
endif
if RemoveOnDeath then
set t = CreateTrigger()
call TriggerAddAction(t, function Death)
set i = 0
loop
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_DEATH, null)
set i = i + 1
exitwhen i >= 12
endloop
endif
call TriggerAddAction(t1, function KeyLeft)
call TriggerAddAction(t2, function KeyRight)
call TriggerAddAction(t3, function KeyDown)
call TriggerAddAction(t4, function KeyUp)
set i = 0
loop
set Rotate<i> = 0
set Distance<i> = CameraDistance
set Angle<i> = CameraAngle
set DoLeft<i> = false
set DoRight<i> = false
set DoDown<i> = false
set DoUp<i> = false
set p = Player(i)
if AllowArrowKeys then
call TriggerRegisterPlayerEvent(t1, p, EVENT_PLAYER_ARROW_LEFT_DOWN)
call TriggerRegisterPlayerEvent(t1, p, EVENT_PLAYER_ARROW_LEFT_UP)
call TriggerRegisterPlayerEvent(t2, p, EVENT_PLAYER_ARROW_RIGHT_DOWN)
call TriggerRegisterPlayerEvent(t2, p, EVENT_PLAYER_ARROW_RIGHT_UP)
call TriggerRegisterPlayerEvent(t3, p, EVENT_PLAYER_ARROW_DOWN_DOWN)
call TriggerRegisterPlayerEvent(t3, p, EVENT_PLAYER_ARROW_DOWN_UP)
call TriggerRegisterPlayerEvent(t4, p, EVENT_PLAYER_ARROW_UP_DOWN)
call TriggerRegisterPlayerEvent(t4, p, EVENT_PLAYER_ARROW_UP_UP)
endif
set i = i + 1
exitwhen i >= 12
endloop
set m = CreateTimer()
call TimerStart(m, 0.05, true, function DoKeys)
set m = null
if AllowEscape then
set t = CreateTrigger()
call TriggerAddAction(t, function Escape)
set i = 0
loop
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_END_CINEMATIC)
set i = i + 1
exitwhen i >= 12
endloop
endif
set t = null
set t1 = null
set t2 = null
set t3 = null
set t4 = null
set p = null
endfunction</i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i></i>
Btw here is an attachment of a map that I am making in which I used aceheart's system (with many other systems)
His system has been changed and made modular and made so camera changes everytime you select a new unit. Also for some reason if you select more than one unit it seems to default pan to the highest ranking unit...
just copy the trigger folder called "Camera System [Modular]" to your map
*thanks aceheart for map header info. moved code and reposted map. much simpler for others to copy and past too!