• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Advanced Camera, Keyboard & Movement System

This is my Advanced Camera, Keyboard and Arrow Key Movement System requested by Nara-shikamaru and many other users.

The Camera System
The camera system is basicly a system that adjusts the camera distance, height and angle.
This prevents the camera from going through doodads or blocking your view when you walk away from them or even up a hill...
Well its MPI and easy to handle!
Read the beginning of the code to see the included functions!
The important values are changeable ingame AND NOW FOR EACH PLAYER SEPERATELY!!

But what makes this system advanced?
In contrast to many other camera systems this one isn't interrupted by items or units standing in your way. It adjusts the zAngle, too, but not like 'bamm' and the new angle is there!! It's smooth and lagg free!!!


The Keyboard System
nothing new but VERY useful as i think...
always when you want to create a effective arrow key movement system or a sniper system or anything else using the arrow keys you need to create 8 triggers: 4 for the key press event and 4 for the key release event.
this system just brings you these triggers, merged and optimized.
now you don't need 8 triggers you just need 1.
You have a function to check whether key xy is pressed.
in addition you have the power to register double press events to triggers.
they will fire when key xy is pressed twice within 0.5 seconds (adjustable).


The Arrow Key Movement System
nothing new, too, but useful, lagg free, MPI and it features custom plugins!
It has the basic functions of each arrow key system:
Up = move towards facing
Down = walk backwards
Left = turn left
Right = turn right
BUT my system doesn't collide with walls, it slides along them!
it is fully MPI so each player can control one unit, even if he doesn't own that unit!
And as i haven't seen this in any movement system before:
when a unit walks backwards it's animation is played reversed, too, so it doesn't look crappy :D Even flying units are supported!!

In addition everyone can expand this system by coding own plugins!!
For this test map I created the following ones:
Double Up press = dash foreward
Double Down Press = turn 180° around
Double Left or Right press = move in that direction without changing the facing angle...

check out the how to's in the test map to create your own plugins!


The test map uses all systems by giving you arrow key movement control over a soldier walking around in a small but lovely village.
To test the zAngle feature please walk outside the village where the hills begin :D

I was asked why i placed items there, because your unit can't pickup items...
Well other systems collide with items and count them as a wall!
My doesn't... it ignores them ;D

you need JNGP and some JASS knowledge to get this code working correctly


If you need a GUI tutorial for this system then read this one, made by Kirizaru

Tutorial


give credits when used and +rep if you think it's worth it


have fun



