По поводу управления на стрелках
Используется система от MF_Andreich (та, что - plain jass). Проблема в том, что скорость анимации юнита не изменяется от замедляющих/ускоряющих баффов, пока зажата стрелка передвижения.
» Код
 
//--------------------------------------------- Control System by MF v1.12 ---------------------------------------

// User-adjucted area
//
// This function takes a unit and returns boolean
// if it can move now. You can add your own conditions
// here to customize thу system.
 
    function SCS_ConditionToMove takes unit u returns boolean
        return (GetUnitState(u, UNIT_STATE_LIFE)>=0.45)and(GetUnitAbilityLevel(u, 'BSTN')==0)and(GetUnitAbilityLevel(u,'BPSE')==0)and(GetUnitAbilityLevel(u,'BUsl')==0)and(GetUnitAbil​ityLevel(u,'BUst')==0)and(GetUnitAbilityLevel(u,'BUim')==0)and(GetUnitAbilityLevel(u,'Bwea')==0)and(​GetUnitAbilityLevel(u,'Bweb')==0)and(GetUnitAbilityLevel(u,'Bmlt')==0)
    endfunction

// End of user-adjucted area

   
    function SCS_UpUp_Func takes integer i returns nothing
        set udg_SCS_Up[i] = false
        if GetUnitState(udg_SCS_Units[i],UNIT_STATE_LIFE)>=0.45 then
            call SetUnitTimeScale(udg_SCS_Units[i], 1)
            call SetUnitAnimation(udg_SCS_Units[i], "stand")    
        endif
        if(udg_SCS_Down[i])and(udg_SCS_Arround[i])then
            set udg_SCS_FlagArround[i] = true
            call SetUnitFacingTimed( udg_SCS_Units[i], (GetUnitFacing(udg_SCS_Units[i])+180), 0.01 )
        endif
        if udg_SCS_ResetFlag[i] then
            set udg_SCS_ResetFlag[i] = false
            if GetUnitState(udg_SCS_Units[i],UNIT_STATE_LIFE)>=0.45 and udg_SCS_ApplyControl[i] and udg_SCS_Anims[i]!=-1 then
                call SetUnitAnimationByIndex(udg_SCS_Units[i],udg_SCS_Anims[i]) 
            endif
            if(not udg_SCS_Up[i])and(udg_SCS_Arround[i])then
                call SetUnitTimeScale(udg_SCS_Units[i], GetUnitMoveSpeed(udg_SCS_Units[i])/GetUnitDefaultMoveSpeed(udg_SCS_Units[i]))
                set udg_SCS_FlagArround[i] = true
                call SetUnitFacingTimed( udg_SCS_Units[i], (GetUnitFacing(udg_SCS_Units[i])+180), 0 )
            else
                call SetUnitTimeScale(udg_SCS_Units[i], -GetUnitMoveSpeed(udg_SCS_Units[i])/GetUnitDefaultMoveSpeed(udg_SCS_Units[i]))
            endif
        endif
    endfunction
    
    function SCS_DownUp_Func takes integer i returns nothing
        set udg_SCS_Down[i] = false
        if GetUnitState(udg_SCS_Units[i],UNIT_STATE_LIFE)>=0.45 then
            call SetUnitTimeScale(udg_SCS_Units[i], 1)
            call SetUnitAnimation(udg_SCS_Units[i], "stand")   
        endif
        if udg_SCS_FlagArround[i] then
            set udg_SCS_FlagArround[i] = false
            call SetUnitFacingTimed( udg_SCS_Units[i], (GetUnitFacing(udg_SCS_Units[i])+180), 0 )
        endif
        if udg_SCS_ResetFlag[i] then
            set udg_SCS_ResetFlag[i] = false
            if GetUnitState(udg_SCS_Units[i],UNIT_STATE_LIFE)>=0.45 and udg_SCS_ApplyControl[i] then
                if(udg_SCS_Anims[i]!=-1)then
                    call SetUnitAnimationByIndex(udg_SCS_Units[i],udg_SCS_Anims[i])   
                endif
                call SetUnitTimeScale(udg_SCS_Units[i], GetUnitMoveSpeed(udg_SCS_Units[i])/GetUnitDefaultMoveSpeed(udg_SCS_Units[i]))
            endif
        endif
    endfunction
    
    function SCS_LeftUp_Func takes integer i returns nothing
        set udg_SCS_Left[i] = false
        if (not udg_SCS_Up[i])and(not udg_SCS_Down[i]) then
            call IssueImmediateOrder( udg_SCS_Units[i], "stop" )
        endif
    endfunction
    
    function SCS_RightUp_Func takes integer i returns nothing
        set udg_SCS_Right[i] = false
        if (not udg_SCS_Up[i])and(not udg_SCS_Down[i]) then
            call IssueImmediateOrder( udg_SCS_Units[i], "stop" )
        endif
    endfunction
    
    function SCS_GetUnit takes player p returns unit
        return udg_SCS_Units[GetPlayerId(p)]
    endfunction
    
    function SCS_RemoveAssociate takes player p returns nothing
        set udg_SCS_Units[GetPlayerId(p)] = null        
    endfunction 
 
    function SCS_Associate takes unit u, player p, integer a, boolean b returns nothing        
        if(udg_SCS_Units[GetPlayerId(p)]!=null)then
            call SetUnitTimeScale(udg_SCS_Units[GetPlayerId(p)],1)
            call SetUnitAnimation(udg_SCS_Units[GetPlayerId(p)], "stand")
        endif
        set udg_SCS_Units[GetPlayerId(p)] = u
        set udg_SCS_Anims[GetPlayerId(p)] = a
        set udg_SCS_Arround[GetPlayerId(p)] = b
        set udg_SCS_FlagArround[GetPlayerId(p)] = false
    endfunction

    function SCS_RemoveControlUnit takes player p returns nothing
        call RemoveUnit(udg_SCS_Units[GetPlayerId(p)])
        set udg_SCS_Units[GetPlayerId(p)] = null
    endfunction
    
    function SCS_SetControl takes player p, boolean b returns nothing
        local integer i = GetPlayerId(p)
        set udg_SCS_ApplyControl[i] = b    
        if not b then
            call SCS_UpUp_Func(i)
            call SCS_DownUp_Func(i)
            call SCS_RightUp_Func(i)
            call SCS_LeftUp_Func(i)
        endif
    endfunction
    
    function SCS_SetCamera takes player p, boolean b returns nothing
        set udg_SCS_ApplyCam[GetPlayerId(p)] = b
        if(GetLocalPlayer()==p)then
            if not b then
                call ResetToGameCamera(0)
                call CameraSetSmoothingFactor(0)
            else            
                call SetCameraTargetController(udg_SCS_Units[GetPlayerId(p)],0,0,false)
                call CameraSetSmoothingFactor(1)
            endif
        endif
    endfunction
    
    function SCS_GetControl takes player p returns boolean
        return udg_SCS_ApplyControl[GetPlayerId(p)]
    endfunction
    
    function SCS_GetCamera takes player p returns boolean
        return udg_SCS_ApplyCam[GetPlayerId(p)]
    endfunction    
    
    function SCS_UpUp_Actions takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        call SCS_UpUp_Func(i)
    endfunction
    
    function SCS_UpDown_Actions takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        set udg_SCS_Up[i] = true
        if GetUnitState(udg_SCS_Units[i],UNIT_STATE_LIFE)>=0.45 and udg_SCS_ApplyControl[i] then
            if(udg_SCS_Anims[i]!=-1)then
                call SetUnitAnimationByIndex(udg_SCS_Units[i],udg_SCS_Anims[i])   
            endif
            call SetUnitTimeScale(udg_SCS_Units[i], GetUnitMoveSpeed(udg_SCS_Units[i])/GetUnitDefaultMoveSpeed(udg_SCS_Units[i]))
        endif
    endfunction
    
    function SCS_DownUp_Actions takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        call SCS_DownUp_Func(i)
    endfunction
    
    function SCS_DownDown_Actions takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        set udg_SCS_Down[i] = true
        if GetUnitState(udg_SCS_Units[i],UNIT_STATE_LIFE)>=0.45 and udg_SCS_ApplyControl[i] and udg_SCS_Anims[i]!=-1 then
            call SetUnitAnimationByIndex(udg_SCS_Units[i],udg_SCS_Anims[i]) 
        endif
        if(not udg_SCS_Up[i])and(udg_SCS_Arround[i])then
            call SetUnitTimeScale(udg_SCS_Units[i], GetUnitMoveSpeed(udg_SCS_Units[i])/GetUnitDefaultMoveSpeed(udg_SCS_Units[i]))
            set udg_SCS_FlagArround[i] = true
            call SetUnitFacingTimed( udg_SCS_Units[i], (GetUnitFacing(udg_SCS_Units[i])+180), 0 )
        else
            call SetUnitTimeScale(udg_SCS_Units[i], -GetUnitMoveSpeed(udg_SCS_Units[i])/GetUnitDefaultMoveSpeed(udg_SCS_Units[i]))
        endif
    endfunction
    
    function SCS_RightUp_Actions takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        call SCS_RightUp_Func(i)
    endfunction
    
    function SCS_RightDown_Actions takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        set udg_SCS_Right[i] = true
    endfunction
    
    function SCS_LeftUp_Actions takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        call SCS_LeftUp_Func(i)
    endfunction
    
    function SCS_LeftDown_Actions takes nothing returns nothing
        local integer i = GetPlayerId(GetTriggerPlayer())
        set udg_SCS_Left[i] = true
    endfunction
    
    function SCS_Move_Actions takes nothing returns nothing
        local real X 
        local real Y 
        local real Xh
        local real Yh
        local boolean bx
        local boolean by
        local real Angle 
        local integer i = 0
        local integer iflag = 0
        local boolean bflag = false
        loop
            exitwhen i >= udg_SCS_COUNT_OF_PLAYERS
                if (udg_SCS_Units[i] != null)and(udg_SCS_ApplyControl[i]) then           
                    if udg_SCS_Up[i] and (not udg_SCS_Down[i]) and SCS_ConditionToMove(udg_SCS_Units[i]) then
                        set bflag = true
                        set iflag = 1
                    elseif (not udg_SCS_Up[i]) and udg_SCS_Down[i] and SCS_ConditionToMove(udg_SCS_Units[i]) then
                        set bflag = true
                        if(udg_SCS_FlagArround[i])then
                            set iflag = 1
                        else
                            set iflag = -1
                        endif
                    else
                        set bflag = false
                    endif
                    if bflag then
                        set Angle = GetUnitFacing(udg_SCS_Units[i])
                        set X = GetUnitX(udg_SCS_Units[i])+iflag*(GetUnitMoveSpeed(udg_SCS_Units[i])/100)*Cos(Angle*bj_DEGTORAD)
                        set Y = GetUnitY(udg_SCS_Units[i])+iflag*(GetUnitMoveSpeed(udg_SCS_Units[i])/100)*Sin(Angle*bj_DEGTORAD)  
                        set Xh = GetUnitX(udg_SCS_Units[i])
                        set Yh = GetUnitY(udg_SCS_Units[i])
                        call SetUnitPosition(udg_SCS_Units[i],X,Y)
                        call ClearTextMessages()                        
                        if(RAbsBJ(GetUnitX(udg_SCS_Units[i])-X)>0.5)or(RAbsBJ(GetUnitY(udg_SCS_Units[i])-Y)>0.5)then
                            call SetUnitPosition(udg_SCS_Units[i],X,Yh)
                            set bx = RAbsBJ(GetUnitX(udg_SCS_Units[i])-X)<=0.5                            
                            call SetUnitPosition(udg_SCS_Units[i],Xh,Y)
                            set by = RAbsBJ(GetUnitY(udg_SCS_Units[i])-Y)<=0.5
                            if bx then
                                call SetUnitPosition(udg_SCS_Units[i],X,Yh)
                            elseif by then
                                call SetUnitPosition(udg_SCS_Units[i],Xh,Y)
                            else
                                call SetUnitPosition(udg_SCS_Units[i],Xh,Yh)
                            endif
                        endif
                    endif
                    if udg_SCS_Right[i] and (not udg_SCS_Left[i]) and SCS_ConditionToMove(udg_SCS_Units[i]) then
                        set bflag = true
                        set iflag = 1
                    elseif (not udg_SCS_Right[i]) and udg_SCS_Left[i] and SCS_ConditionToMove(udg_SCS_Units[i]) then
                        set bflag = true
                        set iflag = -1
                    else
                        set bflag = false
                    endif
                    if bflag then
                        if udg_SCS_Down[i] then
                            call SetUnitFacingTimed( udg_SCS_Units[i], (GetUnitFacing(udg_SCS_Units[i])+iflag*udg_SCS_INVERSE*(8.00)), 0.01 )
                        else
                            call SetUnitFacingTimed( udg_SCS_Units[i], (GetUnitFacing(udg_SCS_Units[i])-iflag*(8.00)), 0.01 )                            
                        endif
                    endif
            endif
          set i = i + 1
        endloop
    endfunction
    
    function SCS_Animation_Actions takes nothing returns nothing    
    local integer i = 0
       loop
         exitwhen i >= udg_SCS_COUNT_OF_PLAYERS 
            if udg_SCS_Up[i] and udg_SCS_Down[i] and not udg_SCS_ResetFlag[i] then
                set udg_SCS_ResetFlag[i] = true
                call SetUnitAnimation(udg_SCS_Units[i],"stand")
            endif
            if not udg_SCS_ResetFlag[i] then
                   if (udg_SCS_Up[i] or udg_SCS_Down[i]) and SCS_ConditionToMove(udg_SCS_Units[i]) and udg_SCS_Anims[i]!=-1 then
                     call SetUnitAnimationByIndex(udg_SCS_Units[i],udg_SCS_Anims[i])                
                  endif                  
            endif
          set i = i + 1
        endloop
    endfunction
    
    function SCS_Camera_Actions takes nothing returns nothing
        local integer i = 0
        local real Z1
        local real Z2
        local real Angle1
        local real offset
        local real Angle2
        loop
            exitwhen i >=  udg_SCS_COUNT_OF_PLAYERS
            if (udg_SCS_Units[i] != null) and (udg_SCS_ApplyCam[i]) then
                call MoveLocation(udg_SCS_l,GetUnitX(udg_SCS_Units[i]),GetUnitY(udg_SCS_Units[i]))
                set Z1 = GetLocationZ(udg_SCS_l)                                
                call MoveLocation(udg_SCS_l,GetUnitX(udg_SCS_Units[i])-400*Cos(GetUnitFacing(udg_SCS_Units[i])*bj_DEGTORA​D),GetUnitY(udg_SCS_Units[i])-400*Sin(GetUnitFacing(udg_SCS_Units[i])*bj_DEGTORAD))
                set Z2 = GetLocationZ(udg_SCS_l)
                if(Z1+100>=Z2)then
                    set offset=GetCameraField(CAMERA_FIELD_ZOFFSET)+GetUnitFlyHeight(udg_SCS_Units[i])+300+Z1-GetCameraEyePo​sitionZ()
                    set Angle1 = -15
                else
                    set offset=R2I(GetCameraField(CAMERA_FIELD_ZOFFSET))+300+GetUnitFlyHeight(udg_SCS_Units[i])+Z2-R2I(GetCa​meraEyePositionZ())
                    set Angle1 = -50
                endif
                set Angle2 = GetUnitFacing(udg_SCS_Units[i])
                if (udg_SCS_Down[i])and(not udg_SCS_Up[i])and(udg_SCS_Arround[i])then
                    set Angle2 = Angle2 + 180
                endif
                if(GetLocalPlayer()==Player(i))then
                    call SetCameraField(CAMERA_FIELD_ZOFFSET,offset,0.25) 
                    call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE,450,0.25)
                    call SetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK,Angle1,0.25)
                    call SetCameraField(CAMERA_FIELD_FIELD_OF_VIEW,100,0.1)
                    call SetCameraField(CAMERA_FIELD_FARZ,bj_CAMERA_DEFAULT_FARZ,0.25)                    
                    call SetCameraField(CAMERA_FIELD_ROTATION,Angle2,0.25)
                endif                
             endif
          set i = i + 1
        endloop
    endfunction

