New spell, and more trouble

Komaqtion

You can change this now in User CP.
Reaction score
469
Hi!
Since my last/first spell now finally got approved (Thanks Andrewgosu !!! :D) I thought i could start on my next one :eek:

But, right away i got problems... Here's the current trigger:
JASS:
scope SearingDash initializer init

globals
    private constant integer ABIL_ID = 'A000'
    private constant string EFFECT_1 = "Environment\\SmallBuildingFire\\SmallBuildingFire2.mdl"
endglobals

globals
endglobals

private struct Data
    effect e
    real x
    real y
    real speed
    unit caster
    timer t
    boolean b = false
    static method create takes unit u returns Data
        local Data d = Data.allocate()
        set d.caster = u
        return d
    endmethod
    
    method onDestroy takes nothing returns nothing
        local Data d = Data.allocate()
        call DestroyEffect(.e)
    endmethod
endstruct

private function Spell_Check takes nothing returns boolean
    return GetSpellAbilityId() == ABIL_ID
endfunction

private function Periodic takes nothing returns boolean
    local Data d = KT_GetData()
    set d.t = NewTimer()
    set d.x = GetUnitX(d.caster)
    set d.y = GetUnitY(d.caster)
    set d.e = AddSpecialEffect(EFFECT_1,d.x,d.y)
    return d.b
endfunction

private function TimerStop takes nothing returns nothing
    local Data D = KT_GetData()
    set D.b = true
    call SetUnitMoveSpeed(D.caster, D.speed)
    call SetUnitPathing(D.caster,true)
    call SetUnitVertexColor(D.caster,255,255,255,100)
    call D.destroy()
endfunction

private function Spell takes nothing returns nothing
    local Data D = Data.create(GetTriggerUnit())
    set D.t = NewTimer()
    set D.x = GetUnitX(D.caster)
    set D.y = GetUnitY(D.caster)
    set D.speed = GetUnitMoveSpeed(D.caster)
    call SetUnitMoveSpeed(D.caster, 522)
    call SetUnitPathing(D.caster,false)
    call SetUnitVertexColor(D.caster,255,255,255,85)
    call KT_Add(function Periodic, D, 0.1)
    call TimerStart(D.t,5,false,function TimerStop)
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 Spell_Check))
    call TriggerAddAction(t, function Spell)
endfunction

endscope


This spell is supposed to create effects every 0.05 seconds at the caster (It's not nearly finished so haven't gotten to the point of destroying the effects or the data or anything yet).

This it now does, though the effects never gets destroyed and the other effects, like the movement speed and stuff never gets set back either :(

What's wrong (If you checked my other spell you know I'm only learning vJASS atm, so this is what i come up with XD)
 

RaiJin

New Member
Reaction score
40
JASS:
private function TimerStop takes nothing returns nothing
    local Data D = KT_GetData()
    set D.b = true
    call SetUnitMoveSpeed(D.caster, D.speed)
    call SetUnitPathing(D.caster,true)
    call SetUnitVertexColor(D.caster,255,255,255,100)
    call D.destroy()
endfunction


this won't work because you didn't use

KT_Add function so just use KT_Add instead of the timer, theres no data attached to that timer
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
You have 2 selections.

1) use CreateTimer(), SetTimerData(), GetTimerData(), PauseTimer(), DestroyTimer()
2) use KT_Add(), KT_GetData()//The period should be multiplier of 0.00125 or it will not accurate.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Ok, i now have this:
JASS:
scope SearingDash initializer init

globals
    private constant integer ABIL_ID = 'A000'
    private constant string EFFECT_1 = "Environment\\SmallBuildingFire\\SmallBuildingFire2.mdl"
endglobals

globals
endglobals

private struct Data
    effect e
    real x
    real y
    real speed
    real time = 1
    unit caster
    timer t
    boolean b = false
    static method create takes unit u returns Data
        local Data d = Data.allocate()
        set d.caster = u
        return d
    endmethod
    
    method onDestroy takes nothing returns nothing
        local Data d = Data.allocate()
        call DestroyEffect(d.e)
        call SetUnitMoveSpeed(d.caster, d.speed)
        call SetUnitPathing(d.caster,true)
        call SetUnitVertexColor(d.caster,255,255,255,100)
    endmethod
