HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Storing data into GC. I've some question.

11-08-2007, 07:02 PM#1
BestZero
Status : All questions cleared even I solved by myself thanks to everyone.


I know only use timer or trigger as name of table before storing.

like this
Collapse JASS:
function SomeFunc takes nothing returns nothing
local timer t=CreateTimer()
local string s=I2S(H2I(t))
call DebugMsg(s) //This is my function that is quick and simple to display text
call DestroyTimer(t)
endfunction

The strings change every time so this way works fine but I tried on trigger...

Collapse JASS:
function SomeFunc takes nothing returns nothing
local trigger t=CreateTrigger()
local string s=I2S(H2I(t))
call DebugMsg(s)
call DestroyTrigger(t)
endfunction

Strings are also the same value.... so this is not good if I make it as table name for storing something into gamecache.


Is there have other way I can use other thing as label ? Timer is not enough for me because some triggers I've used CreateTrigger().
11-08-2007, 07:08 PM#2
TheDamien
...

You can store data under any 2 labels with gamecache. You don't need a timer or a handle or anything.
11-08-2007, 07:21 PM#3
BestZero
Sorry, I forgot something.


My whole reason why I use storing data because I want them can use in other functions like Glob Vars.
11-08-2007, 11:14 PM#4
TheDamien
Quote:
Originally Posted by BestZero
Sorry, I forgot something.


My whole reason why I use storing data because I want them can use in other functions like Glob Vars.

I am having trouble understanding.

Why not just use a global variable? Gamecache is, after all, much slower than a global variable.

Do you mean you want to attach multiple variables to a timer or trigger?
11-09-2007, 10:06 AM#5
BestZero
OK, I just solved my problem. Use unit instead trigger as label.

But I've new problem.

Collapse JASS:
    call GroupEnumUnitsInRange(lVictimG,lLX,lLY,150.+MaxUnitCollisionSize(),lFTF)
        loop
           set lTU=FirstOfGroup(lVictimG)
           call GroupRemoveUnit(lVictimG,lTU)
           call DamageAsSpell(lFTC,lTU,30.*R2I(GetUnitAbilityLevel(lFTC,'A003')),4) //This is function deal damage to lTU unit.
               call SetHandle(s,"FTDoTVictim",lTU) //I want this unit to take damage over time by Timer so I store into gamecache
               call SetInteger(s,"FTDoTBuffTime",5)
               call TimerStart(t,1.,true,function FireTrapDoT)
           exitwhen lTU == null
        endloop


lTU takes damage by function DamageAsSpell normally but I tried to add this
call DebugMsg(I2S(H2I(GetUnit(s,"FTDoTVictim")))) under function SetHandle Text shows me the 0 value!

I'm wondering why ? How to solve this problem ?
11-09-2007, 10:19 AM#6
Malf
I don't know what wierd voodoo you are using to achieve something you haven't clearly stated for us.

But I do recognize that you want to damage a unit overtime. In that case..
Collapse JASS:
library DamageOvertime

private struct data
 unit h
 unit t
 real dmg
 real d
 real i
endstruct

private function Callback takes nothing returns nothing
local timer t = GetExpiredTimer()
local data d = data(GetTimerStructA(t))
 if d.d <= 0 then
  call ReleaseTimer(t)
  call data.destroy(d)
 else
  set d.d = d.d - d.i
  call UnitDamageTarget(d.h,d.t,d.dmg,true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_UNIVERSAL,null)
 endif
endfunction

function DamageUnitOvertime takes unit hurter, unit targ, real dmg, real dur, real interval returns nothing
local timer t = NewTimer()
local data d = data.create()
 set d.h = hurter
 set d.t = targ
 set d.dmg = dmg
 set d.d = dur
 set d.i = interval
 call SetTimerStructA(t,d)
 call TimerStart(t,interval,true,function Callback)
endfunction

endlibrary
It uses cohadar's ABC system, you can find it at the resource section. And also CSSafety, which is included in the Caster System.
11-09-2007, 10:31 AM#7
BestZero
If unnecessary I'm not going to use other system. My map not use struct I think Gamecache is enough.

And this is my whole code about spell "Fire Trap"(carefully it's too mess) and It's unfinished.

Expand JASS:

Have many vars that not used. Don't notice them.
11-09-2007, 10:39 AM#8
Malf
Well, it's your map so do as you wish.

But your var names look like semi hexcodes. You can just use one letter names for them.