• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] MUI in Jass for Spells?

Status
Not open for further replies.
Level 3
Joined
Feb 17, 2008
Messages
41
I have this example spell I was making to get familiar with Jass but I'm not completely sure how to make it MUI. Any tips or tutorials? Example of the existing work.

JASS:
function Trig_Shrink_Ray_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A000' ) ) then
        return false
    endif
    return true
endfunction

function shrink takes nothing returns nothing
    local real newsize = udg_targetsize - 5
    local string mdl = "Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl"
    local effect sfx = AddSpecialEffect(mdl,GetUnitX(udg_target),GetUnitY(udg_target))
    call SetUnitScalePercent( udg_target, newsize, newsize , newsize )
    set udg_targetsize = newsize
endfunction


function startunshrink takes nothing returns nothing
    call SetUnitScalePercent( udg_target, 100, 100, 100)
endfunction

function Trig_Shrink_Ray_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local timer t = CreateTimer()
    local timer t2 = CreateTimer()
    set udg_targetsize = 100
    set udg_target = GetSpellTargetUnit()
    call TriggerSleepAction(.50)
    call TimerStart(t, .05, true, function shrink)
    call TriggerSleepAction(.50)
    call DestroyTimer(t)
    //Unshrink
    call TimerStart(t2,5,false,function startunshrink)
    
endfunction

//===========================================================================
function InitTrig_Shrink_Ray takes nothing returns nothing
    set gg_trg_Shrink_Ray = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shrink_Ray, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Shrink_Ray, Condition( function Trig_Shrink_Ray_Conditions ) )
    call TriggerAddAction( gg_trg_Shrink_Ray, function Trig_Shrink_Ray_Actions )
endfunction

The unshrink part is getting worked on. But anyone able to explain will help me greatly and learn a lot more.
 
Level 14
Joined
Jan 15, 2007
Messages
349
First you need to make a global with the type gamecache and the name cache and you need to make a map init trigger with this lines:
JASS:
function GameInit takes nothing returns nothing
  set udg_cache=InitGameCache("savestuff")
endfunction

After you made that you should replace your lines with this:
JASS:
// This convert handles to integer
function H2I takes handle h returns integer
  return h
  return 0
endfunction

// This convert integer to unit
function I2U takes integer i returns unit
  return i
  return null
endfunction

function Trig_Shrink_Ray_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'
endfunction

function shrink takes nothing returns nothing
    local timer t =GetExpiredTimer()
    //Get the stored datas in cache
    local unit target=I2U(GetStoredInteger(udg_cache,I2S(H2I(t)),"target"))
    local real newsize = GetStoredReal(udg_cache,I2S(H2I(t)),"size") - 5
    //////////////////////////////////////////////////////////////////////////////
    local effect sfx = AddSpecialEffect("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl",GetUnitX(udg_target),GetUnitY(udg_target))
    call SetUnitScalePercent( target, newsize, newsize , newsize )
    call StoreReal(udg_cache,I2S(H2I(t)),"size",newsize)  //Store the new unit scale

    // Clean stuff
    call DestroyEffect(sfx)
    set t=null
    set target=null
    set sfx=null
endfunction

function startunshrink takes nothing returns nothing
    local timer t =GetExpiredTimer()
    //Get the stored datas in cache
    local unit target=I2U(GetStoredInteger(udg_cache,I2S(H2I(t)),"target"))
    //////////////////////////////////////////////////////
    call SetUnitScalePercent( target, 100, 100, 100)
    //Clean up data in cache
    call FlushStoredMission(udg_cache,I2S(H2I(t)))

    //Clean stuff
    call DestroyTimer(t)
    set target=null
    set t=null
endfunction

function Trig_Shrink_Ray_Actions takes nothing returns nothing
    local unit target = GetSpellTargetUnit()
    local timer t = CreateTimer()
    local timer t2 = CreateTimer()
    call TriggerSleepAction(.50)
    call TimerStart(t, .05, true, function shrink)
    // Store datas in cache
    call StoreInteger(udg_cache,I2S(H2I(t)),"target",H2I(target))
    call StoreReal(udg_cache,I2S(H2I(t)),"size",100.)
    /////////////////////////////////////////////////////
    call TriggerSleepAction(.50)
    // Clean up data in cache
    call FlushStoredMission(udg_cache,I2S(H2I(t)))
    ////////////////////////////////////////////////////
    call PauseTimer(t)
    call DestroyTimer(t)    //Unshrink
    call TimerStart(t2,5,false,function startunshrink)
    // Store datas in cache
    call StoreInteger(udg_cache,I2S(H2I(t2)),"target",H2I(target))
    ///////////////////////////////////////////////////

    //
    set t=null
    set t2=null
    set target=null
endfunction

//===========================================================================
function InitTrig_Shrink_Ray takes nothing returns nothing
    set gg_trg_Shrink_Ray = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Shrink_Ray, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Shrink_Ray, Condition( function Trig_Shrink_Ray_Conditions ) )
    call TriggerAddAction( gg_trg_Shrink_Ray, function Trig_Shrink_Ray_Actions )
endfunction

Well I didnt tested it, because Im at work, but it should work correct.
 
Level 3
Joined
Feb 17, 2008
Messages
41
Didn't work right. Map loaded fine, but I haven't really looked into GameCaches. That should help. I also haven't had time to fix it yet.
 
Level 6
Joined
Apr 16, 2007
Messages
177
I have this example spell I was making to get familiar with Jass but I'm not completely sure how to make it MUI. Any tips or tutorials? Example of the existing work.

[/code]

The unshrink part is getting worked on. But anyone able to explain will help me greatly and learn a lot more.

There is a system by cohadar called ABCT. It will allow you to attach structs onto timers, and retrieving them once the timer resolves. This allows you to easily do the spell MUI, just create a struct that holds the unit and the shrink factor, attach it to the newly created timer. Whenever the timer expires, retrieve the struct and apply the new size to the unit.

Hth, Davey
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
There is a system by cohadar called ABCT. It will allow you to attach structs onto timers, and retrieving them once the timer resolves. This allows you to easily do the spell MUI, just create a struct that holds the unit and the shrink factor, attach it to the newly created timer. Whenever the timer expires, retrieve the struct and apply the new size to the unit.

Hth, Davey

There are a lot of systems for vJass, but first he should know vJass for them.
Not even going to mention passing locals with Jass since since vJass came out it's really not efficient anymore.
 
Level 3
Joined
Feb 17, 2008
Messages
41
Any tutorials on vJass, I got the hang of Jass so far. I can't see to find any documentation or tutorials on it.
 
Level 3
Joined
Feb 17, 2008
Messages
41
I just actually found that tutorial. If you have anymore, the more, the merrier.
 
Status
Not open for further replies.
Top