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.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top