endstruct

private function Spell_Check takes nothing returns boolean
    return GetSpellAbilityId() == ABIL_ID
endfunction

private function Periodic takes nothing returns boolean
    local Data d = KT_GetData()
    if d.time < 4.9 then
        set d.time = d.time + 0.1
        set d.x = GetUnitX(d.caster)
        set d.y = GetUnitY(d.caster)
        set d.e = AddSpecialEffect(EFFECT_1,d.x,d.y)
        set d.b = false
    elseif d.time >= 4.9 then
        call SetUnitMoveSpeed(d.caster, d.speed)
        call SetUnitPathing(d.caster,true)
        call SetUnitVertexColor(d.caster,255,255,255,100)
        set d.b = true
        call d.destroy()
    endif
    return d.b
endfunction

private function Spell takes nothing returns nothing
    local Data D = Data.create(GetTriggerUnit())
    set D.t = NewTimer()
    set D.x = GetUnitX(D.caster)
    set D.y = GetUnitY(D.caster)
    set D.speed = GetUnitMoveSpeed(D.caster)
    call SetUnitMoveSpeed(D.caster, 522)
    call SetUnitPathing(D.caster,false)
    call SetUnitVertexColor(D.caster,255,255,255,85)
    call KT_Add(function Periodic, D, 0.1)
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 Spell_Check))
    call TriggerAddAction(t, function Spell)
endfunction

endscope


But it still doesn't destroy the effects, and it only resets the movement speed, not the color or the pathing :(

I kinda understand why the effects aren't destroyed (d.e gets overwritten) so how can i implement an easy and small timedeffect function here ??? :S
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
JASS:
    method onDestroy takes nothing returns nothing
        local Data d = Data.allocate()

You can remove the allocation there. It isn't needed.
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
I think you need to use an effect array. Also, if you're submitting this as a spell it needs to be more configurable, i.e. the user must be able to change how long the spell lasts and the period. I did this for you :D

Tell me if this works, I couldn't compile it since I don't know what systems you are using.

JASS:
scope SearingDash initializer init

globals
    private constant integer ABIL_ID = 'A000'
    private constant string EFFECT_1 = "Environment\\SmallBuildingFire\\SmallBuildingFire2.mdl"
    private constant real DURATION = 5 //How long the spell lasts
    private constant real PERIOD = .1 //Time between 'ticks'
endglobals


//DO NOT TOUCH THIS VARIABLE BLOCK <-- put a message in there when you submit this spell or whatever
globals
    private constant ARRAY_SIZE = DURATION / PERIOD //DONT TOUCH! This is the size of the effect array!
endglobals

private struct Data
    effect array e[ARRAY_SIZE]
    real x
    real y
    real speed
    real time = 1
    unit caster
    timer t
    integer index = 0//this is for the effect array
    static method create takes unit u returns Data
        local Data d = Data.allocate()
        set d.caster = u
        set d.t = NewTimer()
        set d.x = GetUnitX(u)
        set d.y = GetUnitY(u)
        set d.speed = GetUnitMoveSpeed(u)
        return d
    endmethod
    
    method onDestroy takes nothing returns nothing
        //local Data d = Data.allocate() T.S.E said this isn't needed, I trust the noodle man. I personally don't use onDestroy much myself.
        //call DestroyEffect(d.e) We'll need a loop since it is an array!
        loop
            call DestroyEffect(d.e[d.index])
            exitwhen d.index <= 0
            set d.index = d.index-1 //Do you see what I did there? <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite12" alt="o_O" title="Er... what?    o_O" loading="lazy" data-shortname="o_O" />
        endloop            
        call SetUnitMoveSpeed(d.caster, d.speed)
        call SetUnitPathing(d.caster,true)
        call SetUnitVertexColor(d.caster,255,255,255,100)
    endmethod
endstruct

private function Spell_Check takes nothing returns boolean
    return GetSpellAbilityId() == ABIL_ID
endfunction