JASS:
library AdvancedCameraSystem initializer Init
    // Advanced Camera System by The_Witcher
    //
    // This is a very advanced advanced camera system which adjusts the camera 
    // distance to the target so the camera isn't looking through houses/trees/...
    // and the cameras angle of attack so the view isn't blocked because of hills...
    //
    // useful for RPGs and that stuff
    //
    // To bind the camera to a unit for a player use
    //   SetCameraUnit(  unit, player )
    //
    // if you want to have your normal camera again use
    //   ReleaseCameraUnit(  player  )
    //
    // in case you want to know which unit is bound to the camera for player xy use
    //   GetCameraUnit(  player  )
    //
    // to change the AngleOfAttack of a player ingame use
    //   SetCamDefaultAngleOfAttack(  Player, NewValue  )
    //
    // to change the maximal camera target distance of a player ingame use
    //   SetCamMaxDistance(  Player, NewValue  )
    //
    // to change the maximal distance behind the target, the z-offset is checked (for z-angle), of a player ingame use
    //   SetCamMaxZCheckDistance(  Player, NewValue  )
    //
    //   SETUP PART
    globals
        // The max. distance the camera can have to the target
        private real DEFAULT_MAX_DISTANCE = 1000
    
        // The max. distance the zOffset behind the unit is checked (for zAngle)
        private real DEFAULT_MAX_Z_CHECK_DISTANCE = 500
    
        // the camera angle of attack correction after the zAngle calculation
        private real DEFAULT_ANGLE_OF_ATTACK = -20
    
        // the timer interval (0.01 is best but can lagg in huge maps with many of these short intervals)
        private constant real INTERVAL = 0.03
    
        // the time the camera will need to adjust
        private constant real DELAY = 0.25
    
        // the standart z of the camera
        private constant real NORMAL_HEIGHT = 100
    
        // the accuracy increases if the value gets smaller
        private constant real ACCURACY = 50
    
        // the secondary accruracy when the camera reaches a barricade (just leave at this amount)
        private constant real EXTREME_ACCURACY = 10
    endglobals
    //  SETUP END

    // don't modify the code below!

    globals 
        private item ite
        private real array Aoa[15]
        private real array Dist[15]
        private real array CheckDist[15]
        private unit array CamUnit[15]
        private timer tim = CreateTimer()
        private location loc = Location(0,0)
        private integer active = 0
        private hashtable h = InitHashtable()
    endglobals

    private function IsCoordPathable takes real x, real y returns boolean
        call SetItemVisible(ite,true)
        call SetItemPosition(ite,x,y)
        set x = GetItemX( ite) - x
        set y = GetItemY( ite) - y
        call SetItemVisible(ite,false)
        if x < 1 and x > -1 and  y < 1 and y > -1 then
            return true
        endif
        return false
    endfunction    

    private function HideAllItems takes nothing returns nothing
        if IsItemVisible(GetEnumItem()) then
            call SaveInteger(h,GetHandleId(GetEnumItem()),0,1)
        endif
        call SetItemVisible(GetEnumItem(),false)
    endfunction

    private function ShowAllItems takes nothing returns nothing
        if LoadInteger(h,GetHandleId(GetEnumItem()),0) == 1 then
            call SetItemVisible(GetEnumItem(),true)
            call FlushChildHashtable(h,GetHandleId(GetEnumItem()))      
        endif
    endfunction

    private function Actions takes nothing returns nothing
        local real x
        local real y
        local real angle
        local real rz
        local real z
        local integer i = 0
        local integer Check
        local real CheckDistance
        local real DistanceDone
        local rect rec
        loop
            exitwhen i >= bj_MAX_PLAYERS
            if CamUnit[i] != null then
                set DistanceDone = 0
                set rz = 0
                set x = GetUnitX(CamUnit[i])
                set y = GetUnitY(CamUnit[i])
                set Check = 1
                set angle = (GetUnitFacing(CamUnit[i]) - 180)*bj_DEGTORAD
                set CheckDistance = ACCURACY
                set z = DEFAULT_ANGLE_OF_ATTACK
                if not IsUnitType(CamUnit[i], UNIT_TYPE_FLYING) then
                    loop
                        set x = x + CheckDistance * Cos(angle)
                        set y = y + CheckDistance * Sin(angle)
                        set DistanceDone = DistanceDone + CheckDistance
                        call MoveLocation(loc,x,y)
                        set z = GetLocationZ(loc)
                        if RAbsBJ(z) > RAbsBJ(rz) and DistanceDone <= CheckDist[i] then
                            set rz = z
                        endif
                        if not IsCoordPathable(x,y)then
                            set rec = Rect(x-ACCURACY,y-ACCURACY,x+ACCURACY,y+ACCURACY)
                            call EnumItemsInRect(rec,null, function HideAllItems)
                            if not IsCoordPathable(x,y)then
                                set Check = 0
                            endif
                            call RemoveRect(rec)
                        endif
                        if Check == 0 and CheckDistance == ACCURACY then
                            set DistanceDone = DistanceDone - CheckDistance
                            set x = x - CheckDistance * Cos(angle)
                            set y = y - CheckDistance * Sin(angle)
                            set Check = 1
                            set CheckDistance = EXTREME_ACCURACY
                        endif
                        exitwhen (Check == 0 and CheckDistance == EXTREME_ACCURACY) or DistanceDone > Dist[i]
                    endloop          
                else
                    set DistanceDone = Dist[i]
                endif
                call MoveLocation(loc,GetUnitX(CamUnit[i]),GetUnitY(CamUnit[i]))
                set x = GetLocationZ(loc)     
                loop
                    exitwhen x - rz < 180
                    set x = x - 180
                endloop               
                set z = Atan2(x-rz,200) * bj_RADTODEG + Aoa[i]
                if IsUnitType(CamUnit[i], UNIT_TYPE_FLYING) then
                    set z = Aoa[i]
                endif
                if GetLocalPlayer() == Player(i) then
                    call CameraSetSmoothingFactor(1)
                    call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, DistanceDone, DELAY)
                    call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK, z, DELAY)
                    call SetCameraField(CAMERA_FIELD_ZOFFSET,GetCameraField(CAMERA_FIELD_ZOFFSET)+x+GetUnitFlyHeight(CamUnit[i])+NORMAL_HEIGHT-GetCameraTargetPositionZ(),DELAY)
                    call SetCameraField(CAMERA_FIELD_ROTATION, angle*bj_RADTODEG+180, DELAY)
                    call SetCameraTargetController(CamUnit[i],0,0,false)
                endif
            endif
            set i = i + 1
        endloop
        call EnumItemsInRect(bj_mapInitialPlayableArea,null, function ShowAllItems)  
        set rec = null
    endfunction

    function ReleaseCameraUnit takes player p returns nothing
        if CamUnit[GetPlayerId(p)] != null then
            set CamUnit[GetPlayerId(p)] = null
            call ResetToGameCameraForPlayer(p,0)
            if GetLocalPlayer() == p then
                call CameraSetSmoothingFactor(0)
            endif
            set active = active - 1
            if active == 0 then
                call PauseTimer(tim)
            endif
        endif
    endfunction

    function SetCameraUnit takes unit u, player owner returns nothing
        if CamUnit[GetPlayerId(owner)] != null then
            call ReleaseCameraUnit(owner)
        endif
        set CamUnit[GetPlayerId(owner)] = u
        set active = active + 1
        if active == 1 then
            call TimerStart(tim,INTERVAL,true,function Actions)
        endif
    endfunction

    function SetCamDefaultAngleOfAttack takes player p, real a returns nothing
        set Aoa[GetPlayerId(p)] = a
    endfunction

    function SetCamMaxDistance takes player p, real d returns nothing
        set Dist[GetPlayerId(p)] = d
    endfunction

    function SetCamMaxZCheckDistance takes player p, real d returns nothing
        set CheckDist[GetPlayerId(p)] = d
    endfunction

    function GetCameraUnit takes player pl returns unit
        return CamUnit[GetPlayerId(pl)]
    endfunction 

    private function Init takes nothing returns nothing
        local integer i = 0                   
        loop
            exitwhen i >= bj_MAX_PLAYERS
            set CamUnit[i] = null
            set Aoa[i] = DEFAULT_ANGLE_OF_ATTACK
            set Dist[i] = DEFAULT_MAX_DISTANCE
            set CheckDist[i] = DEFAULT_MAX_Z_CHECK_DISTANCE
            set i = i + 1
        endloop
        set ite = CreateItem( 'wolg', 0,0 )
        call SetItemVisible(ite,false)
    endfunction

