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

How to make a spiral?

Status
Not open for further replies.
Level 26
Joined
Mar 19, 2008
Messages
3,140
Yeah there is a little mistake probably:
  • Set StartPoint = (StartPoint offset by 400.00 towards ((Real((Integer A))) x (360.00 / 20.00)) degrees)
  • Set StartPoint = (StartPoint offset by 400.00 towards ((Real((Integer A))) x (180.00 + (360.00 / 20.00))) degrees)
Since at first he sets the StartPoint, and then creates another one on the opposite side since '(180.00 + (360.00 / 20.00))' means exactly opposite side for given angle (360.00 / 20.00).

Meaby I'm wrong, but shouldnt that be like this?
  • Set StartPoint = (StartPoint offset by 400.00 towards ((Real((Integer A))) x (360.00 / 20.00)) degrees)
  • Set EndPoint = (StartPoint offset by 400.00 towards ((Real((Integer A))) x (180.00 + (360.00 / 20.00))) degrees)
Here: distance between those 2 points is diameter, while distance between them / 2 = radius.
 
Level 13
Joined
Oct 25, 2009
Messages
995
It doesn't work also(Holy shit,after i changed it turn into more suck.)
EDIT: I also working at the wheel turning,but it won't turn.
  • For each (Integer A) from 1 to 5, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 1 to 3, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Lightning_Dummy for (Owner of LC_Caster[LC_IndexLoop]) at (LC_TargetPoint[LC_IndexLoop] offset by (100.00 + (8.00 x (Real((Integer A))))) towards (((360.00 / 3.00) x (Real((Integer B)))) + (6.00 x (Real((Integer A))))) degrees) facing LC_TargetPoint[LC_IndexLoop]
          • Unit - Add a 0.01 second Generic expiration timer to (Last created unit)
it cause lag -.-
LC_TargetPoint is the target point of ability being casted.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
This should do the trick...

JASS:
scope Wheel initializer init

globals
    private constant integer       SPELLID = 'AEfk'
    private constant integer       DUMMYID = 'h000'
    private constant real             LIFE = 10
    private constant real   ROTATIONSPEED1 = 2.
    private constant real   ROTATIONSPEED2 = 2.
    private constant real           OFFSET = 200.
    private constant real       TIMERSPEED = 0.03125
    private constant string      LIGHTNING = "DRAL"
    private constant hashtable        HASH = InitHashtable()
endglobals

private struct WWheel
    unit caster
    unit dummy1
    unit dummy2
    real angle1
    real angle2
    real x
    real y
    lightning lig1
    lightning lig2
    
    static method onMove takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local thistype this = LoadInteger(HASH, GetHandleId(t), 1)
        set .angle1 = .angle1+ROTATIONSPEED1*bj_DEGTORAD
        call SetUnitX(.dummy1, .x+OFFSET*Cos(.angle1))
        call SetUnitY(.dummy1, .y+OFFSET*Sin(.angle1))
        set .angle2 = .angle2+ROTATIONSPEED2
        call SetUnitX(.dummy2, GetUnitX(.dummy1)+OFFSET*Cos(.angle2))
        call SetUnitY(.dummy2, GetUnitY(.dummy1)+OFFSET*Sin(.angle2))
        call MoveLightningEx(.lig2, true, GetUnitX(.dummy1), GetUnitY(.dummy1), 100, GetUnitX(.dummy2), GetUnitY(.dummy2), 100)
        if GetWidgetLife(.dummy1) > 0.405 and GetWidgetLife(.dummy2) > 0.405 then
        else
            call PauseTimer(t)
            call DestroyTimer(t)
            call DestroyLightning(.lig1)
            call DestroyLightning(.lig2)
        endif
        set t = null
    endmethod
    
    static method onCreate takes unit u returns thistype
        local thistype this = thistype.create()
        local timer t = CreateTimer()
        local real xx
        local real yy
        local real dist
        set .caster = u
        set .x = GetUnitX(u)
        set .y = GetUnitY(u)
        set .dummy1 = CreateUnit(GetTriggerPlayer(), DUMMYID, .x, .y, 0)
        set .dummy2 = CreateUnit(GetTriggerPlayer(), DUMMYID, .x, .y, 0)
        set .angle1 = 0
        set .angle2 = 0
        set .lig1 = AddLightning(LIGHTNING, true, GetUnitX(.dummy1), GetUnitY(.dummy1), GetUnitX(.dummy2), GetUnitY(.dummy2))
        set .lig2 = AddLightning(LIGHTNING, true, GetUnitX(.dummy1), GetUnitY(.dummy1), GetUnitX(.dummy2), GetUnitY(.dummy2))
        call UnitApplyTimedLife(.dummy1, 'BTLF', LIFE)
        call UnitApplyTimedLife(.dummy2, 'BTLF', LIFE)
        call SaveInteger(HASH, GetHandleId(t), 1, this)
        call TimerStart(t, TIMERSPEED, true, function thistype.onMove)
        return this
    endmethod
endstruct

private function CAST takes nothing returns boolean
    if GetSpellAbilityId()==SPELLID then  
        call WWheel.onCreate(GetTriggerUnit())
    endif
    return false
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()          
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(t, Condition(function CAST))
    set t = null
endfunction

endscope
 
Status
Not open for further replies.
Top