| 11-08-2007, 07:02 PM | #1 |
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 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... 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 |
... 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 |
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 | |
Quote:
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 |
OK, I just solved my problem. Use unit instead trigger as label. But I've new problem. 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 |
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.. 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 |
| 11-09-2007, 10:31 AM | #7 |
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. JASS:function FireTrapConditions takes nothing returns boolean return GetSpellAbilityId()=='A003' endfunction function FireTrapFilter takes nothing returns boolean return IsUnitEnemy(GetFilterUnit(),bj_groupEnumOwningPlayer) and IsUnitType(GetFilterUnit(),UNIT_TYPE_MAGIC_IMMUNE)==false and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE)>0. and IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)==false and GetUnitAbilityLevel(GetFilterUnit(),'A000')==0 endfunction function FireTrapDoT takes nothing returns nothing local timer t=GetExpiredTimer() local string s=I2S(H2I(t)) local unit Caster=GetUnit(s,"FTDoTCaster") local unit Victim=GetUnit(s,"FTDoTVictim") local integer BuffTime=GetInteger(s,"FTDoTBuffTime") //call DebugMsg(I2S(H2I(Caster))) //call DebugMsg(I2S(H2I(Victim))) if BuffTime > 0 then call DestroyEffect(AddSpecialEffectTarget("Environment\\LargeBuildingFire\\LargeBuildingFire1.mdl",Victim,"head")) call DamageAsSpell(Caster,Victim,10.*R2I(GetUnitAbilityLevel(Caster,'A003')),4) call SetInteger(s,"FTDoTBuffTime",BuffTime-1) else call DestroyTimer(t) call FlushTable(s) endif set t=null set Victim=null set Caster=null endfunction function FireTrapTrigger takes nothing returns nothing local trigger lFTT=GetTriggeringTrigger() local string lTable=I2S(H2I(GetTriggerUnit())) local unit lFTC=GetUnit(lTable,"Caster") local real lLX=GetReal(lTable,"LocX") local real lLY=GetReal(lTable,"LocY") local integer FTLV=GetUnitAbilityLevel(lFTC,'A003') local group lVictimG=CreateGroup() local unit lTU local boolexpr lFTF=Condition(function FireTrapFilter) local timer t=CreateTimer() local string s=I2S(H2I(t)) local unit damn call SetHandle(s,"FTDoTCaster",lFTC) //call SetInteger() call DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\Mortar\\MortarMissile.mdl",lLX,lLY)) set bj_groupEnumOwningPlayer=GetOwningPlayer(lFTC) 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) call SetHandle(s,"FTDoTVictim",lTU) call DebugMsg(I2S(H2I(GetUnit(s,"FTDoTVictim")))) call SetInteger(s,"FTDoTBuffTime",5) call TimerStart(t,1.,true,function FireTrapDoT) exitwhen lTU == null endloop call FlushTable(lTable) call DestroyGroup(lVictimG) call DestroyTrigger(lFTT) call DestroyBoolExpr(lFTF) set lVictimG=null set lTU=null set lFTT=null set lFTC=null endfunction function FireTrapActions takes nothing returns nothing local trigger lFTT=CreateTrigger() local unit lFTC=GetTriggerUnit() local real lLX=GetLocationX(GetSpellTargetLoc()) local real lLY=GetLocationY(GetSpellTargetLoc()) local unit lFTU=CreateUnit(GetOwningPlayer(lFTC),'h004',lLX,lLY,0.) local string lTable=I2S(H2I(lFTU)) set lLX=GetUnitX(lFTU) set lLY=GetUnitY(lFTU) call SetHandle(lTable,"Caster",lFTC) call SetReal(lTable,"LocX",lLX) call SetReal(lTable,"LocY",lLY) call TriggerRegisterUnitEvent(lFTT,lFTU,EVENT_UNIT_DEATH) call TriggerAddAction(lFTT,function FireTrapTrigger) set lFTT=null set lFTC=null set lFTU=null endfunction Have many vars that not used. Don't notice them. |
| 11-09-2007, 10:39 AM | #8 |
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. |