endlibrary

JASS:
library ArrowKeyMovement initializer Init requires KeyboardSystem, ArrowKeyMovementPlugins

    // Arrow key movement by The_Witcher
    //   this system allows each player to control 1 unit 
    //   with his arrow keys even if he doesn't own the unit!
    //   It features turning on the left and right arrow, walking foreward 
    //   by pressing the up arrow and walking backwards by pressing the down arrow...
    //
    // You can improve this system with plugins but you need vJass knowledge for that!
    //
    //  --> The TurnRate of a unit inside the object editor STILL influences the turn rate from this system <--
    //
    // Included functions:
    //
    //      SetMovementUnit ( whichunit, forWhichPlayer, walkAnimationIndex )
    //                          unit         player            integer
    //            this gives the player the arrow key movement control over the unit
    //            while the unit moves the animation of the given index is played
    //            (just try around to find the index... start at 0 and increase 
    //             by 1 until you find the walk index of that unit)
    //
    //
    //      ReleaseMovementUnit ( fromWhichPlayer )
    //                                player
    //            this function removes the control from a player
    //
    //
    //      GetMovementUnit ( fromWhichPlayer )    returns unit
    //                            player
    //            I think its self explaining...
    //
    //
    //      SetMovementUnitAnimation ( fromWhichPlayer, animation )
    //                                    player         integer
    //            this function allows ingame changing of the played animation of a unit


    // ------- SETUP PART ---------
    globals
        // the timer interval... increase if laggy
        private constant real INTERVAL = 0.01
    
        // the facing change in degrees each interval (must be a positive value)
        private constant real DEFAULT_VIEW_CHANGE = 4
    
        // when you move backwards you move slower than normal...
        private constant real BACKWARDS_MOVING_FACTOR = 0.7      
    
        // if the unit turns it will turn faster the longer it does...
        // some people may need that but then it should be 1.02 (1.0 means disabled)
        private constant real TURN_ACCELERATION = 1
    
        // (can only be 1 or -1) if you walk backwards you have 2 ways of turning
        //  1. way: pressing left will make the char turn left
        //  2. way: pressing left will make the char turn so he moves to the left                                                                 
        private constant integer REVERSED_BACKWARDS_MOVING = 1
    endglobals                            

    // whenever this function returns false for a unit it won't be moved even if the player
    //  presses the keys! change to create your own "No Movement" conditions
    private function MoveConditions takes unit u returns boolean
        return not IsUnitType(u,UNIT_TYPE_SLEEPING) and not IsUnitType(u,UNIT_TYPE_STUNNED) and not (IsUnitType(u,UNIT_TYPE_DEAD) or GetUnitTypeId(u) == 0 )
    endfunction

    //   --------- don't modify anything below this line ------------
    struct ArrowKeyMovement
        private static ArrowKeyMovement array all [12]       // = bj_MAX_PLAYERS
        private static timer tim
        
        
        integer walking
        unit u
        integer animation
        real SpeedFactor
        real ViewChange
        real SpecialDirection
        boolean SpecialDirectionActive
        
        static method operator [] takes player p returns ArrowKeyMovement
            local integer i = GetPlayerId(p)
            if .all[i] == 0 then
                set .all[i] = ArrowKeyMovement.create()
                set .all[i].SpeedFactor = 1
                set .all[i].SpecialDirection = 0
                set .all[i].SpecialDirectionActive = false
                set .all[i].ViewChange = DEFAULT_VIEW_CHANGE
            endif
            return .all[i]
        endmethod

        private static method Walking takes nothing returns nothing
            local integer i = 0
            local real x
            local real y
            local real X
            local real Y
            local boolean boolX
            local boolean boolY
            local boolean left
            local boolean right
            local boolean up
            local boolean down
            local ArrowKeyMovement mov
            loop
                exitwhen i >= 12              // = bj_MAX_PLAYERS
                set mov = .all[i]
                if mov.u != null and MoveConditions(mov.u) then
                    // special movement <-- plugins
                    if mov.SpecialDirectionActive then
                        if mov.walking != 1 then
                            call SetUnitTimeScale(mov.u,mov.SpeedFactor)
                            call SetUnitAnimationByIndex(mov.u,mov.animation)
                            set mov.walking = 1
                        else
                            call SetUnitTimeScale(mov.u,mov.SpeedFactor)
                        endif
                        set x = GetUnitX(mov.u)
                        set y = GetUnitY(mov.u)
                        set X = x + GetUnitMoveSpeed(mov.u)*INTERVAL * Cos(mov.SpecialDirection*bj_DEGTORAD) * mov.SpeedFactor
                        set Y = y + GetUnitMoveSpeed(mov.u)*INTERVAL * Sin(mov.SpecialDirection*bj_DEGTORAD) * mov.SpeedFactor
                        call SetUnitPosition(mov.u,X,Y)
                        if (RAbsBJ(GetUnitX(mov.u)-X)>0.5)or(RAbsBJ(GetUnitY(mov.u)-Y)>0.5)then
                            call SetUnitPosition(mov.u,X,y)
                            set boolX = RAbsBJ(GetUnitX(mov.u)-X)<=0.5
                            call SetUnitPosition(mov.u,x,Y)
                            set boolY = RAbsBJ(GetUnitY(mov.u)-Y)<=0.5
                            if boolX then
                                call SetUnitPosition(mov.u,X,y)
                            elseif boolY then
                                call SetUnitPosition(mov.u,x,Y)
                            else
                                call SetUnitPosition(mov.u,x,y)
                            endif
                        endif
                    else
                        // Normal movement
                        set left = IsKeyDown(KEY_LEFT,Player(i))
                        set right = IsKeyDown(KEY_RIGHT,Player(i))
                        set up = IsKeyDown(KEY_UP,Player(i))
                        set down = IsKeyDown(KEY_DOWN,Player(i))
                        //right down
                        if right then
                            if down then
                                call SetUnitFacing(mov.u,GetUnitFacing(mov.u)-mov.ViewChange * -REVERSED_BACKWARDS_MOVING)
                            else
                                call SetUnitFacing(mov.u,GetUnitFacing(mov.u)-mov.ViewChange)
                            endif
                            set mov.ViewChange = mov.ViewChange * TURN_ACCELERATION
                        elseif not left then
                            set mov.ViewChange = DEFAULT_VIEW_CHANGE
                        endif
                        //left down
                        if left then
                            if down then
                                call SetUnitFacing(mov.u,GetUnitFacing(mov.u)+mov.ViewChange * -REVERSED_BACKWARDS_MOVING)
                            else
                                call SetUnitFacing(mov.u,GetUnitFacing(mov.u)+mov.ViewChange)
                            endif
                            set mov.ViewChange = mov.ViewChange * TURN_ACCELERATION
                        elseif not right then
                            set mov.ViewChange = DEFAULT_VIEW_CHANGE
                        endif
                        if mov.ViewChange > 179 then
                            set mov.ViewChange = 179
                        endif
                        //up down
                        if up then
                            if mov.walking != 1 then
                                call SetUnitTimeScale(mov.u,mov.SpeedFactor)
                                call SetUnitAnimationByIndex(mov.u,mov.animation)
                                set mov.walking = 1
                            else
                                call SetUnitTimeScale(mov.u,mov.SpeedFactor)
                            endif
                            set x = GetUnitX(mov.u)
                            set y = GetUnitY(mov.u)
                            set X = x + GetUnitMoveSpeed(mov.u)*INTERVAL * Cos(GetUnitFacing(mov.u)*bj_DEGTORAD) * mov.SpeedFactor
                            set Y = y + GetUnitMoveSpeed(mov.u)*INTERVAL * Sin(GetUnitFacing(mov.u)*bj_DEGTORAD) * mov.SpeedFactor
                            //down down
                        elseif down then
                            if mov.walking != 2 then
                                call SetUnitTimeScale(mov.u,-BACKWARDS_MOVING_FACTOR * mov.SpeedFactor)
                                call SetUnitAnimationByIndex(mov.u,mov.animation)
                                set mov.walking = 2
                            else
                                call SetUnitTimeScale(mov.u,-BACKWARDS_MOVING_FACTOR * mov.SpeedFactor)
                            endif
                            set x = GetUnitX(mov.u)
                            set y = GetUnitY(mov.u)
                            set X = x - GetUnitMoveSpeed(mov.u) * INTERVAL * Cos(GetUnitFacing(mov.u)*bj_DEGTORAD) * BACKWARDS_MOVING_FACTOR * mov.SpeedFactor
                            set Y = y - GetUnitMoveSpeed(mov.u) * INTERVAL * Sin(GetUnitFacing(mov.u)*bj_DEGTORAD) * BACKWARDS_MOVING_FACTOR * mov.SpeedFactor
                        endif
                        //move
                        if down or up then
                            call SetUnitPosition(mov.u,X,Y)
                            if (RAbsBJ(GetUnitX(mov.u)-X)>0.5)or(RAbsBJ(GetUnitY(mov.u)-Y)>0.5)then
                                call SetUnitPosition(mov.u,X,y)
                                set boolX = RAbsBJ(GetUnitX(mov.u)-X)<=0.5
                                call SetUnitPosition(mov.u,x,Y)
                                set boolY = RAbsBJ(GetUnitY(mov.u)-Y)<=0.5
                                if boolX then
                                    call SetUnitPosition(mov.u,X,y)
                                elseif boolY then
                                    call SetUnitPosition(mov.u,x,Y)
                                else
                                    call SetUnitPosition(mov.u,x,y)
                                endif
                            endif
                        else
                            if mov.walking != 0 then
                                call SetUnitAnimation(mov.u,"stand")
                                call SetUnitTimeScale(mov.u,1)
                                set mov.walking = 0
                            endif
                        endif
                    endif
                endif
                set i = i + 1
            endloop
        endmethod
        
        static method onInit takes nothing returns nothing
            set .tim = CreateTimer()
            call TimerStart(.tim,INTERVAL,true,function ArrowKeyMovement.Walking)
        endmethod
    
    endstruct

    function GetMovementUnit takes player p returns unit
        return ArrowKeyMovement.u
    endfunction

    function SetMovementUnitAnimation takes player p, integer animation returns nothing
        set ArrowKeyMovement.animation = animation
    endfunction

    function ReleaseMovementUnit takes player p returns nothing
        if ArrowKeyMovement.u != null then 
            set ArrowKeyMovement.walking = 0
            call SetUnitAnimation(ArrowKeyMovement.u,"stand")
            call SetUnitTimeScale(ArrowKeyMovement.u,1)
            set ArrowKeyMovement.u = null
        endif
    endfunction

    function SetMovementUnit takes unit u, player p, integer anim returns nothing
        if u == null then
            call ReleaseMovementUnit(p)
            return
        endif
        if ArrowKeyMovement.u != null then
            call ReleaseMovementUnit(p)
        endif
        call SetUnitAnimation(ArrowKeyMovement.u,"stand")
        set ArrowKeyMovement.u = u
        set ArrowKeyMovement.animation = anim
    endfunction

    //! runtextmacro ArrowKeyMovement_Plugins_Functions()

    private function Init takes nothing returns nothing
        //! runtextmacro Init_ArrowKeyMovement_Plugins()
    endfunction

