HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Angle Problem

11-03-2007, 04:57 PM#1
Tiku
Okay so im making a simple custom attack system, basically, you click the spell (or press hotkey) to attack an area in front of you, basically a real life attack thingy...

Umm so far i got some stuff, it should of worked... i mean it does work but sometimes it doesnt depending on the angle facing of the caster... like facing north, it doesnt work... i dont understand why...

Heres the Code:
Collapse JASS:
constant function FurySlash_sfx takes nothing returns string
    return "Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl"
endfunction

function Trig_Fury_Slash_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function FurySlash_Check takes nothing returns boolean
    return IsUnitAliveBJ(GetFilterUnit()) == true
endfunction

function Trig_Fury_Slash_Actions takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local player up = GetOwningPlayer(u)
    local real face = GetUnitFacing(u)
    local real ux = GetUnitX(u)
    local real uy = GetUnitY(u)
    local group g = CreateGroup()
    local real x = ux+150.0*Cos(face*bj_DEGTORAD)
    local real y = uy+150.0*Sin(face*bj_DEGTORAD)
    local boolexpr check = Condition(function FurySlash_Check)
    local unit dmg
    
    call GroupEnumUnitsInRange(g, x, y, 200.0, check)
     loop
     set dmg = FirstOfGroup(g)
     exitwhen dmg == null
      if IsUnitEnemy(dmg, up) then
       call UnitDamageTarget(u, dmg, 150.0, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
       call DestroyEffect(AddSpecialEffect(FurySlash_sfx(), GetUnitX(dmg), GetUnitY(dmg)))
       call GroupRemoveUnit(g, dmg)
      endif
     endloop 
     
     call DestroyGroup(g)
     set g = null 
     set u = null
     set dmg = null
     set up = null  
endfunction

//===========================================================================
function InitTrig_Fury_Slash takes nothing returns nothing
    set gg_trg_Fury_Slash = CreateTrigger(  )
    call Preload(FurySlash_sfx())
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fury_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Fury_Slash, Condition( function Trig_Fury_Slash_Conditions ) )
    call TriggerAddAction( gg_trg_Fury_Slash, function Trig_Fury_Slash_Actions )
endfunction


Please help, i'd appreciate it :D
11-03-2007, 09:06 PM#2
Salbrismind
Whats "bj_DEGTORAD" ?

Also what happens when the caster is facing north? Does the spell go off but in a different area?
11-03-2007, 11:14 PM#3
Pyrogasm
bj_DEGTORAD is a global variable equal to 0.01745 that can be used to convert an angle measure in degrees to one in radians.

I don't see any errors in the code, so what exactly do you mean by "doesn't work"?
11-04-2007, 12:21 AM#4
Tiku
haha nvm guys, but thanks...
i figured it out, it was the "IsUnitEnemy" part... it was bugged, so i removed it and set a higher range, but a lower radius :D