System Fountain

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Do you love fountain?
Some may be say no, but for me, yes. :)

Well..
fountainw.jpg

JASS:
             _________   _______   _     _   ___    __   _______     ___      ______   ___    __  
  |  ______| |  ___  | | |   | | |   \  |  | |       |   / _ \    |__  __| |   \  |  | 
  | |____    | |   | | | |   | | |  | \ |  | |__   __|  / /_\ \     |  |   |  | \ |  | 
  |  ____|   | |   | | | |   | | |  |\ \|  |    | |    / _____ \    |  |   |  |\ \|  |  
  | |        | |___| | \ \___/ / |  | \ \  |    | |   / /     \ \  _|  |_  |  | \ \  |    
  |_|        |_______|  \_____/  |__|  \__ |    |_|  /_/       \_\|______| |__|  \__ |    
  
  *Jass tag is not working well, so the big "FOUNTAIN" does not display properly.

  V1 by kingking
  
  This system allows you to create mass types fountains.
  
  How to use?
  System provides 'fountain' type variable
  
  List of Functions provided :
  CreateFountain() -> fountain
  SetFountainModel(fountain, string path of model)
  SetFountainPos(fountain, real x, real y)
  SetFountainJumpSpeed(fountain, real spd)
  SetFountainJumpRange(fountain,real range)
  SetFountainAngle(fountain, real starting angle)
  SetFountainSpinSpeed(fountain, real spin speed) Put 0 if you dont want it spins.
  SetFountainHeight(fountain, real max height)
  FountainStart(fountain)
  DestroyFountain(fountain)