private function Periodic takes nothing returns boolean
    local Data d = KT_GetData()
    if d.time &lt; (DURATION - PERIOD) then
        set d.time = d.time + PERIOD
        set d.x = GetUnitX(d.caster)
        set d.y = GetUnitY(d.caster)
        set d.e[d.index] = AddSpecialEffect(EFFECT_1,d.x,d.y)
        //set d.b = false //Why comment this out? It isn&#039;t even needed!
        set d.index = d.index+1
        return false
    else //Why the elseif? If it isn&#039;t less than, it must be greater than or equal to!
        call SetUnitMoveSpeed(d.caster, d.speed)
        call SetUnitPathing(d.caster,true)
        call SetUnitVertexColor(d.caster,255,255,255,100)
        call d.destroy()
        return true
    endif
endfunction

private function Spell takes nothing returns nothing
    local Data D = Data.create(GetTriggerUnit())
    call SetUnitMoveSpeed(D.caster, 522)
    call SetUnitPathing(D.caster,false)
    call SetUnitVertexColor(D.caster,255,255,255,85)
    call KT_Add(function Periodic, D, PERIOID)
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 Spell_Check))
    call TriggerAddAction(t, function Spell)
endfunction
endscope
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Ok, after mixing around a bit ... (It didn't compile right away, nor does it now) This is how it looks atm:
JASS:
scope SearingDash initializer init

globals
    private constant integer ABIL_ID = &#039;A000&#039;
    private constant string EFFECT_1 = &quot;Environment\\SmallBuildingFire\\SmallBuildingFire2.mdl&quot;
    private constant real DURATION = 5 //How long the spell lasts
    private constant real PERIOD = .1 //Time between &#039;ticks&#039;
endglobals


//DO NOT TOUCH THIS VARIABLE BLOCK &lt;-- put a message in there when you submit this spell or whatever
globals
    private constant integer ARRAY_SIZE = DURATION / PERIOD //DONT TOUCH! This is the size of the effect array!
endglobals

private struct Data
    effect array e[ARRAY_SIZE]
    real x
    real y
    real speed
    real time = 1
    unit caster
    timer t
    integer index = 0
    static method create takes unit u returns Data
        local Data d = Data.allocate()
        set d.caster = u
        set d.t = NewTimer()
        set d.x = GetUnitX(u)
        set d.y = GetUnitY(u)
        set d.speed = GetUnitMoveSpeed(u)
        return d
    endmethod
    
    method onDestroy takes nothing returns nothing
        loop
            call DestroyEffect(.e[.index])
            exitwhen .index &lt;= 0
            set .index = .index-1
        endloop            
        call SetUnitMoveSpeed(.caster, .speed)
        call SetUnitPathing(.caster,true)
        call SetUnitVertexColor(.caster,255,255,255,100)
    endmethod
endstruct

private function Spell_Check takes nothing returns boolean
    return GetSpellAbilityId() == ABIL_ID
endfunction

private function Periodic takes nothing returns boolean
    local Data d = KT_GetData()
    if d.time &lt; DURATION - PERIOD then
        set d.time = d.time + PERIOD
        set d.x = GetUnitX(d.caster)
        set d.y = GetUnitY(d.caster)
        set d.e[d.index] = AddSpecialEffect(EFFECT_1,d.x,d.y)
        set d.index = d.index+1
        return false
    else
        call SetUnitMoveSpeed(d.caster, d.speed)
        call SetUnitPathing(d.caster,true)
        call SetUnitVertexColor(d.caster,255,255,255,100)
        call d.destroy()
        return true
    endif
endfunction

private function Spell takes nothing returns nothing
    local Data D = Data.create(GetTriggerUnit())
    call SetUnitMoveSpeed(D.caster, 522)
    call SetUnitPathing(D.caster,false)
    call SetUnitVertexColor(D.caster,255,255,255,85)
    call KT_Add(function Periodic, D, PERIOD)
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 Spell_Check))
    call TriggerAddAction(t, function Spell)
endfunction
endscope


Though there is only 1 error left:

JASS:
    effect array e[ARRAY_SIZE]


Error: Line 467: Wrong [size] definition.

:(

I remember i got this error on my last spell, though can't remember how I fixed it XD

Note: And Frozenhelfir... I know I need more constants and stuff like that, but this isn't nearly finished atm, so I'll get to that later :D But thanks anyway :thup:
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
put an R2I() around the DURATION/PERIOD and then add 1
R2I(DURATION/PERIOD) + 1 Sorry about it not compiling :( I couldn't test it because you have some custom functions in there.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Nope, sorry... Still doesn't work :( If I just could remember how I fixed it last time :S

And, for your information, I'm using KT2 for some extra functions :D
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
I just compiled and realized how many stupid mistakes I made :p

JASS:
effect array e[R2I(5/.1)]


That doesn't even work. It looks like you can only put a straight up number in the brackets. I'm going to go download the newest JassHelper and see if that will work. If it doesn't the method may be a bit ugly but meh :/

EDIT: Just out of curiosity, do these effects need to show until the spell is done? And the new JassHelper can only put numbers in there too. If it needs to be an array, you can either put in 8190 (max size) or have the user do the math. I'm not sure if 8190 array size will lag or not, but it is probably better than having the user do the math.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
So there is no way of doing this then ??? Anyone knows ??? :S It's just much easier, both for me and for the users :D
 

roXplosive

New Member
Reaction score
15
As far as I know the arrays need not be initialized . They always get the maximum size of 8190 and if you define them in globals the specified size is initialized to 0 or NULL . For locals just use the goddamn array as it is . O defined 1 with just

local unit array spirits

and got no syntax error . Try this one .
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
Arrays are different in a struct. JassHelper manual says they need a size when created.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Yeah, struct members need to have initialized arrays :( I know that :D

But still, any ideas to the problem ??? :S
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
just make it 8190, or something high like 3000. But you forgot to answer my question: does the effect need to stay around until the ability finishes? Tell me if this gives the desired outcome:

JASS:
scope SearingDash initializer init

globals
    private constant integer ABIL_ID = &#039;A000&#039;
    private constant string EFFECT_1 = &quot;Environment\\SmallBuildingFire\\SmallBuildingFire2.mdl&quot;
    private constant real DURATION = 5 //How long the spell lasts
    private constant real PERIOD = .1 //Time between &#039;ticks&#039;
endglobals

private struct Data
    effect e
    real x
    real y
    real speed
    real time = 1
    unit caster
    timer t
    static method create takes unit u returns Data
        local Data d = Data.allocate()
        set d.caster = u
        set d.t = NewTimer()
        set d.x = GetUnitX(u)
        set d.y = GetUnitY(u)
        set d.speed = GetUnitMoveSpeed(u)
        return d
    endmethod
    
    method onDestroy takes nothing returns nothing
        call DestroyEffect(.e)           
        call SetUnitMoveSpeed(.caster, .speed)
        call SetUnitPathing(.caster,true)
        call SetUnitVertexColor(.caster,255,255,255,100)
    endmethod
endstruct

private function Spell_Check takes nothing returns boolean
    return GetSpellAbilityId() == ABIL_ID
endfunction

private function Periodic takes nothing returns boolean
    local Data d = KT_GetData()
    if d.time &lt; DURATION - PERIOD then
        set d.time = d.time + PERIOD
        set d.x = GetUnitX(d.caster)
        set d.y = GetUnitY(d.caster)
        call DestroyEffect(d.e)
        set d.e = AddSpecialEffect(EFFECT_1,d.x,d.y)
        return false
    else
        call SetUnitMoveSpeed(d.caster, d.speed)
        call SetUnitPathing(d.caster,true)
        call SetUnitVertexColor(d.caster,255,255,255,100)
        call d.destroy()
        return true
    endif
endfunction

private function Spell takes nothing returns nothing
    local Data D = Data.create(GetTriggerUnit())
    call SetUnitMoveSpeed(D.caster, 522)
    call SetUnitPathing(D.caster,false)
    call SetUnitVertexColor(D.caster,255,255,255,85)
    call KT_Add(function Periodic, D, PERIOD)
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 Spell_Check))
    call TriggerAddAction(t, function Spell)
endfunction
endscope
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Yeah it works :D But I'd at least like the effects to stand longer than 0.1 seconds :(

And I'd also like to decrease the period, and creating more effect since it looks a bit shabby with so little effect XD Any ideas ??? :S

(And I'm no longer using TimerUtils, so no NewTimer() anymore :D)
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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 The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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