• 🏆 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!

Did the "dummy.mdl" model have facing angle?

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,850
I wanna attach this effect Culling Slash to that dummy and for some reason don't have its facing, this is the code:
vJASS:
function Trig_Fast_Cut_Conditions takes nothing returns boolean
    return Spell=='A0AX'
endfunction

function Trig_Fast_Cut_Actions3 takes nothing returns nothing
    local timer t=GetExpiredTimer()
    local integer i=GetHandleId(t)
    set bj_lastCreatedUnit=GetRecycledUnit(Player(PLAYER_NEUTRAL_PASSIVE),'h013',LoadReal(udg_Wait,i,1)+600*Cos(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,2)+600*Sin(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,3))
    call DestroyEffect(AddSpecialEffectTarget("war3mapImported\\Culling Cleave Silver.mdx",bj_lastCreatedUnit,"origin"))
    call RecycleUnitDelayed(bj_lastCreatedUnit,0.27)
    call ReleaseTimer(t)
    call FlushChildHashtable(udg_Wait,i)
    set t=null
endfunction

function Trig_Fast_Cut_Actions2 takes nothing returns nothing
    local timer t=GetExpiredTimer()
    local integer i=GetHandleId(t)
    set bj_lastCreatedUnit=GetRecycledUnit(Player(PLAYER_NEUTRAL_PASSIVE),'h013',LoadReal(udg_Wait,i,1)+300*Cos(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,2)+300*Sin(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,3))
    call DestroyEffect(AddSpecialEffectTarget("war3mapImported\\Culling Cleave Silver.mdx",bj_lastCreatedUnit,"origin"))
    call RecycleUnitDelayed(bj_lastCreatedUnit,0.27)
    call TimerStart(t,0.03,false,function Trig_Fast_Cut_Actions3)
    set t=null
endfunction

function Trig_Fast_Cut_Actions takes nothing returns nothing
    local unit u
    local group g=CreateGroup()
    local real damage
    local real x=GetUnitX(Caster)
    local real y=GetUnitY(Caster)
    local real face=AngleBetweenCoords(x,y,GetSpellTargetX(),GetSpellTargetY())
    local player p=GetOwningPlayer(Caster)
    local timer t=NewTimer()
    local integer i=GetHandleId(t)
    if Spell=='A0AX' then
        set damage=40+50*Level
        set Level=Level+2
    endif
    call GroupEnumUnitsInRange(g,x-100*Cos(face),y-100*Sin(face),800,null)
    loop
        set u=FirstOfGroup(g)
        exitwhen u==null
        if RAbsBJ(AngleBetweenCoords(x,y,GetUnitX(u),GetUnitY(u))-face)<=bj_PI/5 and IsUnitEnemy(u,p) and not IsUnitType(u,UNIT_TYPE_STRUCTURE) and not IsUnitType(u,UNIT_TYPE_MAGIC_IMMUNE) and not IsUnitType(u,UNIT_TYPE_MECHANICAL) then
            call UnitDamageTarget(Caster,u,damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_SONIC,WEAPON_TYPE_WHOKNOWS)
            set bj_lastCreatedUnit=GetRecycledUnit(p,'n018',GetUnitX(u),GetUnitY(u),bj_UNIT_FACING)
            call SetUnitAbilityLevel(bj_lastCreatedUnit,'A07L',Level)
            call IssueTargetOrder(bj_lastCreatedUnit,"slow",u)
            call RecycleUnitDelayed(bj_lastCreatedUnit,0.27)
        endif
        call GroupRemoveUnit(g,u)
    endloop
    call DestroyGroup(g)
    call DestroyEffect(AddSpecialEffectTarget("war3mapImported\\Culling Cleave Silver.mdx",Caster,"origin"))
    call SaveReal(udg_Wait,i,1,x)
    call SaveReal(udg_Wait,i,2,y)
    call SaveReal(udg_Wait,i,3,face)
    call TimerStart(t,0.03,false,function Trig_Fast_Cut_Actions2)
    set g=null
    set p=null