endlibrary


Keywords:
camera, key, arrow, up, down, left, right, press, release, vjass, mpi, rpg, distance, angle, zAngle, jass, z, item, doodad, movement, third, person, f
Contents

Camera and Keyboard System (Map)

Level 2
Joined
Jun 11, 2010
Messages
15
How can i even add unit to this map?? when i add unit and click test map it gives me some kind of errors like expecting end loop at the end of tralala....(just example) how can i put unit without that error (i cant even change the name of footman or dragon!!!) helpp plsssss! plss
 
Level 2
Joined
Jun 11, 2010
Messages
15
please i need some help... when i put a unit in the map and click test map it send me some errors like ''expecting end of line'' (just example ) anybody help? pls?
 
Level 4
Joined
Jun 13, 2010
Messages
114
I searched for several systems but none of them really worked.


1.How can I set this one up for 6 human players ?




2. I changed the footman into a Paladin but the Paladin just slides aroud without animations when I use arrow keys.
Is there a way to fix that ?
 
Last edited:
Can you create an in game individual player distance adjustment feature?

DainyG: you have to adjust the animation index for each model. thats why he just stands there unanimated. I created a library for every unit type I use and adjust an integer variable equal to the animation index needed. and its already set for all players

well new update features your proposal :D
some new functions implemented too
 