function InitTrig_SCS_plain_jass takes nothing returns nothing
        local integer Count = 0
        //create triggers
        local trigger UpDown = CreateTrigger(  )
        local trigger UpUp = CreateTrigger(  )
        local trigger DownDown = CreateTrigger(  )
        local trigger DownUp = CreateTrigger(  )
        local trigger RightDown = CreateTrigger(  )
        local trigger RightUp = CreateTrigger(  )
        local trigger LeftDown = CreateTrigger(  )
        local trigger LeftUp = CreateTrigger(  )
        
        set udg_SCS_l = Location(0,0)
        //create events
        loop
            exitwhen Count>=udg_SCS_COUNT_OF_PLAYERS
            call TriggerRegisterPlayerEvent(UpDown, Player(Count), EVENT_PLAYER_ARROW_UP_DOWN)
            call TriggerRegisterPlayerEvent(UpUp, Player(Count), EVENT_PLAYER_ARROW_UP_UP)
            call TriggerRegisterPlayerEvent(DownDown, Player(Count), EVENT_PLAYER_ARROW_DOWN_DOWN)
            call TriggerRegisterPlayerEvent(DownUp, Player(Count), EVENT_PLAYER_ARROW_DOWN_UP)
            call TriggerRegisterPlayerEvent(LeftDown, Player(Count), EVENT_PLAYER_ARROW_LEFT_DOWN)
            call TriggerRegisterPlayerEvent(LeftUp, Player(Count), EVENT_PLAYER_ARROW_LEFT_UP)
            call TriggerRegisterPlayerEvent(RightDown, Player(Count), EVENT_PLAYER_ARROW_RIGHT_DOWN)
            call TriggerRegisterPlayerEvent(RightUp, Player(Count), EVENT_PLAYER_ARROW_RIGHT_UP)                      
            set Count = Count + 1
        endloop
        
        //create actions
        call TriggerAddAction( UpDown, function SCS_UpDown_Actions )
        call TriggerAddAction( UpUp, function SCS_UpUp_Actions )
        call TriggerAddAction( DownDown, function SCS_DownDown_Actions )
        call TriggerAddAction( DownUp, function SCS_DownUp_Actions )
        call TriggerAddAction( RightDown, function SCS_RightDown_Actions )
        call TriggerAddAction( RightUp, function SCS_RightUp_Actions )
        call TriggerAddAction( LeftDown, function SCS_LeftDown_Actions )
        call TriggerAddAction( LeftUp, function SCS_LeftUp_Actions )

        
        call TimerStart(CreateTimer(),0.01,true,function SCS_Move_Actions)
        call TimerStart(CreateTimer(),0.2,true,function SCS_Animation_Actions)
        call TimerStart(CreateTimer(),0.01,true,function SCS_Camera_Actions)
endfunction

//--------------------------------------------- End of Control System by MF v1.12 ---------------------------------------

Лучший ответ:
Надо же. Не обладая знаниями Jass, в течении 3-х дней пыток, удалось разобраться.

Теперь скорость анимации может изменяется во время движения юнита.
+ независимые передняя и задняя скорости.
+ внешний контроль скоростей анимации, движения и поворота.

Нехитрое дело, изменений не более ~0,5%.



Просмотров: 226

Bergi_Bear #1 - 2 месяца назад 0
call SetUnitTimeScale(udg_SCS_Units[i], GetUnitMoveSpeed(udg_SCS_Units[i])/GetUnitDefaultMoveSpeed(udg_SCS_Units[i]))
вот оно ускорение шевеления юнита от его скорости, всё "нормально"
SNART #2 - 2 месяца назад (отредактировано ) 0
Нужно доработать следующий блок:
» Оригинал
 
    function SCS_Animation_Actions takes nothing returns nothing    
    local integer i = 0
       loop
         exitwhen i >= udg_SCS_COUNT_OF_PLAYERS 
            if udg_SCS_Up[i] and udg_SCS_Down[i] and not udg_SCS_ResetFlag[i] then
                call SetUnitAnimation(udg_SCS_Units[i],"stand")
            endif
            if not udg_SCS_ResetFlag[i] then
                   if (udg_SCS_Up[i] or udg_SCS_Down[i]) and SCS_ConditionToMove(udg_SCS_Units[i]) and udg_SCS_Anims[i]!=-1 then
                     call SetUnitAnimationByIndex(udg_SCS_Units[i],udg_SCS_Anims[i])                
                  endif                  
            endif
          set i = i + 1
        endloop
    endfunction
» То, чего там нехватает:
 
            call SetUnitTimeScalePercent(udg_SCS_Units[i], (GetUnitMoveSpeed(udg_SCS_Units[i])/udg_J_JukSkorAnimA[i]))
            call SetUnitFacingTimed( udg_SCS_Units[i], (GetUnitFacing(udg_SCS_Units[i])+180), 0 )
        else
            call SetUnitTimeScalePercent(udg_SCS_Units[i], (0-(GetUnitMoveSpeed(udg_SCS_Units[i])/udg_J_JukSkorAnimB[i])))
        endif
    endfunction
SNART #3 - 2 месяца назад (отредактировано ) 2   

Надо же. Не обладая знаниями Jass, в течении 3-х дней пыток, удалось разобраться.

Теперь скорость анимации может изменяется во время движения юнита.
+ независимые передняя и задняя скорости.
+ внешний контроль скоростей анимации, движения и поворота.

Нехитрое дело, изменений не более ~0,5%.