Problem with "Clock"

Trollvottel

never aging title
Reaction score
262
Ok i tried making a spell named clock. it creates a clock with a pointer turning very fast, slowing down and stopping after a random time...
after that you get the angle and check for the time but my angle values are kind of senseless so i dont know what to do with it....

here is the code:
JASS:
scope Clock



private function TextTagCreate takes string msg, real x, real y returns texttag
    local texttag t = CreateTextTag()
    call SetTextTagText(t, msg, 0.02)
    call SetTextTagColor(t, 255, 255, 255, 255)
    call SetTextTagVisibility(t, true)
    call SetTextTagPos(t, x,y, 40)
    return t
endfunction

private struct Uhr
    lightning pointer
    lightning array pointerpart[3]
    lightning array clockborder[25]
    real angle = 0
    real speed 
    real x
    real y
    texttag array uhrzeit[24]
    unit caster
        static method create takes unit which returns Uhr
            local Uhr init = Uhr.allocate()
            local integer i = 0
            local real tmpx
            local real tmpy
            local real tmp2x
            local real tmp2y
            local integer zeit = 1
            
            set init.speed = GetRandomReal(0.400, 1.00)
            set init.caster = which
            set init.x = GetUnitX(which)
            set init.y = GetUnitY(which)
            loop
                exitwhen i == 24
                
                set init.clockborder<i> = AddLightning(&quot;LEAS&quot;, false, init.x + 380 * Cos( i * 360/24 * bj_DEGTORAD), init.y + 380 * Sin(i * 360/24 * bj_DEGTORAD), init.x + 380 * Cos((i+1) * 360/24 * bj_DEGTORAD), init.y + 380 * Sin((i + 1) * 360/24 * bj_DEGTORAD))
                set i = i + 1
                
            endloop
            set i = 0
            set init.uhrzeit<i> = TextTagCreate(I2S(i), init.x + 400 * Cos((90 + i * 360/24) * bj_DEGTORAD), init.y + 400 * Sin((90 + i * 360/24) * bj_DEGTORAD))
            loop
                exitwhen i == -23
                set i = i - 1
                set zeit = i * -1
                set init.uhrzeit[zeit] = TextTagCreate(I2S(zeit), init.x + 400 * Cos((90 + i * 360/24) * bj_DEGTORAD), init.y + 400 * Sin((90 + i * 360/24) * bj_DEGTORAD))
            endloop
            set tmpx = (init.x + 300 * Cos(init.angle)) - 60 * Cos(init.angle + 90)
            set tmpy = (init.y + 300 * Sin(init.angle)) - 60 * Sin(init.angle + 90)
            set tmp2x = (init.x + 300 * Cos(init.angle)) + 60 * Cos(init.angle + 90)
            set tmp2y = (init.y + 300 * Sin(init.angle)) + 60 * Sin(init.angle + 90)
            
            set init.pointer =  AddLightning(&quot;LEAS&quot;, false, init.x, init.y, init.x + 300 * Cos(init.angle), init.y + 300 * Sin(init.angle))
            
            set init.pointerpart[0] = AddLightning(&quot;LEAS&quot;, false, tmpx, tmpy, tmp2x, tmp2y)
            set init.pointerpart[1] = AddLightning(&quot;LEAS&quot;, false, tmp2x, tmp2y, init.x  + 380 * Cos(init.angle), init.y + 380 * Sin(init.angle))
            set init.pointerpart[2] = AddLightning(&quot;LEAS&quot;, false, tmpx, tmpy,   init.x  + 380 * Cos(init.angle), init.y + 380 * Sin(init.angle))
            
            
            
            return init
        endmethod
        
        method moveit takes nothing returns nothing
            local real tmpx
            local real tmpy
            local real tmp2x
            local real tmp2y
            
            set this.angle = this.angle - this.speed
            set this.speed = this.speed - 0.0045
            if this.angle &lt;= -360 then 
                set this.angle = 0
            endif
            set tmpx = (this.x + 300 * Cos(this.angle)) - 30 * Cos(this.angle + 80)
            set tmpy = (this.y + 300 * Sin(this.angle)) - 30 * Sin(this.angle + 80)
            set tmp2x = (this.x + 300 * Cos(this.angle)) + 30 * Cos(this.angle + 80)
            set tmp2y = (this.y + 300 * Sin(this.angle)) + 30 * Sin(this.angle + 80)
            
            call MoveLightning(this.pointer, false, this.x, this.y, this.x + 300 * Cos(this.angle), this.y + 300 * Sin(this.angle))
            call MoveLightning(this.pointerpart[0], false, tmpx, tmpy, tmp2x, tmp2y)
            call MoveLightning(this.pointerpart[1], false, tmp2x, tmp2y, this.x  + 380 * Cos(this.angle), this.y + 380 * Sin(this.angle))
            call MoveLightning(this.pointerpart[2], false, tmpx, tmpy,   this.x  + 380 * Cos(this.angle), this.y + 380 * Sin(this.angle))
        endmethod
        
        method onDestroy takes nothing returns nothing
            call DestroyLightning(this.pointerpart[0])
            call DestroyLightning(this.pointerpart[1])
            call DestroyLightning(this.pointerpart[2])
            call DestroyLightning(this.pointer)
        endmethod
        
endstruct


private function Conditions takes nothing returns boolean
    return true
endfunction

private function Periodic takes nothing returns boolean
    local Uhr dat = TT_GetData()
    call dat. moveit()
    if dat.speed &lt;= 0 then
        call BJDebugMsg(R2S(dat.angle ))
        return true
    endif
    return false
endfunction

private function Actions takes nothing returns nothing
    local Uhr dat = Uhr.create(GetTriggerUnit())
    call TT_Start( function Periodic, dat)
endfunction

//===========================================================================
public function InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction( t, function Actions )
endfunction

endscope
</i></i>

how it looks:
neubitmapda2.jpg
 

Hatebreeder

So many apples
Reaction score
381
So you want to check the Angles?
Just make a loop and do this:
JASS:
set Angles = 23
set TimerAngle = 360/Angles
set Random = RandomInt(0,23)
loop
exitwhen Count &gt;= Random
set TimerAngleX = GetLocationX(...) + dist * Cos(TimerAngle * Count * bj_DEGTORAD)
set TimerAngleY = GetLocationY(...) + dist * Sin(TimerAngle * Count * bj_DEGTORAD)
set Count = Count + 1
// Do your Actions
endloop
if Count = 1 then
//Do Actions
elseif Count = 2 then
//Do Action
...
elseif Count = 23 then
//Do Action


You have to check all Angles with an If then else Statement, depending on what you want to do.

*EDIT: BTW; the Clock look really Sexy ^^
 

Trollvottel

never aging title
Reaction score
262
this wont work really because the pointer stops in a random direction on a letter and it should fit with the time....
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top