| 10-02-2006, 04:13 PM | #1 |
Hi, I'm making spell, based on channel Her is the code : JASS:function Testament_Conditions takes nothing returns boolean if ( not ( GetSpellAbilityId() == 'A055' ) ) then return false endif return true endfunction function Testament_Effect takes nothing returns nothing local timer t = GetExpiredTimer() local string St = H2S(t) local unit cast = GetStoredHandleUnit(St, "Caster") local integer N = GetStoredHandleInteger(St, "SecCount") local integer stats = GetStoredHandleInteger(St, "Attributes") set N = N + 1 call StoreHandleInteger (St, "SecCount", N) if (not(N <= 4)) then call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Items\\TomeOfRetraining\\TomeOfRetrainingCaster.mdl",cast,"origin")) call SetHeroAgi(cast, (GetHeroStatBJ(bj_HEROSTAT_AGI, cast, false)+2*GetUnitAbilityLevel(cast, 'A055')), false) call SetHeroInt(cast, (GetHeroStatBJ(bj_HEROSTAT_INT, cast, false)+2*GetUnitAbilityLevel(cast, 'A055')), false) call SetHeroStr(cast, (GetHeroStatBJ(bj_HEROSTAT_STR, cast, false)+2*GetUnitAbilityLevel(cast, 'A055')), false) set stats = stats + 2*GetUnitAbilityLevelSwapped('A055', cast) call StoreHandleInteger (St, "Attributes", stats) endif endfunction function EndCast takes nothing returns nothing local string GGR=H2S(GetTriggeringTrigger()) local timer t=GetStoredHandleTimer(GGR,"Timer") local string St=H2S(t) local unit cast=GetStoredHandleUnit(St,"Caster") local integer stats=GetStoredHandleInteger(St,"Attributes") call PauseTimer(t) call TriggerRemoveAction(GetTriggeringTrigger(),GetStoredHandleTriggerAction(GGR,"TriggerAction")) call FlushHandleLocals(GGR) call PolledWait(10) call SetHeroAgi(cast, (GetHeroStatBJ(bj_HEROSTAT_AGI, cast, false)-stats), false) call SetHeroAgi(cast, (GetHeroStatBJ(bj_HEROSTAT_INT, cast, false)-stats), false) call SetHeroAgi(cast, (GetHeroStatBJ(bj_HEROSTAT_STR, cast, false)-stats), false) call FlushHandleLocals(St) call DestroyTimer(t) set cast = null call DestroyTrigger(GetTriggeringTrigger()) endfunction function Testament_Actions takes nothing returns nothing local timer t = CreateTimer() local string St=H2S(t) local trigger ggr = CreateTrigger() local unit cast = GetTriggerUnit() local integer N = 0 local integer stats call TriggerRegisterUnitEvent(ggr,GetTriggerUnit(),EVENT_UNIT_SPELL_ENDCAST) call StoreHandleObject(H2S(ggr),"TriggerAction",TriggerAddAction(ggr,function EndCast)) call StoreHandleInteger(St, "SecCount", N) call StoreHandleInteger(St, "Attributes", stats) call StoreHandleObject(St, "Caster", cast) call StoreHandleObject(H2S(ggr), "Timer",t) call StoreHandleObject(St, "Trigger", ggr) call TimerStart(t, 1, true, function Testament_Effect) endfunction //====================================================================== ============================= function InitTrig_Testament takes nothing returns nothing set gg_trg_Testament = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Testament, EVENT_PLAYER_UNIT_SPELL_EFFECT ) call TriggerAddCondition( gg_trg_Testament, Condition( function Testament_Conditions ) ) call TriggerAddAction( gg_trg_Testament, function Testament_Actions ) endfunction The code has no error but is still not working. Where are my mistakes ?? |
| 10-02-2006, 04:21 PM | #2 |
Could you be more specific about what isn't working? Debug first see if you can figure out what's not working. Also post your script for your H2S and gamecache functions, since they don't appear to be standard. |
| 10-02-2006, 04:36 PM | #3 |
Ok i will try to explain the spell (in my bad english) : This spell is supposed to add intel, agi and strength every seconds during the channel action. The duration is maxed at 4 seconds, and i want to stop increasing the attributes if the hero stop channeling ( if he moves or has be stunned). Then, after the charge, the atributes bonus have to stay 10 seconds. I use this script : JASS:function InitCache takes nothing returns nothing call FlushGameCache(InitGameCache("TLW")) set udg_Cache=InitGameCache("TLW") endfunction function H2I takes handle h returns integer return h return 0 endfunction function H2S takes handle h returns string return I2S(H2I(h)) endfunction function FlushHandleLocals takes string sMission returns nothing call FlushStoredMission(udg_Cache,sMission) endfunction function StoreHandleObject takes string sMission,string sKey,handle hObject returns nothing call StoreInteger(udg_Cache,sMission,sKey,H2I(hObject)) endfunction function StoreHandleInteger takes string sMission,string sKey,integer iInteger returns nothing call StoreInteger(udg_Cache,sMission,sKey,iInteger) endfunction function StoreHandleInteger_Copy takes string sMission,string sKey,integer iInteger returns nothing call StoreInteger(udg_Cache,sMission,sKey,iInteger) endfunction function StoreHandleReal takes string sMission,string sKey,real rReal returns nothing call StoreReal(udg_Cache,sMission,sKey,rReal) endfunction function StoreHandleBoolean takes string sMission,string sKey,boolean bBoolean returns nothing call StoreBoolean(udg_Cache,sMission,sKey,bBoolean) endfunction function GetStoredHandleUnit takes string sMission,string sKey returns unit return GetStoredInteger(udg_Cache,sMission,sKey) return null endfunction function GetStoredHandlePlayer takes string sMission,string sKey returns player return GetStoredInteger(udg_Cache,sMission,sKey) return null endfunction function GetStoredHandleTimer takes string sMission,string sKey returns timer return GetStoredInteger(udg_Cache,sMission,sKey) return null endfunction function GetStoredHandleTrigger takes string sMission,string sKey returns trigger return GetStoredInteger(udg_Cache,sMission,sKey) return null endfunction function GetStoredHandleGroup takes string sMission,string sKey returns group return GetStoredInteger(udg_Cache,sMission,sKey) return null endfunction function GetStoredHandleEffect takes string sMission,string sKey returns effect return GetStoredInteger(udg_Cache,sMission,sKey) return null endfunction function GetStoredHandleLocation takes string sMission,string sKey returns location return GetStoredInteger(udg_Cache,sMission,sKey) return null endfunction function GetStoredHandleTriggerAction takes string sMission,string sKey returns triggeraction return GetStoredInteger(udg_Cache,sMission,sKey) return null endfunction function GetStoredHandleInteger takes string sMission,string sKey returns integer return GetStoredInteger(udg_Cache,sMission,sKey) endfunction function GetStoredHandleInteger_Copy takes string sMission,string sKey returns integer return GetStoredInteger(udg_Cache,sMission,sKey) endfunction function GetStoredHandleReal takes string sMission,string sKey returns real return GetStoredReal(udg_Cache,sMission,sKey) endfunction function GetStoredHandleBoolean takes string sMission,string sKey returns boolean return GetStoredBoolean(udg_Cache,sMission,sKey) endfunction |
| 10-02-2006, 09:13 PM | #4 |
It seems to be my handle script, i changed it and now some spells don't work too. I m trying with katana's handle and I will see if it change something. EDIT : No, with katana's handle this spell doesn't work. I tried to modify the code in order to have the simpliest timer code and it doesn't work, but my old spells work fine. |
