So i modded a camera System that i found here ->>Klick<<-
with some more functions... [UPDATED]
4. Some things that i need, i hope someone will make:
Here is the Code to Set the Unit:
And here the Movement System:
So Sry for my bad english.. and i hope someone will like it ^^[/tab][/tab]
with some more functions... [UPDATED]
- First u usually move with a,w,s,d..
- You can Look at you and turn the Camerea then you hold the left Mousebutton...
- Then you Hold the left & right mouse button You can walk like WoW ,turn with your mouse and so on...
- with the mouswheel you can change the distance to your char..
- with mouswheel + ctrl you can change the distance of what you can see
- with spacebar you can now JUMP ...
- with tab you select the nearest enemy...
- with "t" you attack the selected not allied unit...
- with "F1" you select your HERO...
4. Some things that i need, i hope someone will make:
- A Jump System [Added, but it's shit you can jump through walls -.- it dissables pathing and it also had no animations^^]
- A Select the nearest Mob System (like wow with [TAB]) [ADDED]
[*]A Wall Detect System or Something like this, cause i can go through walls, etc [Pathability Check ADDED]
[*]A physic engine would be nice [Needed]
[*]A swimming system [Needed]
[*]A Castbar [Needed]
[*]A system where you always have Selected your hero, but all abilitys and attacks not AoE's are casted on the Selected enemy (mybe you can also see the hp of this mob through a multiboard) [Needed]
[/TAB]
[TAB]v1.1
Removed the Bug with the running animation loop then you walk with the mousebuttons.
Added Nearest Enemy Selector [TAB]
Added A Jump System wich disables Pathing
Added a Pathability check
Added A attack order then you press "t"
Changed the look at you function so now you must press ctrl+ leftmousebutton
v1.2
Added A Max AoA and Rot so now you cant lock through the bottom
Changed the Range for the select nearest enemy from 750 to 1000
v1.3
Removed A bug with the walk animation for other units
Improved the Camera System so you can look now and spell skills
(thanks mindworx for your advancedcamera example =))[/TAB]
Here is the Code to Set the Unit:
JASS:
function Trig_init_cam_Actions takes nothing returns nothing
call SetCamUnit( gg_unit_Hjai_0012 ) // Set the Unit
endfunction
//===========================================================================
function InitTrig_init_cam takes nothing returns nothing
set gg_trg_init_cam = CreateTrigger( )
call TriggerAddAction( gg_trg_init_cam, function Trig_init_cam_Actions )
endfunction
And here the Movement System:
JASS:
function Jump_Exec takes nothing returns nothing
local unit u = bj_groupRandomCurrentPick
local real h = bj_enumDestructableRadius
local real r = bj_lastTransmissionDuration
call SetUnitPathing( u, false )
call UnitAddAbility(u,'Amrf' )
call UnitRemoveAbility(u,'Amrf')
call SetUnitFlyHeight( u, h, r )
call TriggerSleepAction(.1)
call SetUnitFlyHeight( u, 0, r )
call TriggerSleepAction(.01)
call SetUnitPathing( u, true )
call ForceKeyUp(32)
endfunction
library thirdpersoncam initializer init
globals
private unit CurrentPick
private real CenterX
private real CenterY
private real CurrentDistance
private group AnyGroup = CreateGroup()
private real cam_zoffset = 150.00
private real cam_aoa = 327.65
private real cam_dist = 500.00
private real cam_farz = 3000.00
private real cam_angle = 0.0
private unit cam_unit
//---
private constant trigger trig_OnMouseLeftDown = CreateTrigger()
private constant trigger trig_OnMouseLeftUp = CreateTrigger()
private constant trigger trig_OnMouseRightDown = CreateTrigger()
private constant trigger trig_OnMouseRightUp = CreateTrigger()
private boolean bool_MouseLeftState = false
private boolean bool_MouseRightState = false
private constant trigger trig_OnMouseWheel = CreateTrigger()
private constant trigger trig_AoAControl = CreateTrigger()
private constant trigger trig_OnKeyDown = CreateTrigger()
private constant trigger trig_OnKeyUp = CreateTrigger()
private boolean array bool_KeyState
private boolean bool_AoAChanging = false
private integer int_AoAOffsetY = GetMouseY()
private integer int_AoAOffsetX = GetMouseX()
endglobals
private function Enum takes nothing returns nothing
local unit u = GetEnumUnit()
local real dx = GetUnitX(u) - CenterX
local real dy = GetUnitY(u) - CenterY
local real d = (dx*dx + dy*dy) / 10000.
if ( IsUnitAlly(GetEnumUnit(), GetOwningPlayer(cam_unit)) == false ) then
if d < CurrentDistance then
set CurrentDistance = d
set CurrentPick = u
endif
endif
set u = null
endfunction
function GetClosestUnitInRange takes real x, real y, real radius returns unit
set CurrentPick = null
set CenterX = x
set CenterY = y
set CurrentDistance = 100000
call GroupEnumUnitsInRange(AnyGroup, x, y, radius, null)
call ForGroup(AnyGroup, function Enum)
return CurrentPick
endfunction
function Jump takes unit u, real height, real rate returns nothing
set bj_enumDestructableRadius = height
set bj_lastTransmissionDuration = rate
set bj_groupRandomCurrentPick = u
call ExecuteFunc( "Jump_Exec" )
endfunction
private function GetPointZ takes real x, real y returns real
local location l = Location(x,y)
local real h = GetLocationZ(l)
call RemoveLocation(l)
set l = null
return h
endfunction
private function OnMouseLeftDown takes nothing returns nothing
set bool_MouseLeftState = true
endfunction
private function OnMouseLeftUp takes nothing returns nothing
set bool_MouseLeftState = false
if not bool_MouseLeftState then
call SetUnitAnimation(cam_unit, "stand")
call SetUnitTimeScale(cam_unit, 1.0)
endif
endfunction
private function OnMouseRightDown takes nothing returns nothing
set bool_MouseRightState = true
endfunction
private function OnMouseRightUp takes nothing returns nothing
set bool_MouseRightState = false
if not bool_MouseRightState then
call SetUnitAnimation(cam_unit, "stand")
call SetUnitTimeScale(cam_unit, 1.0)
endif
endfunction
private function OnKeyDown takes nothing returns nothing
set bool_KeyState[GetTriggerKey()] = true
endfunction
private function OnKeyUp takes nothing returns nothing
set bool_KeyState[GetTriggerKey()] = false
if not bool_KeyState[65] and not bool_KeyState[68] and not bool_KeyState[87] and not bool_KeyState[83] or bool_KeyState[32] then
call SetUnitAnimation(cam_unit, "stand")
call SetUnitTimeScale(cam_unit, 1.0)
endif
endfunction
function GetMouseLeftState takes nothing returns boolean
return bool_MouseLeftState
endfunction
function GetMouseRightState takes nothing returns boolean
return bool_MouseRightState
endfunction
function GetKeyState takes integer key returns boolean
return bool_KeyState[key]
endfunction
//=== Zooming
private function OnMouseWheel takes nothing returns nothing
local integer WheelDelta = GetTriggerWheelDelta()
if GetKeyState(17) then
set cam_farz = cam_farz - WheelDelta
if cam_farz > 4500 then
set cam_farz = 4500
endif
else
set cam_dist = cam_dist - WheelDelta
if cam_dist > 1150 then
set cam_dist = 1150
endif
endif
endfunction
private function CameraControl takes nothing returns nothing
local real offset = 0
local real move_x = 0
local real move_y = 0
local real r
local real m = 1.5
set bool_AoAChanging = true
if GetMouseRightState() and GetMouseLeftState() then
call SetUnitFacing(cam_unit, cam_angle)
call SetUnitAnimation(cam_unit, "walk")
call SetUnitTimeScale(cam_unit, 1.0)
set m = 1.5
set move_x = move_x + CosBJ(cam_angle)
set move_y = move_y + SinBJ(cam_angle)
endif
if GetKeyState(9) then
call GetClosestUnitInRange(GetUnitX(cam_unit), GetUnitY(cam_unit), 1000)
call SelectUnitForPlayerSingle(CurrentPick, GetOwningPlayer(cam_unit))
endif
if GetKeyState(32) then
call Jump(cam_unit, 70, 450)
endif
if GetKeyState(84) then
call IssueTargetOrder(cam_unit, "attack", GroupPickRandomUnit(GetUnitsSelectedAll(GetOwningPlayer(cam_unit))))
call DestroyGroup(GetLastCreatedGroup())
endif
if GetKeyState(65) then
call SetUnitFacing(cam_unit, cam_angle)
call SetUnitAnimation(cam_unit, "walk")
call SetUnitTimeScale(cam_unit, 1.0)
set move_x = move_x + CosBJ(cam_angle+45)
set move_y = move_y + SinBJ(cam_angle+45)
set m = 1.0
endif
if GetKeyState(68) then
call SetUnitFacing(cam_unit, cam_angle)
call SetUnitAnimation(cam_unit, "walk")
call SetUnitTimeScale(cam_unit, 1.0)
set move_x = move_x - 0.5*CosBJ(cam_angle+45)
set move_y = move_y - 0.5*SinBJ(cam_angle+45)
set m = 1.0
endif
if GetKeyState(87) then
call SetUnitFacing(cam_unit, cam_angle)
call SetUnitAnimation(cam_unit, "walk")
call SetUnitTimeScale(cam_unit, 1.0)
set m = 1.5
set move_x = move_x + CosBJ(cam_angle)
set move_y = move_y + SinBJ(cam_angle)
endif
if GetKeyState(83) then
call SetUnitFacing(cam_unit, cam_angle)
call SetUnitAnimation(cam_unit, "walk")
call SetUnitTimeScale(cam_unit, -0.5)
set move_x = move_x - CosBJ(cam_angle)
set move_y = move_y - SinBJ(cam_angle)
set m = 0.8
endif
set r = SquareRoot(move_x*move_x + move_y*move_y)
if r > 0 then
set move_x = move_x / r
set move_y = move_y / r
endif
if (not GetMouseRightState() and not GetMouseLeftState()) or (not GetMouseLeftState() and not GetKeyState(17)) then
set bool_AoAChanging = false
set int_AoAOffsetY = GetMouseY()
set int_AoAOffsetX = GetMouseX()
set cam_aoa = cam_aoa
set cam_angle = cam_angle
endif
if IsTerrainPathable((GetUnitX(cam_unit) + move_x * 0.01 * GetUnitMoveSpeed(cam_unit) * m), (GetUnitY(cam_unit) + move_y * 0.01 * GetUnitMoveSpeed(cam_unit) * m), PATHING_TYPE_WALKABILITY) and not GetKeyState(32) then
call SetUnitX(cam_unit, GetUnitX(cam_unit))
call SetUnitY(cam_unit, GetUnitY(cam_unit))
else
call SetUnitX(cam_unit, GetUnitX(cam_unit) + move_x * 0.01 * GetUnitMoveSpeed(cam_unit) * m)
call SetUnitY(cam_unit, GetUnitY(cam_unit) + move_y * 0.01 * GetUnitMoveSpeed(cam_unit) * m)
endif
if(bool_AoAChanging) then
set offset = (int_AoAOffsetY - GetMouseY())
set cam_aoa = cam_aoa + offset
set int_AoAOffsetY = GetMouseY()
endif
if(cam_aoa > 350) then
set cam_aoa = 350
endif
if(cam_aoa < 240) then
set cam_aoa= 240
endif
if(bool_AoAChanging) then
set offset = (int_AoAOffsetX - GetMouseX())
set cam_angle = cam_angle + offset
set int_AoAOffsetX = GetMouseX()
endif
if(cam_angle > 360) then
set cam_angle = cam_angle - 360
endif
if(cam_angle < 0) then
set cam_angle = cam_angle + 360
endif
call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, cam_aoa, 0.00)
call SetCameraField(CAMERA_FIELD_ROTATION, cam_angle, 0.00)
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, cam_dist, 0.3)
call SetCameraField(CAMERA_FIELD_FARZ, cam_farz, 0.3)
call SetCameraField( CAMERA_FIELD_ZOFFSET, GetCameraField( CAMERA_FIELD_ZOFFSET ) + ( GetPointZ(GetUnitX(cam_unit),GetUnitY(cam_unit)) + 150 - GetCameraTargetPositionZ() ), 0.01 )
endfunction
function SetCamUnit takes unit u returns nothing
call SetCameraTargetController(u, 0, 0, false)
call SetCameraField(CAMERA_FIELD_ROTATION, GetUnitFacing(u), 1.0)
set cam_unit = u
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t, 0.01, true)
call TriggerAddAction(t, function CameraControl)
call TriggerRegisterMouseEvent(trig_OnMouseLeftDown, EVENT_LMOUSEDOWN)
call TriggerAddAction(trig_OnMouseLeftDown, function OnMouseLeftDown)
call TriggerRegisterMouseEvent(trig_OnMouseLeftUp, EVENT_LMOUSEUP)
call TriggerAddAction(trig_OnMouseLeftUp, function OnMouseLeftUp)
call TriggerRegisterMouseEvent(trig_OnMouseRightDown, EVENT_RMOUSEDOWN)
call TriggerAddAction(trig_OnMouseRightDown, function OnMouseRightDown)
call TriggerRegisterMouseEvent(trig_OnMouseRightUp, EVENT_RMOUSEUP)
call TriggerAddAction(trig_OnMouseRightUp, function OnMouseRightUp)
call TriggerRegisterMouseEvent(trig_OnMouseWheel, EVENT_MOUSEWHEEL)
call TriggerAddAction(trig_OnMouseWheel, function OnMouseWheel)
call TriggerRegisterKeyEvent(trig_OnKeyDown, 1)
call TriggerAddAction(trig_OnKeyDown, function OnKeyDown)
call TriggerRegisterKeyEvent(trig_OnKeyUp, 0)
call TriggerAddAction(trig_OnKeyUp, function OnKeyUp)
endfunction
endlibrary
So Sry for my bad english.. and i hope someone will like it ^^[/tab][/tab]
Attachments
Last edited: