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

[JASS] Help please

Status
Not open for further replies.
Level 16
Joined
Oct 12, 2008
Messages
1,570
Heey people,,

i am trying to convert a cam system to Jass, im using JNGP and it gives no errors, but i just cant get it to work! I am probable forgetting something or just doing something wrong, oh, and i put it in a library to make it put at top of the script,, not specificaly for structs or anything else that is vJass-specific,,
Here is the code:
Oh, and any improvements are welcome!
JASS:
library Cam initializer Init
    globals
        private boolean Up
        private boolean Down
        private boolean Left
        private boolean Right
        private real Rotation = 90
        private real Distance = 750
        private unit Unit
        private boolean Facing
        private constant real MaxDist = 1500
        private constant real MinDist = 500
        private constant real DD = 10
        private constant real DR = 5
        private constant real Smooth = 0.035
        private trigger PT = CreateTrigger()
    endglobals
    private function UpUp takes nothing returns nothing
        set Up = false
        call BJDebugMsg("TestArrow")
    endfunction
    private function UpDown takes nothing returns nothing
        set Up = true
        call BJDebugMsg("TestArrow")
    endfunction
    private function DownUp takes nothing returns nothing
        set Down = false
        call BJDebugMsg("TestArrow")
    endfunction
    private function DownDown takes nothing returns nothing
        set Down = true
        call BJDebugMsg("TestArrow")
    endfunction
    private function LeftUp takes nothing returns nothing
        set Left = false
        call BJDebugMsg("TestArrow")
    endfunction
    private function LeftDown takes nothing returns nothing
        set Left = true
        call BJDebugMsg("TestArrow")
    endfunction
    private function RightUp takes nothing returns nothing
        set Right = false
        call BJDebugMsg("TestArrow")
    endfunction
    private function RightDown takes nothing returns nothing
        set Right = true
        call BJDebugMsg("TestArrow")
    endfunction
    function fPeriodicCam takes nothing returns nothing
        local real x1
        local real y1
        local real x2
        local real y2
        local real z1
        local real z2
        local real f1
        local real f2
        local location l
        call BJDebugMsg("Test")
        if Up == true and Distance < MaxDist then
            set Distance = Distance - DD
        endif
        if Down == true and Distance > MinDist then
           set Distance = Distance + DD
        endif
        if Left == true then
            set Rotation = Rotation - DR
        endif
        if Right == true then
            set Rotation = Rotation + DR
        endif
        if Rotation > 360 then
            set Rotation = Rotation - 360
        elseif Rotation < 0 then
            set Rotation = Rotation + 360
        endif
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, Distance, Smooth )
        call SetCameraField(CAMERA_FIELD_ROTATION, Rotation, Smooth)
        if Facing == true then
            set f1 = GetUnitFacing(Unit)
            set f2 = Rotation + f1
            if f2 >= 360 then
                set f2 = f2 - 360
            elseif f2 <= 0 then
                set f2 = f2 + 360
            endif
            call SetCameraField(CAMERA_FIELD_ROTATION, f2, Smooth)
        endif
        set x1 = GetUnitX(Unit)
        set y1 = GetUnitY(Unit)
        set x2 = GetCameraEyePositionX()
        set y2 = GetCameraEyePositionY()
        set z1 = GetCameraEyePositionZ()
        set l = Location(x2,y2)
        set z2 = GetLocationZ(l)
        if z2 >= z1 + 10.00 then
            call SetCameraField(CAMERA_FIELD_ZOFFSET, z2 + 10.00, Smooth)
        endif
        call RemoveLocation(l)
        set l = null
    endfunction
    private function RPGEnable takes nothing returns nothing
        call ForceCinematicSubtitles( true )
        call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, 1000000000.00, 0.00 )
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 1000.00, 0.00 )
        call ResetToGameCamera(1.00)
        call SetCameraTargetController(Unit, 0, 0, false )
        call EnableTrigger(PT)
        set udg_Cam_On = true
    endfunction
    private function RPGDisable takes nothing returns nothing
        call ForceCinematicSubtitles( true )
        call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW, 1000000000.00, 0.00 )
        call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 1000.00, 0.00 )
        call ResetToGameCamera(1.00)
        call SetCameraTargetController(Unit, 0, 0, false )
        call DisableTrigger(PT)
        set udg_Cam_On = false
    endfunction
    private function StringCamera takes nothing returns nothing
        if udg_Cam_On == true then
            call RPGDisable()
        elseif udg_Cam_On == false then
            call RPGEnable()
        endif
    endfunction
    private function FACINGFOLLOW takes nothing returns nothing
        if udg_Cam_On == false then
            call DisplayTextToPlayer(GetTriggerPlayer(),0,0, "You must enable the RPG Camera before you can follow the Trainer's facing")
        elseif udg_Cam_On == true then
            if Facing == true then
                set Facing = false
            elseif Facing == false then
                set Facing = true
            else
                return
            endif
        else
            return
        endif
    endfunction
    private function Init takes nothing returns nothing
        local trigger array t 
        local integer i = 1
        loop
        exitwhen i > 8
            set t[i] = CreateTrigger()
            call TriggerRegisterPlayerEvent(t[i], Player(0), ConvertPlayerEvent(i+264))
        endloop
        call RPGDisable()
        set Unit = udg_TrainerUnit
        call SetCameraTargetController(Unit, 0, 0, false )
        call TriggerRegisterTimerEvent(PT, 0.03, true)
        call TriggerAddAction(PT, function fPeriodicCam)
        call TriggerRegisterPlayerChatEvent(t[9], Player(0), "-Camera", true)
        call TriggerRegisterPlayerChatEvent(t[10], Player(0), "-Facing", true)
        call TriggerAddAction(t[9], function StringCamera)
        call TriggerAddAction(t[10], function FACINGFOLLOW)
        call TriggerAddAction(t[1], function DownDown)
        call TriggerAddAction(t[2], function DownUp)
        call TriggerAddAction(t[3], function LeftDown)
        call TriggerAddAction(t[4], function LeftUp)
        call TriggerAddAction(t[5], function RightDown)
        call TriggerAddAction(t[6], function RightUp)
        call TriggerAddAction(t[7], function DownDown)
        call TriggerAddAction(t[8], function DownUp)
        set i = 1
        loop
            exitwhen i > 8
            set t[i] = null
            set i = i + 1
        endloop
    endfunction
endlibrary


Thanks! -Yixx,,-

P.S. this doesnt have to be MPI, since it is for a Singleplayer map,,
 
Level 16
Joined
Oct 12, 2008
Messages
1,570
Ya, that could be done, but i need to practice Jass and vJass as much as possible, so i took the GUI cam system i used, and tried to turn it into Jass (vJass, but that reason is above),, but do you know why it isnt working?
 
Status
Not open for further replies.
Top