Spell Mojo Magic

Romek

Super Moderator
Reaction score
964
Maybe because Local handle vars are declared after this?
You should put them into a library.

And put this into a scope for that matter. "Timer" is a common function name.
 

Nexor

...
Reaction score
74
I do have the Local Handle Vars in the map header

Is it a problem that I use the 1.22 patch? :S :O
 

Nexor

...
Reaction score
74
Can you test it?

I can't, I will reinstall warcraft at 1.21 to make it work...

(Please, makers of Grimorie make it work with 1.22 :rolleyes: )
 

Nexor

...
Reaction score
74
I use NewGen but I haven't tried this reinstall-in-other-folder thing, so I try this.
 

Viikuna

No Marlo no game.
Reaction score
265
This spell looks neat. Im starting to like spells which link units and use litghnings. :)

Wouldnt it be better to store your data to struct and use gamecache to transfer only that struct to timer function?

something like this:
JASS:

private struct Data
   unit unit1
   unit unit2
   lightning light
endstruct

private function Timer takes nothing returns nothing
    local timer tim = GetExpiredTimer()
    local Data d = GetHandleInt(tim, "Data")
    // some actions like this:
    call SetUnitX(d.unit1,0.0)
    //...
endfunction

private function Actions takes nothing returns nothing
    local Data d = Data.create()
    local timer tim = CreateTimer()
    set d.unit1 = GetTriggerUnit()
    //...
    call SetHandleInt(tim, "Data", d)
    call TimerStart(tim, TIMER_INT, true, function Timer)
    set t = null
endfunction


Also: There is some nice systems like Vexorians Table and TimerUntils. You should check them out.
http://www.wc3campaigns.net/forums.php
 

Nexor

...
Reaction score
74
What is the best system out there for this spell, I know that some are good for long intervals or for more timers, but I don't know which the best for this is :)
 

Romek

Super Moderator
Reaction score
964
What is the best system out there for this spell, I know that some are good for long intervals or for more timers, but I don't know which the best for this is :)
I recommend ABC for Spells with multiple timers at different frequencies.
TT for spells with all the same frequency.

You could use HSAS or HAIL, which are also very good, but they're harder to use, and the amount of handles in your map effects the performance. You don't know what kind of map will be using your spell! :p
 

Nexor

...
Reaction score
74
There is no descripiton of the usage of ABC, how can I use it, how can I take local variables through functions?
 

Romek

Super Moderator
Reaction score
964
There is no descripiton of the usage of ABC, how can I use it, how can I take local variables through functions?
It says how to use it in the code, in the comments at the top.
There is also a test map if I remember correctly.
 

Viikuna

No Marlo no game.
Reaction score
265
Romek is allways talking about ABC. ABC this, ABC that..

Anyways, ABC is a good system, but there is loads of attachments systems around there. Everybody has their favorite ( I would recommend TimerUtils and Table ), but if you want to find the best one, you need to test them all and see which one you like most. :)

Try these: ABC, TT, TimerUtils, Table, HSAS, HAIL ...

and oh yeh, There is PUI for Unit Indexing too.

EDIT. TT is for low period timers ( like 0.04, 0.03, 0.02 etc.), and its pretty easy to use. So it might work for this spell good.

EDIT2. Handle Vars is nice too, but if you use it, you should only attach structs. ( Check that my previous post )
 

Romek

Super Moderator
Reaction score
964
Romek is allways talking about ABC. ABC this, ABC that..

Only when an attaching system is mentioned, or is a solution to something.
And ABC is one I would recommend as it's easy to use, especially for beginners (I also think it's the most suitable for spells). :p
 

Nexor

...
Reaction score
74
I can't use the solution for using NewGen with patch 1.22, I tried everything, the only one I didn't was the deleting of all Warcraft files and reinstalling it using patch 1.21 a or b. I'll try it next time...
 

Nexor

...
Reaction score
74
BUMP

Spell reworked !

- Now uses ABC instead of HandleVars.
- More configurables.
- Finally working as I wanted it to.
 

Nexor

...
Reaction score
74
I can't use T32 :S
What am I doing wrong?
Trigger so far:

JASS:
scope MojoMagic

globals
  constant integer SPELL_ID  = 'A000'   //Spell ID (Ctrl+D at Object Editor)
  constant real DAMAGE_MULTI = 60.      //Damage multiplier
  constant real CASTER_MULTI = 0.5      //Multiplier of damage on caster
  constant integer DURATION  = 5       //Multiplier of duration
  constant string FX_STRING  = "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl" //Spell SFX
  constant real RED          = 0.75  //*******************************
  constant real GREEN        = 0.2   //
  constant real BLUE         = 0.8   //These are the colors and the alpha value of the lightning
  constant real ALPHA        = 0.8   //*******************************
  constant real DISTANCE     = 600.0 //The maximal range of the link
  constant real HEIGHT       = 50.    // Height of lightning effect
  constant string LIGHT_TYPE = "SPLK" // Type of lightning (STLK is Spirit Link)
endglobals
    
private function Damage takes integer level returns real
    return DAMAGE_MULTI * level
endfunction

private function Duration takes integer level returns integer
    return DURATION * level
endfunction    

private struct mojo
    unit caster
    unit target
    lightning light
    real damage
    integer ticks
    private method periodic takes nothing returns boolean
            local real loc1x = GetUnitX(.caster)
            local real loc1y = GetUnitY(.caster)
            local real loc1z = GetLocationZ(Location(loc1x,loc1y)) + GetUnitFlyHeight(.caster) + HEIGHT
            local real loc2x = GetUnitX(.target)
            local real loc2y = GetUnitY(.target)
            local real loc2z = GetLocationZ(Location(loc2x,loc2y)) + GetUnitFlyHeight(.target) + HEIGHT
            local real disx = loc2x - loc1x
            local real disy = loc2y - loc1y
            
            local real distance = disx * disx + disy * disy
            
            call MoveLightningEx( .light, true, loc1x, loc1y, loc1z, loc2x, loc2y, loc2z)
            
            set .ticks = .ticks - 1
            
            if distance >= DISTANCE*DISTANCE or GetWidgetLife(.target) <.405 or GetWidgetLife(.caster) <.405 or .ticks == 0 then
            
                if IsUnitEnemy(.target, GetOwningPlayer(.caster)) == true then
                    call UnitDamageTarget( .caster, .target, DAMAGE_MULTI, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS ) //Damage Target
                    call UnitDamageTarget( .caster, .caster, DAMAGE_MULTI*CASTER_MULTI, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS ) //Damage Caster
                else
                    call SetUnitState( .target, UNIT_STATE_LIFE, ( GetUnitStateSwap(UNIT_STATE_LIFE, .target) + DAMAGE_MULTI ) ) //Heal Target
                    call SetUnitState( .caster, UNIT_STATE_LIFE, ( GetUnitStateSwap(UNIT_STATE_LIFE, .caster) + DAMAGE_MULTI ) ) //Heal Caster
                endif
                
                call DestroyEffect( AddSpecialEffect( FX_STRING, loc1x, loc1y))
                call DestroyEffect( AddSpecialEffect( FX_STRING, loc2x, loc2y))
                call DestroyLightning(.light)
                
                return true
            endif
            
            return false
    endmethod
    implement T32
endstruct

private function Trig_Mojo_Magic_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == SPELL_ID
endfunction

function Trig_Mojo_Magic_Actions takes nothing returns nothing
    local mojo d = mojo.create()
    local unit caster = GetTriggerUnit()
    local unit target = GetSpellTargetUnit()
    local timer tim = CreateTimer()
    local real loc1x = GetUnitX(caster)
    local real loc1y = GetUnitY(caster)
    local real loc1z = GetLocationZ(Location(loc1x,loc1y)) + GetUnitFlyHeight(d.caster) + HEIGHT
    local real loc2x = GetUnitX(target)
    local real loc2y = GetUnitY(target)
    local real loc2z = GetLocationZ(Location(loc2x,loc2y)) + GetUnitFlyHeight(d.target) + HEIGHT
    

    set d.light =  AddLightningEx( LIGHT_TYPE, true, loc1x, loc1y, loc1z, loc2x, loc2y, loc2z ) //Set the type of the lightning (in this case, it's Spirit Link)
    call SetLightningColor( d.light, RED, GREEN, BLUE, ALPHA )                                  //Set the color of the lightning
    set d.caster = caster
    set d.target = target
    set d.damage = Damage( GetUnitAbilityLevel(d.caster, SPELL_ID) )
    set d.ticks  = R2I(Duration( GetUnitAbilityLevel(d.caster, SPELL_ID) ) / T32_PERIOD)

    call mojo.create().startPeriodic()
    set caster = null
    set target = null
endfunction

//===========================================================================
function InitTrig_Mojo_Magic_t32 takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Trig_Mojo_Magic_Conditions ) )
    call TriggerAddAction( t, function Trig_Mojo_Magic_Actions )
    set t = null
endfunction

endscope
 

Komaqtion

You can change this now in User CP.
Reaction score
469
JASS:
call mojo.create().startPeriodic()


Supposed to be:
JASS:
call d.startPeriodic()


?
 

Nexor

...
Reaction score
74
Wow, thanks !
that was the problem... Didn't check that part of the code :O

Update:
- now uses T32 instead of ABC
- new options added ( duration, damage on end )

You can suggest other functions as well to add
 
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
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      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