HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Mass Timed event - help needed

08-11-2005, 08:53 AM#1
tufy
I'm making a triggered ability for CaQT and I need some help here.

What I'm trying to do is get the spellcaster, spelltarget and spelltarget's owner (player 1 for instance), store them into variables (arrays actually, but..), then set a timer. Once the timer runs out, I want the spelltarget and player 1 to be picked and an action is done to them.

The problem is, I need this trigger setting to run for quite a few abilities (let's say a hundred or more) at the same time. If I store the owner of unit and the unit into arrays, then:

1. how do I reference to them with a timer (once the timer runs out, how will the trigger now which unit to pick?)
2. Would it be possible to avoid using variables at all? And how?

EDIT:

Well, if it helps:

I want the trigger to change ownership of spelltarget to spellcaster player. Once the timer runs out (or the spell is dispelled), I want the trigger to return spelltarget to original owner. It's a regular unit ability, so it has to be multicastable.
08-11-2005, 11:54 AM#2
Zoxc
This is easy done in JASS.

You don't need to store the owner. ( Owner of unit )

And you need 1 game cache variable. Here name Cache


Quote:
function H2I takes handle h returns integer
return h
return 0
endfunction

function Int2Unit takes integer I returns effect
if I != 0 then
return I
endif
return null
endfunction


function SpellGoGetUnit takes timer t, string name returns unit
return GetStoredInteger(udg_Cache,"ASpell"+I2S(H2I(t)), name)
return null
endfunction

function SpellGoTimer takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit caster=SpellGoGetUnit(t, "unitcaster")
local unit target=SpellGoGetUnit(t, "unittarget")
local player owner = GetOwningPlayer(caster)


/// Do actions


call DestroyTimer(t)
set caster=unit
set target=null
set owner = null
endfunction


function SpellGo takes nothing returns nothing
local timer t=CreateTimer()

call StoreInteger(udg_Cache,"ASpell"+I2S(H2I(t)),"unitcaster",H2I(GetSpellAbilityUnit()))
call StoreInteger(udg_Cache,"ASpell"+I2S(H2I(t)),"unittarget",H2I(GetSpellTargetUnit()))
call TimerStart(t, Number of secouds ,false,function SpellGoTimer)
set t=null
endfunction

This shoud be placed on global script when the spell executes do this
Custom Script: call SpellGo()