- Joined
- Apr 28, 2006
- Messages
- 187
Hey fellas, seems 1.24 breaks spells that rely on GUI game caches, despite reading some hashtable tutorials and understanding the basic principles, problem is the recoding of the jass that already exists, any help on this?
In custom script:
***
Spell 1:
***
***
Spell 2:
***
***
Thanks!
In custom script:
JASS:
function Cache takes nothing returns gamecache
if (udg_cache==null) then
set udg_cache=InitGameCache("cache")
endif
return udg_cache
endfunction
function HandToInt takes handle h returns integer
return h
return 0
endfunction
function StoreHandle takes handle m_key, handle stored, string key returns nothing
call StoreInteger(Cache(),I2S(HandToInt( m_key )),key,HandToInt(stored))
endfunction
function RetrieveUnit takes handle m_key,string key returns unit
return GetStoredInteger(Cache(),I2S(HandToInt( m_key )),key)
return null
endfunction
function RetrieveInt takes handle m_key,string key returns integer
return GetStoredInteger(Cache(),I2S(HandToInt( m_key )),key)
endfunction
function RetrieveGroup takes handle m_key,string key returns group
return GetStoredInteger(Cache(),I2S(HandToInt( m_key )),key)
return null
endfunction
function Flush takes handle m_key returns nothing
call FlushStoredMission(Cache(),I2S(HandToInt( m_key )))
endfunction
Spell 1:
***
JASS:
function RawPSSJ takes nothing returns integer
return 'A07G' //Raw code for Pounce
endfunction
//=================================================================================
//Configuration
function ss_pounceconstant takes nothing returns real
return 7.00 //Set this real number higher to get faster speed, and lower to get slower speed
endfunction
//=================================================================================
function Trig_Pounce_Conditions takes nothing returns boolean
return GetSpellAbilityId() == RawPSSJ()
endfunction
function PounceSS takes nothing returns nothing
local unit spell_pouncecaster = RetrieveUnit(GetExpiredTimer(), "spell_pouncecaster")
local real spell_pouncess_const = GetStoredReal(Cache(),I2S(HandToInt(GetExpiredTimer())),"spell_pouncess_const")
local real spell_pouncefaceangle = GetStoredReal(Cache(),I2S(HandToInt(GetExpiredTimer())),"spell_pouncefaceangle")
local location pouncecastloc = GetUnitLoc(spell_pouncecaster)
local location pouncepolarproj = PolarProjectionBJ(pouncecastloc, ( spell_pouncess_const * 5.00 ), ( spell_pouncefaceangle + 180.00 )) //else goes backwards
local effect spell_pouncedusteffect
call SetUnitPositionLocFacingBJ( spell_pouncecaster, pouncepolarproj, ( spell_pouncefaceangle - 180.00 ) )
set spell_pouncedusteffect = AddSpecialEffectTarget("Abilities\\Weapons\\AncientProtectorMissile\\AncientProtectorMissile.mdl",spell_pouncecaster,"origin")
call DestroyEffectBJ( spell_pouncedusteffect )
call RemoveLocation(pouncecastloc)
call RemoveLocation(pouncepolarproj)
set spell_pouncecaster = null
set pouncecastloc = null
set pouncepolarproj = null
set spell_pouncedusteffect = null
endfunction
function Trig_Pounce_Actions takes nothing returns nothing
local real spell_pouncess_const = ss_pounceconstant()
local unit spell_pouncecaster = GetTriggerUnit()
local location pouncecastloc = GetUnitLoc(spell_pouncecaster)
local location spell_pouncetarget = GetUnitLoc(GetSpellTargetUnit())
local real spell_pouncefaceangle = AngleBetweenPoints(pouncecastloc, spell_pouncetarget) + 180.00
local real spell_distancepounce = DistanceBetweenPoints(pouncecastloc, spell_pouncetarget)
local timer spell_pouncetimer = CreateTimer()
if ( spell_distancepounce > 500 ) then
set spell_distancepounce = 500
endif
// call SetUnitPathing( spell_pouncecaster, false ) //collision off
// call UnitAddAbility(spell_pouncecaster, RawEvade())
call SetUnitAnimation( spell_pouncecaster, "ready" )
call StoreHandle(spell_pouncetimer, spell_pouncecaster, "spell_pouncecaster")
call StoreReal(Cache(),I2S(HandToInt( spell_pouncetimer )),"spell_pouncess_const",spell_pouncess_const)
call StoreReal(Cache(),I2S(HandToInt( spell_pouncetimer )),"spell_pouncefaceangle",spell_pouncefaceangle)
call TimerStart(spell_pouncetimer, 0.03, true, function PounceSS)
call TriggerSleepAction( ( spell_distancepounce / ( spell_pouncess_const * 200.00 ) ) )
// call UnitRemoveAbility( spell_pouncecaster, RawEvade())
call ResetUnitAnimation( spell_pouncecaster )
// call SetUnitPathing( spell_pouncecaster, true ) //collision on
call Flush(spell_pouncetimer)
call DestroyTimer(spell_pouncetimer)
call RemoveLocation(pouncecastloc)
call RemoveLocation(spell_pouncetarget)
set pouncecastloc = null
set spell_pouncetarget = null
set spell_pouncecaster = null
set spell_pouncetimer = null
endfunction
//===========================================================================
function InitTrig_Pounce_JASS takes nothing returns nothing
set gg_trg_Pounce_JASS = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Pounce_JASS, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Pounce_JASS, Condition( function Trig_Pounce_Conditions ) )
call TriggerAddAction( gg_trg_Pounce_JASS, function Trig_Pounce_Actions )
endfunction
Spell 2:
***
JASS:
//---------------------------------------------------------------------------------------
function getOmniDrain_Abilcode takes nothing returns integer
return 'A01A' //The ability code for the Omni Drain spell.
endfunction
function getOmniDrain_caster takes nothing returns integer
return 'h00H' //The unit code for the dummy caster.
endfunction
function getOmniDrain_buff takes nothing returns integer
return 'B00N' //The buff code for the buff Drain Life (target - no fx).
endfunction
function getOmniDrain_DummyLightningFX_Abilcode takes nothing returns integer
return 'A01B' //The ability code for the dummy Multi Drain (lightning fx) spell
endfunction
function getOmniDrain_DummyCheck_Abilcode takes nothing returns integer
return 'A01C' //The ability code for the dummy Multi Drain (forked check) spell
endfunction
function getOmniDrain_CapTargets takes nothing returns integer
return 2+GetUnitAbilityLevelSwapped(getOmniDrain_Abilcode(), GetTriggerUnit())
//Formula for maximum # of targets per level
endfunction
function GetOmniDrain_dmgReturnFactor takes nothing returns real
return 0.5 //Damage return as a factor of the life drained
endfunction
//---------------------------------------------------------------------------------------
function CastAbility takes integer abil, integer level, string order, unit caster, unit target, location loc, real h returns nothing
call CreateNUnitsAtLoc(1,getOmniDrain_caster(), GetOwningPlayer(caster), loc,bj_UNIT_FACING)
call SetUnitPathing( GetLastCreatedUnit(), false )
call SetUnitPositionLoc( GetLastCreatedUnit(), loc )
if h > 20 then
call SetUnitFlyHeightBJ( GetLastCreatedUnit(), h, 10000.00 )
endif
call UnitAddAbilityBJ( abil, GetLastCreatedUnit() )
call SetUnitAbilityLevelSwapped( abil, GetLastCreatedUnit(), level )
call UnitApplyTimedLifeBJ( 1.00, 'BTLF', GetLastCreatedUnit() )
call IssueTargetOrderBJ( GetLastCreatedUnit(), order, target )
endfunction
function GameCache2Trigger takes gamecache g returns trigger
return g
return null
endfunction
function H2I takes handle h returns integer
return h
return 0
endfunction
function I2U takes integer i returns unit
return i
return null
endfunction
function I2T takes integer t returns trigger
return t
return null
endfunction
function I2G takes integer g returns group
return g
return null
endfunction
function Trig_MultiDrain_InitConditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == getOmniDrain_Abilcode() ) ) then
return false
endif
return true
endfunction
function GetMultiDrainGameCache takes nothing returns gamecache
return gg_trg_MultiDrain
return null
endfunction
function Trig_MultiDrain_RemoveCasters takes nothing returns nothing
call RemoveUnit(GetEnumUnit())
endfunction
function Trig_MultiDrain_TargetDmgCondition takes nothing returns boolean
local gamecache g = GetMultiDrainGameCache()
local unit dummy = I2U(GetStoredInteger(g, "dummy", I2S(H2I(GetTriggeringTrigger()))))
return ( GetEventDamageSource() == dummy )
endfunction
function Trig_MultiDrain_TargetDmgActions takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local unit caster = I2U(GetStoredInteger(g, "caster", I2S(H2I(GetTriggeringTrigger()))))
call SetUnitLifeBJ( caster, ( GetUnitStateSwap(UNIT_STATE_LIFE, caster) + GetEventDamage()*GetOmniDrain_dmgReturnFactor() ) )
endfunction
function Trig_MultiDrain_DmgEvent_Child takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local unit caster = GetTriggerUnit()
local trigger t = I2T(GetStoredInteger(g,"t",I2S(H2I(caster))))
local trigger u = CreateTrigger()
local real dmg = GetStoredReal(g,"dmg",I2S(H2I(t)))
local integer spell = GetStoredInteger(g,"spell",I2S(H2I(t)))
local location loc = GetUnitLoc(caster)
local group dummycasters = I2G(GetStoredInteger(g, "dummycasters", I2S(H2I(t))))
local unit target = GetEnumUnit()
local unit dummy
call CreateNUnitsAtLoc(1,getOmniDrain_caster(), GetOwningPlayer(caster), loc,bj_UNIT_FACING)
call UnitAddAbilityBJ( getOmniDrain_DummyLightningFX_Abilcode(), GetLastCreatedUnit() )
call SetUnitAbilityLevelSwapped(getOmniDrain_DummyLightningFX_Abilcode(),GetLastCreatedUnit(),GetUnitAbilityLevelSwapped(getOmniDrain_Abilcode(),caster))
call UnitApplyTimedLifeBJ( 10.00, 'BTLF', GetLastCreatedUnit() )
call SetUnitPathing( GetLastCreatedUnit(), false )
call SetUnitPositionLoc( GetLastCreatedUnit(), loc )
call IssueTargetOrderBJ( GetLastCreatedUnit(), "drain", target )
set dummy = GetLastCreatedUnit()
call StoreIntegerBJ( H2I(dummy), I2S(H2I(u)), "dummy", g )
call StoreIntegerBJ( H2I(caster), I2S(H2I(u)), "caster", g )
call GroupAddUnitSimple(dummy,dummycasters)
call TriggerRegisterUnitEvent( u, target, EVENT_UNIT_DAMAGED )
call TriggerAddCondition( u, Condition(function Trig_MultiDrain_TargetDmgCondition) )
call TriggerAddAction( u, function Trig_MultiDrain_TargetDmgActions )
call PolledWait(0.5)
loop
call TriggerSleepAction( 0.1 )
exitwhen UnitHasBuffBJ( dummy, getOmniDrain_buff() ) == false
endloop
call GroupRemoveUnitSimple(dummy,dummycasters)
call FlushStoredInteger(g,"dummy", I2S(H2I(u)))
call FlushStoredInteger(g,"caster", I2S(H2I(u)))
call DestroyTrigger(u)
call RemoveLocation(loc)
set loc = null
endfunction
function Trig_MultiDrain_DmgEvent takes nothing returns nothing
call ExecuteFunc("Trig_MultiDrain_DmgEvent_Child")
endfunction
function Trig_MultiDrain_AddEvent takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local trigger t = I2T(GetStoredInteger(g,"t",I2S(H2I(GetTriggerUnit()))))
call TriggerRegisterUnitEvent( t, GetEnumUnit(), EVENT_UNIT_DAMAGED )
endfunction
function Trig_MultiDrain_AddGroupCondition takes nothing returns boolean
local gamecache g = GetMultiDrainGameCache()
local unit dummycaster = I2U(GetStoredInteger(g, "dummycaster", I2S(H2I(GetTriggeringTrigger()))))
return ( GetEventDamageSource() == dummycaster )
//set g = null
endfunction
function Trig_MultiDrain_AddGroupActions takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local group targets = I2G(GetStoredInteger(g, "targets", I2S(H2I(GetTriggeringTrigger()))))
call GroupAddUnitSimple(GetTriggerUnit(), targets)
endfunction
function Trig_MultiDrain_InitActions takes nothing returns nothing
local gamecache g = GetMultiDrainGameCache()
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local unit dummycaster
local location loc = GetUnitLoc(caster)
local location targetloc = GetUnitLoc(target)
local group targets = CreateGroup()
local group tempgroup
local group dummycasters = CreateGroup()
local trigger t = CreateTrigger()
local integer spell = GetSpellAbilityId()
local trigger endcast = CreateTrigger()
local boolean isendcast = false
local effect fx = AddSpecialEffectTargetUnitBJ( "weapon", caster, "Abilities\\Spells\\Other\\Drain\\DrainCaster.mdl" )
call CastAbility(getOmniDrain_DummyCheck_Abilcode(),1,"forkedlightning",caster,target,loc,0)
set dummycaster = GetLastCreatedUnit()
set targets = GetUnitsInRangeOfLocAll(1500.00, loc)
call StoreIntegerBJ( H2I(t), I2S(H2I(GetTriggerUnit())), "t", g )
call ForGroupBJ( targets, function Trig_MultiDrain_AddEvent )
call GroupClear(targets)
call TriggerAddCondition( t, Condition(function Trig_MultiDrain_AddGroupCondition) )
call TriggerAddAction( t, function Trig_MultiDrain_AddGroupActions )
call TriggerRegisterUnitEvent(endcast, caster, EVENT_UNIT_SPELL_ENDCAST)
call StoreIntegerBJ( H2I(caster), I2S(H2I(t)), "caster", g )
call StoreIntegerBJ( H2I(target), I2S(H2I(t)), "target", g )
call StoreIntegerBJ( H2I(dummycaster), I2S(H2I(t)), "dummycaster", g )
call StoreIntegerBJ( H2I(targets), I2S(H2I(t)), "targets", g )
call StoreIntegerBJ( H2I(dummycasters), I2S(H2I(t)), "dummycasters", g )
call StoreIntegerBJ( spell, I2S(H2I(t)), "spell", g )
call StoreBooleanBJ(isendcast, I2S(H2I(t)), "endcast", g)
call PolledWait(0.4)
call GroupRemoveUnitSimple( target, targets )
set tempgroup = GetRandomSubGroup(getOmniDrain_CapTargets()-1, targets)
call DestroyGroup(targets)
set targets = tempgroup
call GroupAddUnitSimple( target, targets )
call ForGroupBJ( targets, function Trig_MultiDrain_DmgEvent )
loop
call TriggerSleepAction(0.1)
exitwhen GetTriggerEvalCount(endcast)>0 or CountUnitsInGroup(dummycasters) == 0 or GetUnitCurrentOrder(caster) != String2OrderIdBJ("drain")
endloop
call PauseUnitBJ( true, caster )
call PauseUnitBJ( false, caster )
call ForGroupBJ( dummycasters, function Trig_MultiDrain_RemoveCasters )
call RemoveLocation(loc)
call RemoveLocation(targetloc)
call DestroyEffect(fx)
call PolledWait(0.1)
call FlushStoredInteger(g,"caster", I2S(H2I(t)))
call FlushStoredInteger(g,"t", I2S(H2I(caster)))
call FlushStoredInteger(g,"target", I2S(H2I(t)))
call FlushStoredInteger(g,"spell", I2S(H2I(t)))
call FlushStoredInteger(g,"targets", I2S(H2I(t)))
call FlushStoredBoolean(g,"endcast", I2S(H2I(t)))
call FlushStoredInteger(g,"dummycaster", I2S(H2I(t)))
call FlushStoredInteger(g,"dummycasters", I2S(H2I(t)))
call DestroyTrigger(t)
call DestroyTrigger(endcast)
call GroupClear(targets)
call DestroyGroup(targets)
call DestroyGroup(tempgroup)
call DestroyGroup(dummycasters)
set t = null
set endcast = null
set targets = null
set dummycasters = null
set loc = null
endfunction
//===========================================================================
function InitTrig_MultiDrain takes nothing returns nothing
local trigger m = CreateTrigger()
set gg_trg_MultiDrain = GameCache2Trigger(InitGameCache( "MultiDrain.w3v" ))
call TriggerRegisterAnyUnitEventBJ( m, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( m, Condition( function Trig_MultiDrain_InitConditions ) )
call TriggerAddAction( m, function Trig_MultiDrain_InitActions )
endfunction
Thanks!
Last edited: