HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

SetUnitFacing Question

03-04-2008, 04:34 PM#1
GALLED
Hello,

I have a spell that twist the creature objective, but the twist is very slow. I wanted something like cyclone:

Collapse JASS:
function Trig_Twist_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A070' 
endfunction

function Twist_Main takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit(t,"Twist_Unit")
local real a = GetHandleReal(t,"Twist_Ang")+60

    if(a>360)then
        set a = 1
    endif

    call SetUnitFacing(u,a)
    call SetHandleReal(t,"Twist_Ang",a)
    
set u = null
set t = null
endfunction

function Trig_Twist_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit v = GetSpellTargetUnit()
    call PauseUnit(v,true)
    call SetHandleUnit(t,"Twist_Unit",v)
    call SetHandleReal(t,"Twist_Ang",GetUnitFacing(v))
    call TimerStart(t,0.035,true,function Twist_Main)
    call TriggerSleepAction(1.1)
    call FlushHandleLocals(t)
    call DestroyTimer(t)
    
set t = null
set v = null    
endfunction

//===========================================================================
function InitTrig_Twist takes nothing returns nothing
local trigger gg_trg_Twist = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Twist, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Twist, Condition( function Trig_Twist_Conditions ) )
    call TriggerAddAction( gg_trg_Twist, function Trig_Twist_Actions )
endfunction

When I use this code:

Collapse JASS:
function Trig_Twist_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A070' 
endfunction

function Twist_Main takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = GetHandleUnit(t,"Twist_Unit")
local real a = GetUnitFacing(u)+45

    if(a>360)then
        set a = 1
    endif
    call BJDebugMsg(R2S(a))
    call SetUnitFacing(u,a)
    
set u = null
set t = null
endfunction

function Trig_Twist_Actions takes nothing returns nothing
local timer t = CreateTimer()
local unit v = GetSpellTargetUnit()
    call PauseUnit(v,true)
    call SetHandleUnit(t,"Twist_Unit",v)
    call TimerStart(t,0.035,true,function Twist_Main)
    call TriggerSleepAction(1.1)
    call FlushHandleLocals(t)
    call DestroyTimer(t)
    
set t = null
set v = null    
endfunction

//===========================================================================
function InitTrig_Twist takes nothing returns nothing
local trigger gg_trg_Twist = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Twist, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Twist, Condition( function Trig_Twist_Conditions ) )
    call TriggerAddAction( gg_trg_Twist, function Trig_Twist_Actions )
endfunction

This return me, numbers like this:
45
47
50
53
etc.

Why SetUnitFacing is too slow???
03-04-2008, 04:48 PM#2
Anitarf
It is not possible to change the facing of a unit instantly; it can only turn as fast as it's turn speed (defined in the object editor) will allow it.
03-04-2008, 04:53 PM#3
GALLED
Quote:
Originally Posted by Anitarf
It is not possible to change the facing of a unit instantly; it can only turn as fast as it's turn speed (defined in the object editor) will allow it.

And Which is the difference between SetUnitFacing and SetUnitFacingTimed???
03-04-2008, 05:00 PM#4
Anitarf
The timed version allows you to set it slower than the unit's turn speed.
03-04-2008, 05:54 PM#5
GALLED
Ah ok. Thanks, so i cannot make my cyclone :(
03-04-2008, 06:27 PM#6
RolePlaynGamer
You could hide the hero and place a dummy unit with bladestorm, then let the dummy use it, and finally remove the dummy and un-hide the hero
03-04-2008, 06:45 PM#7
GALLED
It wanted to do it, but towards an objective creature. Not to the hero.
03-04-2008, 06:51 PM#8
RolePlaynGamer
What do you mean?
03-04-2008, 06:59 PM#9
GALLED
Quote:
Originally Posted by RolePlaynGamer
What do you mean?

I want to do custom Cyclone, but without the special effect. Just that the creature turns and turns.
03-04-2008, 07:13 PM#10
RolePlaynGamer
If you mean where the hero / dummy just do the bladestorm whirlwind, without damaging anyone, then just set these fields in the bladestorm skill in Object Editor:

Damage Per Second ~ 0.00
Area of Effect ~ 0.00
Duration ~ Whatever you want
Hero Ability ~ Set to false
Mana Cost ~ 0
Required Level ~ 0
03-08-2008, 12:33 AM#11
burningice95
I think the bladestorm is actually part of the blademaster model, so giving it to a unit w/o that model will do nothing (except constantly damage the are around him, maybe)
03-08-2008, 01:18 AM#12
Fledermaus
And preventing him from casting spells.
03-08-2008, 08:48 AM#13
RolePlaynGamer
Then give the dummy the blademastyer model, none will notice that it has blademaster model if it begin spinning when it's created