HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Sin + Cos help

01-17-2007, 09:34 PM#1
Joker
i made a trigger so that it would far sight the unit target, then 3 more far sights that are in the same direction as the unit is facing. heres an example


but my trigger it does this :(


it is offset by a lot and it does it at the same place too. whats wrong?

Collapse JASS:
function Trig_Heavens_Sight_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A005'
endfunction

function Trig_Heavens_Sight_Actions takes nothing returns nothing
    local unit a = GetSpellAbilityUnit()
    local unit b
    local integer c = 0
    local integer d = 0
    loop
        exitwhen d == 4
        set b = CreateUnit( GetOwningPlayer(a), 'nzin', GetUnitX(a), GetUnitY(a), 0)
        call UnitAddAbility( b, 'A008')
        call SetUnitAbilityLevel(b, 'A008', GetUnitAbilityLevel(a, 'A005') )
        call IssuePointOrder( b, "farsight", Cos(GetUnitFacing(a) * bj_DEGTORAD) + c, Sin(GetUnitFacing(a) * bj_DEGTORAD) + c )
        set c = c + GetUnitAbilityLevel(a, 'A005') * 100 + 1000
        set d = d + 1
    endloop
    call UnitRemoveAbility( b, 'A008' )
    call RemoveUnit(b)
    set a = null
    set b = null
endfunction

//===========================================================================
function InitTrig_Heavens_Sight takes nothing returns nothing
    set gg_trg_Heavens_Sight = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Heavens_Sight, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Heavens_Sight, Condition( function Trig_Heavens_Sight_Conditions ) )
    call TriggerAddAction( gg_trg_Heavens_Sight, function Trig_Heavens_Sight_Actions )
endfunction
01-17-2007, 09:53 PM#2
Taur
I suggest instead of using sin or cos you use polar offsets, set the direction to the facing of the unit & use the distacnes to space out your farsights.
01-17-2007, 10:39 PM#3
Joker
how do i do that?
01-18-2007, 12:27 AM#4
Naakaloh
call IssuePointOrder( b, "farsight", Cos(GetUnitFacing(a) * bj_DEGTORAD) + c, Sin(GetUnitFacing(a) * bj_DEGTORAD) + c )
You probably want to multiply by c instead of adding.
01-18-2007, 12:37 AM#5
The_AwaKening
You are creating 4 dummy units but only removing the last one. You would need to remove the units in the loop, or even better, use an expiration timer on them instead.

Try this:

Collapse JASS:
function Trig_Heavens_Sight_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A005'
endfunction

function Trig_Heavens_Sight_Actions takes nothing returns nothing
    local unit a = GetSpellAbilityUnit()
    local unit b
    local integer c = 0
    local integer d = 0
    local real x
    local real y
    loop
        exitwhen d == 4
        set b = CreateUnit( GetOwningPlayer(a), 'nzin', GetUnitX(a), GetUnitY(a), 0)
        call UnitApplyTimedLife(b,'BTLF',1) 
        call UnitAddAbility( b, 'A008')
        call SetUnitAbilityLevel(b, 'A008', GetUnitAbilityLevel(a, 'A005') )
        set x = GetUnitX(a)+c*Cos(GetUnitFacing(a)*bj_DEGTORAD)
        set y = GetUnitY(a)+c*Sin(GetUnitFacing(a)*bj_DEGTORAD)
        call IssuePointOrder(b,"farsight",x,y)
        set c = c + GetUnitAbilityLevel(a, 'A005') * 100 + 1000
        set d = d + 1
    endloop
    set a = null
    set b = null
endfunction

//===========================================================================
function InitTrig_Heavens_Sight takes nothing returns nothing
    set gg_trg_Heavens_Sight = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Heavens_Sight, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Heavens_Sight, Condition( function Trig_Heavens_Sight_Conditions ) )
    call TriggerAddAction( gg_trg_Heavens_Sight, function Trig_Heavens_Sight_Actions )
endfunction

I didn't test, but you may want to change your method of increasing c, depending on how you want them spread out. Still should work though.
01-18-2007, 12:40 AM#6
Pyrogasm
Collapse JASS:
    set b = CreateUnit( GetOwningPlayer(a), 'nzin', GetUnitX(a), GetUnitY(a), 0)
    call UnitApplyTimedLife(b,'BTLF',1)
    set udg_Temp_Point[1] = GetUnitLoc(GetSpellTargetUnit())
    set udg_Temp_Point[2] = PolarProjectionBJ(udg_Temp_Point[1], 100.00, GetUnitFacing(GetSpellTargetUnit()))
    loop
        exitwhen d == 4
        set udg_Temp_Point[3] = PolarProjectionBJ(udg_Temp_Point[1], ( ( 1100.00 * I2R(d) ) ), AngleBetweenPoints(udg_Temp_Point[1], udg_Temp_Point[2]))
        call IssuePointOrder( b, "farsight", udg_Temp_Point[3] )
        call RemoveLocation( udg_Temp_Point[3] )
        set d = d + 1
    endloop
    call RemoveLocation( udg_Temp_Point[1] )
    call RemoveLocation( udg_Temp_Point[2] )
Might that work? Sorry about those BJ's... I'm a GUI guy, and that's converted to custom text from a GUI trigger ><

EDIT: Damn you The_AwaKening... beat me to it.
01-18-2007, 11:37 PM#7
Joker
Lol its ok pyro. +rep to both :) ty
01-19-2007, 12:50 AM#8
Joker
Quote:
Originally Posted by The_AwaKening
You are creating 4 dummy units but only removing the last one. You would need to remove the units in the loop, or even better, use an expiration timer on them instead.

Try this:

Collapse JASS:
function Trig_Heavens_Sight_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A005'
endfunction

function Trig_Heavens_Sight_Actions takes nothing returns nothing
    local unit a = GetSpellAbilityUnit()
    local unit b
    local integer c = 0
    local integer d = 0
    local real x
    local real y
    loop
        exitwhen d == 4
        set b = CreateUnit( GetOwningPlayer(a), 'nzin', GetUnitX(a), GetUnitY(a), 0)
        call UnitApplyTimedLife(b,'BTLF',1) 
        call UnitAddAbility( b, 'A008')
        call SetUnitAbilityLevel(b, 'A008', GetUnitAbilityLevel(a, 'A005') )
        set x = GetUnitX(a)+c*Cos(GetUnitFacing(a)*bj_DEGTORAD)
        set y = GetUnitY(a)+c*Sin(GetUnitFacing(a)*bj_DEGTORAD)
        call IssuePointOrder(b,"farsight",x,y)
        set c = c + GetUnitAbilityLevel(a, 'A005') * 100 + 1000
        set d = d + 1
    endloop
    set a = null
    set b = null
endfunction

//===========================================================================
function InitTrig_Heavens_Sight takes nothing returns nothing
    set gg_trg_Heavens_Sight = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Heavens_Sight, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Heavens_Sight, Condition( function Trig_Heavens_Sight_Conditions ) )
    call TriggerAddAction( gg_trg_Heavens_Sight, function Trig_Heavens_Sight_Actions )
endfunction

I didn't test, but you may want to change your method of increasing c, depending on how you want them spread out. Still should work though.
My way of spreading out works fine and so does your trigger :) just tested.
01-19-2007, 01:20 AM#9
Pyrogasm
I tried