Level 6
Joined
May 20, 2010
Messages
274
I love this system!!! I'll use it and i will really give you credits on my map ^_^ (it's an rpg) and if you dont mind i will also make you an npc character! ^_^ just simply tell me what you wanna be (just a suggestion if you want and i'll be willing to do it) :D
 
I love this system!!! I'll use it and i will really give you credits on my map ^_^ (it's an rpg) and if you dont mind i will also make you an npc character! ^_^ just simply tell me what you wanna be (just a suggestion if you want and i'll be willing to do it) :D

Sure^^ that will be funny;) make me a town leader or something like that;) please just not a simple peasant :D and send me a link to your map...
 
Level 4
Joined
Jun 13, 2010
Messages
114
Can you create an in game individual player distance adjustment feature?

DainyG: you have to adjust the animation index for each model. thats why he just stands there unanimated. I created a library for every unit type I use and adjust an integer variable equal to the animation index needed. and its already set for all players

How can I do that ?
I have no idea on how to code jass... :sad:
 
well new update features your proposal :D
some new functions implemented too

Awesome I'll have to implement it before i release my demo!

How can I do that ?
I have no idea on how to code jass... :sad:

like if you chose a hero unit make it run something like this:

  • If/Then/Else
    • Conditions
      • Unit type of triggering unit = VillagerMale
    • Then
      • Set AnimationIndexVar = 6
    • Else
  • Call the camera system custom script here using the udg_AnimationIndexVar
 
