Spell Mojo Magic

Romek

Super Moderator
Reaction score
963
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
963
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
963
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
963
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.

      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