Library Here :
JASS:
library Fountain
   
    globals
        private constant real FOUNTAIN_PERIOD = .5
        private constant real DUMMY_SLIDE_PERIOD = .03125
        private constant integer DUMMY_ID = 'h000'
    endglobals

    private struct DummyData
        real x
        real y
        real spd
        real angle
        real cos
        real sin
        real totaldis
        real dis
        real height
        effect e
        unit dummy
        integer ticks
        
        method onDestroy takes nothing returns nothing
            set .dis = 0.
            call DestroyEffect(.e)
            call KillUnit(.dummy)
        endmethod
    endstruct
    
    struct fountain
        real x
        real y
        real spd
        real angle
        real anglerate
        real height
        string path
        boolean stop = false
        integer ticks
        
        method onDestroy takes nothing returns nothing
            set .x = 0.
            set .y = 0.
            set .spd = 0.
            set .angle = 0.
            set .anglerate = 0.
            set .path = null
            set .stop = false
            set .ticks = 0
            set .height = 0.
        endmethod
    endstruct
    
    globals//Struct Stack?
        private timer FountainTimer = CreateTimer()
        private fountain array FountainStack
        private integer FountainCount = 0
        private timer SlideTimer = CreateTimer()
        private DummyData array SlideStack
        private integer SlideCount = 0
    endglobals

    globals//locals
        private integer FountainLoop
        private fountain CurrentFountain
        private integer SlideLoop
        private DummyData CurrentDummy
        private DummyData NewDummy
    endglobals

    private function SlideDummies takes nothing returns nothing
        set SlideLoop = SlideCount
        loop
        exitwhen SlideLoop == 0
            set CurrentDummy = SlideStack[SlideLoop]
            if CurrentDummy.ticks > 0 then
                set CurrentDummy.ticks = CurrentDummy.ticks - 1
                set CurrentDummy.x = CurrentDummy.x + CurrentDummy.cos
                set CurrentDummy.y = CurrentDummy.y + CurrentDummy.sin
                set CurrentDummy.dis = CurrentDummy.dis + CurrentDummy.spd
                call SetUnitPosition(CurrentDummy.dummy,CurrentDummy.x,CurrentDummy.y)
                call SetUnitFlyHeight(CurrentDummy.dummy,4 * CurrentDummy.height * CurrentDummy.dis * (CurrentDummy.totaldis - CurrentDummy.dis) / (CurrentDummy.totaldis * CurrentDummy.totaldis),0.)
            else
                call CurrentDummy.destroy()
                set SlideStack[SlideLoop] = SlideStack[SlideCount]
                set SlideCount = SlideCount - 1
            endif
            set SlideLoop = SlideLoop - 1
        endloop
        if SlideCount == 0 then
            call PauseTimer(SlideTimer)
        endif
    endfunction
    
    private function CreateDummies takes nothing returns nothing
        set FountainLoop = FountainCount
        loop
        exitwhen FountainLoop == 0
            set CurrentFountain = FountainStack[FountainLoop]
            set CurrentFountain.angle = CurrentFountain.angle + CurrentFountain.anglerate
            if CurrentFountain.angle > 360. then
                set CurrentFountain.angle = 0.
            endif
            if not CurrentFountain.stop then
                set NewDummy = DummyData.create()
                set NewDummy.x = CurrentFountain.x
                set NewDummy.y = CurrentFountain.y
                set NewDummy.spd = CurrentFountain.spd
                set NewDummy.angle = CurrentFountain.angle
                set NewDummy.cos = NewDummy.spd * Cos(NewDummy.angle * .0175)
                set NewDummy.sin = NewDummy.spd * Sin(NewDummy.angle * .0175)
                set NewDummy.ticks = CurrentFountain.ticks
                set NewDummy.totaldis = NewDummy.spd * NewDummy.ticks
                set NewDummy.height = CurrentFountain.height
                set NewDummy.dummy = CreateUnit(Player(15),DUMMY_ID,NewDummy.x,NewDummy.y,NewDummy.angle)
                set NewDummy.e = AddSpecialEffectTarget(CurrentFountain.path,NewDummy.dummy,"origin")
                set SlideCount = SlideCount + 1
                set SlideStack[SlideCount] = NewDummy
                if SlideCount == 1 then
                    call TimerStart(SlideTimer,DUMMY_SLIDE_PERIOD,true,function SlideDummies)
                endif
            else
                call CurrentFountain.destroy()
                set FountainStack[FountainLoop] = FountainStack[FountainCount]
                set FountainCount = FountainCount - 1
            endif
            set FountainLoop = FountainLoop - 1
        endloop
        if FountainCount == 0 then
            call PauseTimer(FountainTimer)
        endif
    endfunction
    
    function CreateFountain takes nothing returns fountain
        return fountain.create()
    endfunction
    
    function SetFountainModel takes fountain d, string path returns nothing
        set d.path = path
    endfunction
    
    function SetFountainPos takes fountain d, real x, real y returns nothing
        set d.x = x
        set d.y = y
    endfunction
    
    function SetFountainJumpSpeed takes fountain d, real spd returns nothing
        set d.spd = spd
    endfunction
    
    function SetFountainJumpRange takes fountain d, real range returns nothing
        if d.spd != 0 then //if d.spd = 0, then d.ticks = infinity. <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />
            set d.ticks = R2I(range / d.spd)
        endif
    endfunction
    
    function SetFountainAngle takes fountain d, real angle returns nothing
        set d.angle = angle
    endfunction
    
    function SetFountainSpinSpeed takes fountain d, real spd returns nothing
        set d.anglerate = spd
    endfunction
    
    function SetFountainHeight takes fountain d, real h returns nothing
        set d.height = h
    endfunction
    
    function FountainStart takes fountain d returns nothing
        set FountainCount = FountainCount + 1
        set FountainStack[FountainCount] = d
        if FountainCount == 1 then
            call TimerStart(FountainTimer,FOUNTAIN_PERIOD,true,function CreateDummies)
        endif
    endfunction
    
    function DestroyFountain takes fountain d returns nothing
        set d.stop = true
    endfunction
endlibrary
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Your fountain of fire spell lagged terribly for me, I can only assume this shall do the same.
Do you test the new version? I changed the model... So it will be fine now.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
Your description isn't descriping how this 'fountain' is function.
It is just creating a unit there and eye-candy around them? only?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Quit using that convention without knowing what it means.
And this doesn't seem useful. Am I wrong?

Just some note for myself.
Well, this is quite nice when you use it in RPG IMO.

Why doesn't it heal? o_O
You need to make healing trigger yourself. This system only provide the graphic effect. Adding heal effect will complicating the system. If many of other users demand me for heal effect, I will make an add-on. :D
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top