Level 4
Joined
Jun 13, 2010
Messages
114
like if you chose a hero unit make it run something like this:

  • If/Then/Else
    • Conditions
      • Unit type of triggering unit = VillagerMale
    • Then
      • Set AnimationIndexVar = 6
    • Else
  • Call the camera system custom script here using the udg_AnimationIndexVar
[/QUOTE]


What hero uses what animation index ?
In my case the heroes are
Imported custom modells....heres my RPG: http://epicwar.com/maps/137626/
 
Level 4
Joined
Jun 13, 2010
Messages
114
Every model is different and you have to find that out for yourself lol

How can I find that out myself ?
Just by messing around and try all numbers ?

EDIT:....not even the cam system works for me.
I copied and pasted the trigger of it into my map but it just doesnt work.....
btw I use the latest version of jassnewgenpack.
 
Last edited:
Level 4
Joined
Jun 13, 2010
Messages
114
yeah start from 1 then work your way up, if you make a way to change the index in game it works better for finding it out.

ok I'll give it a try.

but what about the cam system?


EDIT: I already fixed it.
I just forgot to copy the "systems in use" trigger.
Everything works fine now excepted the animations.



EDIT2: is the part with "SetAnimationIndexVar= x" a variable ?
How can I do that variable exactly ?

and I neither understand this part "Call the camera system custom script here using the udg_AnimationIndexVar"

