S
spectre237
Guest
Ok, see I've got this 'Omnislash' type ability, it's really kewl. Thanks Vex!
Anyway the deal is I need to edit it so that the hero becomes invulnerable for it's duration.
The entire script runs as follows:
Any help you could provide would be most appreciated.
Anyway the deal is I need to edit it so that the hero becomes invulnerable for it's duration.
The entire script runs as follows:
PHP:
//********************************************************************** *****************************
//*
//* Slash Template
//* ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//* Requires:
//* -A triggerer ability ( Unit targetable please)
//* -The Caster System
//* -The Alternative Spell Templates System
//* -This Trigger
//*
//* Art: The Triggerer ability has art fields that are considered:
//* - Caster effect is attached twice to the hero during the slash.
//* - Second and Third Caster Effects are attachment points for the Caster Effect
//* - Special effect is used on the feet of the hero before teleporting to slash
//* - Target art is the target effect, or the periodic damage effect if used, and the
//* second target effect is its attachment point.
//*
//********************************************************************** *****************************
//====================================================================== =============================
// Slash Template Configuration:
//
function SlashTemplateSetup takes nothing returns nothing
local integer D //An integer variable we use later to save the Damage Options so we give them to the templates
local integer s //An integer variable we use later to save the rawcodes of spells to save some time
//====================================================================== =============================
// Template Info:
//
// Template Name Id = "SlashTemplate"
//
// The hero just gets teleported and attacks the targets fast, it looks nice and allows to cast
// a spell, do damage, damage per second, and also has options for the way to choose targets and
// factor for each target and that stuff.
//
//
// integer "totalhits" The maximum number of hits done per cast
// real "dmg" The initial damage
// real "PDmg" The initial Periodic Damage
// real "PDmgPeriod" The period of the Periodic Damage
// real "PDmgDur" The Duration of the periodic Damage
//
// real "dmgfct" The factor per target for the damage, each time the unit hits a target,
// the damage will be multiplied by this value to get reduced or incremented
//
// integer "Spell" Rawcode of the Spell to cast (if any)
// real "SpellHeight" Height of the caster that casts the spell to cast
// integer "OrderId" Order Id of that spell
// real "RecDelay" Caster Recycle delay for that spell
//
//
// real "area" The new target detection range
// integer "canrepeat" Is 1 if the slash can repeat targets, otherwise 0
//
// integer "SelMethod" Is 0 if the slash should pick the closest unit, 1 to pick random units
// integer "SlashKind" The kind of the Slash, 0 will try to get to the back of the unit, 1
// will attack in random direction, and 2 is a combination of both
//
// integer "AngleKind" Is 0 for the default angle kind, is 1 to multiple the angle by -1
//
// string "animation" The animation used by the slash
//
// integer "colorize" If it is 1 enables casting unit "colorizing"
// integer "SlashColor" Color in 0xAARRGGBB form for the duration of the slash
// integer "EndColor" Color in 0xAARRGGBB form after the slash (original color of the hero)
//
// integer "DamageOptions" Caster System Damage Options in saveable form, used to determine which
// units can be attacked by the slash, if the damage factor is 0 the unit
// is not affected by the target spells nor damage, otherwise the value
// is only important as a damage factor.
//====================================================================== =============================
// Slash template Defaults:
//
call SetTemplateDefaultInt( "SlashTemplate", "totalhits", 1) //Default Total Hits is 1
call SetTemplateDefaultInt( "SlashTemplate", "canrepeat", 0) //Can't repeat targets
call SetTemplateDefaultReal( "SlashTemplate", "area", 100) //Default area is 100
call SetTemplateDefaultReal( "SlashTemplate", "dmg", 150) //Default initial damage is 150
call SetTemplateDefaultReal( "SlashTemplate", "dmgfct", 1) //Default damage factor is 1
call SetTemplateDefaultString("SlashTemplate", "animation", "attack slam") //Default animation is attack slam
call SetTemplateDefaultInt( "SlashTemplate", "SlashColor", 0xFFFFFFFF) //Default slash color is 255-255-255-255
call SetTemplateDefaultInt( "SlashTemplate", "EndColor" , 0xFFFFFFFF) //Default end color is 255-255-255-255
//====================================================================== =============================
// Cold Slash ('A006')
//
set s=SetSpellTemplate('A006',"SlashTemplate")
set D=0 //Cold Slash Options :
set D=DamageTypes(ATTACK_TYPE_NORMAL,DAMAGE_TYPE_COLD) //Cold spell damage
set D=DamageOnlyEnemies() //Only hurt enemies
set D=CreateDamageOptions(D) //Save the damage options
call SetAbilityDataInt( s,"totalhits",1,3) //Level 1: 3 hits
call SetAbilityDataInt( s,"totalhits",2,5) //Level 2: 5 hits
call SetAbilityDataInt( s,"totalhits",3,7) //Level 3: 7 hits
call SetAbilityDataReal(s,"dmg",1,150) //Level 1: 150 damage
call SetAbilityDataReal(s,"dmg",2,200) //Level 2: 200 damage
call SetAbilityDataReal(s,"dmg",3,250) //Level 3: 250 damage
call SetAbilityDataReal(s,"area",1,360) //Level 1: 360 area
call SetAbilityDataReal(s,"area",2,370) //Level 2: 370 area
call SetAbilityDataReal(s,"area",3,380) //Level 3: 380 area
call SetAbilityDataInt( s,"DamageOptions",0,D) //Using the damage options saved before
call SetAbilityDataString(s,"animation",0,"attack slam") //Use attack slam animation
//====================================================================== =============================
// Fire Slash ('A00D')
//
set s=SetSpellTemplate('A00D',"SlashTemplate")
set D=0 //Fire Slash Options :
set D=DamageTypes(ATTACK_TYPE_NORMAL,DAMAGE_TYPE_FIRE) //Fire spell damage
set D=DamageOnlyEnemies() //Only hurt enemies
set D=CreateDamageOptions(D) //Save the damage options
call SetAbilityDataInt( s,"totalhits",0,5) //5 Hits
call SetAbilityDataReal(s,"dmg",1,200) //Level 1: 200 damage
call SetAbilityDataReal(s,"dmg",2,270) //Level 2: 270 damage
call SetAbilityDataReal(s,"dmg",3,340) //Level 3: 340 damage
call SetAbilityDataReal(s,"area",0,500) //Always 500 of area
call SetAbilityDataInt( s,"SlashKind",0,2) //Slash Kind is 2
call SetAbilityDataInt( s,"canrepeat",0,1) //It can repeat targets!
call SetAbilityDataReal(s,"dmgfct",0,0.75) //Will lose 25% of the damage per target
call SetAbilityDataString(s,"animation",0,"attack") //Use attack animation
call SetAbilityDataInt( s,"DamageOptions",0,D) //Using the damage options saved before
endfunction
//====================================================================== =============================
function SlashTemplate_DoSpell takes player ow, unit t, integer s, integer l returns nothing
local integer ab=GetAbilityDataInt(s,l,"Spell")
if (ab!=0) then
call CasterCastAbilityEx(ow,GetUnitX(t),GetUnitY(t),GetAbilityDataReal(s,l, "SpellHeight"),ab,l,I2S(GetAbilityDataInt(s,l,"OrderId") ),t,GetAbilityDataReal(s,l,"RecDelay") )
endif
endfunction
function SlashTemplate_Colorize takes unit u, integer rgb returns nothing
local integer Y=rgb+IntegerTertiaryOp(rgb<0,0x80000000,0)
local integer Z
local integer r
local integer g
local integer b
set Z=Y/0x100
set b=Y-(Z*0x100)
set Y=Z/0x100
set g=Z-(Y*0x100)
set Z=Y/0x100
set r=Y-(Z*0x100)
if (rgb<0) then
set Z=Z+128
endif
call SetUnitVertexColor(u,r,g,b,Z)
endfunction
function SlashTemplate takes nothing returns nothing
local unit u=GetTriggerUnit()
local integer s=GetSpellAbilityId()
local integer l=GetUnitAbilityLevel( u, s )
local group targetlog=CreateGroup()
local group inrange=CreateGroup()
local integer i=GetAbilityDataInt( s,l, "totalhits")
local unit target=GetSpellTargetUnit()
local unit picked
local unit other=GetSpellTargetUnit()
local real grad=GetUnitX( u)
local real damage=GetAbilityDataReal(s,l,"dmg")
local effect fx1=AddSpellEffectTargetById( s, EFFECT_TYPE_CASTER, u, GetAbilityEffectById(s,EFFECT_TYPE_CASTER,1))
local effect fx2=AddSpellEffectTargetById( s, EFFECT_TYPE_CASTER, u, GetAbilityEffectById(s,EFFECT_TYPE_CASTER,2))
local real x
local real y
local real tx
local real ty
local real d
local integer dop
local real fc
local real dmgps=GetAbilityDataReal(s,l,"PDmg")
local real period=GetAbilityDataReal(s,l,"PDmgPeriod")
local real dur=GetAbilityDataReal(s,l,"PDmgDur")
local integer ki=GetAbilityDataInt(s,l,"SlashKind")
local boolean closest=(GetAbilityDataInt(s,l,"SelMethod")==0)
local boolean color = (GetAbilityDataInt(s,l,"colorize")==1 )
call PauseUnit(u, true)
call SetUnitPathing(u,false)
if (color) then
call SlashTemplate_Colorize(u,GetAbilityDataInt(s,l,"SlashColor"))
endif
loop
call GroupAddUnit( targetlog,target)
set x=GetUnitX(u)
set y=GetUnitY(u)
set tx=GetUnitX(target)
set ty=GetUnitY(target)
call DestroyEffect( AddSpellEffectById( s, EFFECT_TYPE_SPECIAL, x,y ) )
call SetUnitAnimation( u, GetAbilityDataString(s,l,"animation") )
call TriggerSleepAction(0)
if ((ki==0) or ((ki==2) and (GetRandomInt(0,1)==0))) then
set grad=Atan2( ty - y, tx - x )
else
set grad=GetRandomReal(0,2*bj_PI)
endif
set x=100*Cos(grad)
set y=100*Sin(grad)
if (GetAbilityDataInt(s,l,"AngleKind")==1) then
set x=-x
set y=-y
endif
set x=tx+x
set y=ty+y
call SetUnitFacing( u, grad*bj_RADTODEG )
call SetUnitPosition( u, x, y )
set dop=LoadDamageOptions(GetAbilityDataInt(s,l,"DamageOptions"))
set fc=GetDamageFactorByOptions(u,target,dop)
if (fc!=0) then
call UnitDamageTarget( u,target, damage*fc,true,false,null,null,null)
call SlashTemplate_DoSpell(GetOwningPlayer(u),target,s,l)
if (dmgps!=0) then
call UnitDamageUnitTimed(u,dmgps*fc,period,dur,target,GetAbilityEffectById( s,EFFECT_TYPE_TARGET,0),GetAbilityEffectById(s,EFFECT_TYPE_TARGET,1),n ull,null)
else
call DestroyEffect( AddSpellEffectTargetById( s, EFFECT_TYPE_TARGET, target, GetAbilityEffectById(s,EFFECT_TYPE_TARGET,1) ) )
endif
endif
call TriggerSleepAction(0)
set x=GetAbilityDataReal(s,l,"dmgfct")
set damage=damage*x
set dmgps=dmgps*x
set x=GetUnitX(u)
set y=GetUnitY(u)
set tx=GetUnitX(target)
set ty=GetUnitY(target)
set i=i-1
exitwhen (i==0) or (GetWidgetLife(u)<1)
call GroupClear(inrange)
call GroupEnumUnitsInRange(inrange, tx, ty , GetAbilityDataReal(s,l,"area") , null)
set target=null
set other=null
if closest then
set grad=1000000
else
set grad=0
endif
set dop=LoadDamageOptions(GetAbilityDataInt(s,l,"DamageOptions"))
loop
set picked=FirstOfGroup(inrange)
exitwhen (picked==null)
set fc=GetDamageFactorByOptions(u,picked,dop)
if (fc!=0) then
if closest then
set d=SquareRoot( Pow(x-GetUnitX(picked),2) + Pow(y-GetUnitY(picked),2) )
else
set d=GetRandomInt(0,R2I(grad+1))
endif
if (d <= grad) then
if not( IsUnitInGroup(picked,targetlog) ) then
if closest then
set grad=d
endif
set target=picked
endif
if not(closest) then
set grad=grad+1
endif
set other=picked
endif
endif
call GroupRemoveUnit(inrange,picked)
endloop
if (target==null) and (GetAbilityDataInt(s,l,"canrepeat") == 1) then
set target=other
endif
exitwhen (target==null)
endloop
if (color) then
call SlashTemplate_Colorize(u,GetAbilityDataInt(s,l,"EndColor"))
endif
call DestroyEffect( AddSpellEffectTargetById( s, EFFECT_TYPE_SPECIAL, u, "origin" ) )
call PauseUnit(u,false)
call SetUnitPathing(u,true)
call SetUnitPosition(u, GetUnitX(u), GetUnitY(u) )
call DestroyEffect(fx1)
call DestroyEffect(fx2)
set fx1=null
set fx2=null
set u=null
call DestroyGroup(targetlog)
set targetlog=null
call DestroyGroup(inrange)
set inrange=null
set target=null
set other=null
endfunction
function InitTrig_Slash_Template takes nothing returns nothing
call ExecuteFunc("SlashTemplateSetup")
//Must use ExecuteFunc to prevent the Map init thread from getting too long and crash.
endfunction
Any help you could provide would be most appreciated.