endfunction

//===========================================================================
function InitTrig_Fast_Cut takes nothing returns nothing
    set gg_trg_Fast_Cut=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Fast_Cut,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Fast_Cut,Condition(function Trig_Fast_Cut_Conditions))
    call TriggerAddAction(gg_trg_Fast_Cut,function Trig_Fast_Cut_Actions)
endfunction
And I don't think the model of the effect is the problem because it worked when I attached it in another unit.
 
Level 24
Joined
Jun 26, 2020
Messages
1,850
Is in 0
0.PNG

what else could be?
 
It's ok, at least what I meant. But maybe it's not really related.. I'm not sure why facing should work different if you spawn an other unit type with same code.

To get sure, is it this facing we're talking about which is wrong?
Code:
call SaveReal(udg_Wait,i,3,face)
is face in radian? I ask because Sin and Cos require radian, but normal facing unit requires degree. So here is most likely one mistake in these lines
Code:
set bj_lastCreatedUnit=GetRecycledUnit(Player(PLAYER_NEUTRAL_PASSIVE),'h013',LoadReal(udg_Wait,i,1)+300*Cos(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,2)+300*Sin(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,3))
... but it still would not explain why it should work correctly for an other unit type. Might you attach a demo?
 
Level 24
Joined
Jun 26, 2020
Messages
1,850
Well, this is how it is:
vJASS:
local real x=GetUnitX(Caster)
local real y=GetUnitY(Caster)
local real face=AngleBetweenCoords(x,y,GetSpellTargetX(),GetSpellTargetY())
vJASS:
function AngleBetweenCoords takes real x1, real y1, real x2, real y2 returns real
    return Atan2(y2-y1,x2-x1)
endfunction
Use this map, just use the placed Cacique and the spell called "Fast Cut" and the trigger is in "Habilidades/Fast Cut", and the dummy unit is in "Custom Units/Human/Melee/Base para efectos"
 

Attachments

  • The escape of draenei vBeta23.w3x
    4.5 MB · Views: 15
Last edited:
Well, this is how it is:
vJASS:
local real x=GetUnitX(Caster)
local real y=GetUnitY(Caster)
local real face=AngleBetweenCoords(x,y,GetSpellTargetX(),GetSpellTargetY())
vJASS:
function AngleBetweenCoords takes real x1, real y1, real x2, real y2 returns real
    return Atan2(y2-y1,x2-x1)
endfunction
Use this map, just use the placed Cacique and the spell called "Fast Cut" and the trigger is in "Habilidades/Fast Cut", and the dummy unit is in "Custom Units/Human/Melee/Base para efectos"
So "face" is radian, as Atan2 returns radian, alright. What I meant is then this last parameter is probably wrong. I would assume it requires degree
Code:
set bj_lastCreatedUnit=GetRecycledUnit(Player(PLAYER_NEUTRAL_PASSIVE),'h013',LoadReal(udg_Wait,i,1)+300*Cos(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,2)+300*Sin(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,3))
. So it would be bj_DEGTORAD*LoadReal(udg_Wait,i,3))

Right now I can't test the demo, but tomorrow I guess. But you mean same code works correctly for other unit type?
 
Level 24
Joined
Jun 26, 2020
Messages
1,850
So "face" is radian, as Atan2 returns radian, alright. What I meant is then this last parameter is probably wrong. I would assume it requires degree
Code:
set bj_lastCreatedUnit=GetRecycledUnit(Player(PLAYER_NEUTRAL_PASSIVE),'h013',LoadReal(udg_Wait,i,1)+300*Cos(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,2)+300*Sin(LoadReal(udg_Wait,i,3)),LoadReal(udg_Wait,i,3))
. So it would be bj_DEGTORAD*LoadReal(udg_Wait,i,3))

Right now I can't test the demo, but tomorrow I guess. But you mean same code works correctly for other unit type?
Oh of course I forgot that functions works with degrees not with radians, but what a fool I was, thank you.
 
Last edited:
Status
Not open for further replies.
Top