It currently looks like that for me
Rpgsystem.PNG


I made the "SetAnimationIndexVar= x" as integer but it doesnt work....


...and whats the highest number for animation index?

btw UrsaWarrior is player 2 (blue)

EDIT: ....ok it works now allways when I change the number the animation is a different one...
But how can I find the walking animation faster ?

Its anoying trying out all numbers....
 
Last edited:
Level 4
Joined
Jun 13, 2010
Messages
114
Now everything works fine for me.

But I got another questions.
Some units seem to turn faster with arrow keys than others.
Where can I change the turning speed ?
...and no It changes nothing when I just change the turning speed of the units with the unitseditor.
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
Uhm... whats your problem? when you registered the unit it should work...
and you maybe have to try around to find the walk anim index...

1.The unit is never moving!
2.Adding debug messages, I found out that the loop works and it only found the unit in the first loop and never again.
3.I never remove, replace or kill the unit. I don't remove it from movement either.

I will find the walk animation index, that's easy.
 
Level 3
Joined
May 28, 2009
Messages
53
Alright thisl make me sound like a noob at jass (fore i am a noob at jass) but what do i type and were to set the walk animation ive looked allover ur notes and things and i couldent figure out i tried a few gesses but jass helper told me it was errord so if u could link up what to type exactly id love u forever!!

oh and i almost forgot when u select the unit in the editor and on the left theres the little window with the model there go through the anims and count till u find the walk anim or atleast thats what i think u do instead of gess and checkin i believ the riflemans walk is five
anim.jpg

lol u can still control the unit when it dies
 
Last edited:
Level 3
Joined
May 28, 2009
Messages
53
well copy it all plus one of the trigs in the setup folder named systems in use. triggs (gui thank the lord) like
  • systems in use
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set u = Footman 0001 <gen>
      • Custom script: call SetCameraUnit(udg_u, Player(0))
      • Custom script: call SetMovementUnit(udg_u,Player(0),6)
copy that in also and change u to the unit you wana control all will work sept it might not play walk anim im not sure how to change hopefly sombody will post how
 
Level 3
Joined
Jun 7, 2010
Messages
33
Need help

The release function doesn't work

Compile error
JASS:
function Trig_TestCamRelease_Actions takes nothing returns nothing
    call ReleaseCamUnit(2)
endfunction

The trigger in question is

  • TestCamRelease
    • Events
      • Player - Player 3 (Teal) types a chat message containing -release as An exact match
    • Conditions
    • Actions
      • Custom script: call ReleaseCamUnit(2)
 
well copy it all plus one of the trigs in the setup folder named systems in use. triggs (gui thank the lord) like
  • systems in use
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set u = Footman 0001 <gen>
      • Custom script: call SetCameraUnit(udg_u, Player(0))
      • Custom script: call SetMovementUnit(udg_u,Player(0),6)
copy that in also and change u to the unit you wana control all will work sept it might not play walk anim im not sure how to change hopefly sombody will post how

guys LEARN JASS BASICS!! you don't have to know how to code but you should understand how jass works so you can use jass systems...

to change the animation you have to change the 6 in Custom script: call SetMovementUnit(udg_u,Player(0),6) into another number! you have to try around with this value cause there is no way to say which is the right one before trying... just start at 0 and always increase by 1 until you find the right one ;)



UPDATE: v.9.0: after trying to add a feature to make doodads blocking your view transparent (which i realized is impossible in WC3) i improved the cam system's code a little
 
Level 6
Joined
Sep 9, 2006
Messages
92
would it be possible to change the function of arrow keys when one of the other arrow keys is pressed? i was thinking that it would be cool to make it so when strafing, the opposite arrow is used to turn, like it would when not strafing, and the up arrow is used to turn the opposite way, because the arrow used to turn that way would be currently held down.

(strafing left then pushing the up arrow would turn u left as u strafe and right arrow would turn u right
 
would it be possible to change the function of arrow keys when one of the other arrow keys is pressed? i was thinking that it would be cool to make it so when strafing, the opposite arrow is used to turn, like it would when not strafing, and the up arrow is used to turn the opposite way, because the arrow used to turn that way would be currently held down.

(strafing left then pushing the up arrow would turn u left as u strafe and right arrow would turn u right
Well the whole strafing thing is coded as a plugin and not part of the system core^^ so you can code your own plugin or edit mine so you get your result...
 
Level 1
Joined
Jul 23, 2010
Messages
5
Thanks ALOT for this system. I've been searching for a good system for ages, I actually made this account just to thank you. I don't know much about jass, but what i know is that there are others who have a lot to learn from you. I love the double click system.
10/5 +rep
 
I've looked at the spells ratings, and I've come to the conclusion that this is the best spell/system at hive! It's got 15 5/5 ratings! It's the 5/5 rated spell with most raters!
Damn it deserves this rating for it's coolness!

yeah you are right! and its not even directors cut :D:D
but i'm very glad and
I'd like to thank everyone who tried/supported/rated this system!!!

You made this system the --> BEST <-- rated system here on THW!!!!!

BIG THX ;)
 
Level 21
Joined
Dec 9, 2007
Messages
3,096
yeah you are right! and its not even directors cut :D:D
but i'm very glad and
I'd like to thank everyone who tried/supported/rated this system!!!

You made this system the --> BEST <-- rated system here on THW!!!!!

BIG THX ;)


[REMOVED SIZE LOL]

Well, it should be Director's Cut because it is simply our most useful resource and it's very well coded!
 
Level 10
Joined
Jun 7, 2008
Messages
420
JASS:
function ResetToGameCameraForPlayer takes player whichPlayer, real duration returns nothing
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call ResetToGameCamera(duration)
    endif
endfunction
in
JASS:
function ReleaseCameraUnit takes player p returns nothing
    if CamUnit[GetPlayerId(p)] != null then
        set CamUnit[GetPlayerId(p)] = null
        call ResetToGameCameraForPlayer(p,0)
        if GetLocalPlayer() == p then
            call CameraSetSmoothingFactor(0)
        endif
        set active = active - 1
        if active == 0 then
            call PauseTimer(tim)
        endif
    endif
endfunction
but no need to change for just a single function call
well I actually need to find something to have a reason to post and vote it so... :thumbs_up:

5/5 + rep anyway


So how do I do that? Could someone please put it in a map and send/pastebin it to me? Thanks, will rep. I know I'm crap at JASS, but there's only 2 triggers in my whole map in JASS that I need to edit so isn't reason enough to learn.

Also, how to set the camera further back from the unit?

Thanks, great system
 
Level 4
Joined
Jul 27, 2009
Messages
70
very good but I cannot use it im my map?
It is code not a trigger
I cannot use jass if i Edit the map the cods will begin to disable!
Can you plan it im my map?
I will give you a good credit!
p.m me
But I need it for player 3 and player 9!
my action group!
 
Top