| 05-14-2011, 08:27 AM | #1 |
I have a trigger ability,when test,it's very good with first time!But late(for greater than 9 times attack a unit),it's not happen! I try find error in this trigger but not effected! Here,my trigger: Code:
scope ThrowingAxe
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
globals
private constant integer abiID = 'A048'
private integer isl = 0
private integer idl = 0
endglobals
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private struct Throw2 extends xecollider
unit source
unit tar
real dam2
method onUnitHit takes unit target returns nothing
if IsUnitEnemy(target, GetOwningPlayer(this.source)) and (this.source != target) and GetWidgetLife(target)>0.405 and (this.tar != target) and GetUnitAbilityLevel(target, resID) == 0 then
call DestroyEffect(AddSpecialEffectTarget("MDX\\HitStrike.mdx", target, "chest"))
call DamageTarget(this.source, target, this.dam2, AT,DAMAGE_TYPE_ENHANCED, true,true)
set isl = (GetUnitAbilityLevel(this.source, 'A048')+20)+(GetUnitAbilityLevel(this.source,'A047')*2)
set idl = (GetUnitAbilityLevel(this.source, 'A048')+20)
if isl>GetRandomInt(1,100) then
call TargetCast(this.source,target,'A00C',"slow",1)
endif
if idl>GetRandomInt(1,100) then
call KBS_BeginEx(target,90,0.40,GetUnitFacing(this.source)-180,"Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl",0,false,true)
endif
endif
endmethod
method onDestroy takes nothing returns nothing
set this.source = null
set this.tar = null
endmethod
method onExpire takes nothing returns nothing
call this.terminate()
endmethod
endstruct
private struct Throwa extends xecollider
unit source
unit tar
real dam
real goc
real goc2
method onUnitHit takes unit target returns nothing
if IsUnitEnemy(target, GetOwningPlayer(this.source)) and (this.source != target) and GetWidgetLife(target)>0.405 and (this.tar != target) and GetUnitAbilityLevel(target, resID) == 0 then
call DestroyEffect(AddSpecialEffectTarget("MDX\\HitStrike.mdx", target, "chest"))
call DamageTarget(this.source, target, this.dam, AT,DAMAGE_TYPE_ENHANCED, true,true)
set isl = (GetUnitAbilityLevel(this.source,abiID)+20)+(GetUnitAbilityLevel(this.source,'A047')*2)
if isl>GetRandomInt(1,100) then
call TargetCast(this.source,target,'A00C',"slow",1)
endif
endif
endmethod
method onDestroy takes nothing returns nothing
local Throw2 fx
set fx = Throw2.create(GetLocationX(PolarProjectionBJ(GetUnitLoc(this.source), 800, this.goc2*bj_RADTODEG)), GetLocationY(PolarProjectionBJ(GetUnitLoc(this.source), 800, this.goc2*bj_RADTODEG)) , this.goc)
set fx.fxpath = "MDX\\AxeMissile.mdx"
set fx.z = 50.0
set fx.speed = 1100
set fx.scale = 1.6
set fx.expirationTime = 0.80
set fx.source = this.source
set fx.dam2 = this.dam
////////////////////////////////////////////////////////////
set this.source = null
set this.tar = null
endmethod
method onExpire takes nothing returns nothing
call this.terminate()
endmethod
endstruct
function Trig_ThrowingAxe_Actions takes nothing returns nothing
local unit c=GetEventDamageSource()
local unit t = GetTriggerUnit()
local real cx=GetUnitX(c)
local real cy=GetUnitY(c)
local real tx=GetUnitX(t)
local real ty=GetUnitY(t)
local real ang=Atan2(ty-cy,tx-cx)
local real tttdam=0
local real tttalldam=0
local Throwa fx
call DisableTrigger( GetTriggeringTrigger() )
if (UnitHasBuffBJ(t,'B01P')==true) then
call UnitRemoveBuffBJ('B01P',t)
set Resist[GetPlayerId(GetOwningPlayer(c))] = 0.20
set tttdam = ((I2R(GetUnitAbilityLevel(c,abiID))))*GetRandomReal(145,160)
set tttalldam = ((I2R(GetHeroStr(c,true)))*1.7) + tttdam
set fx = Throwa.create(cx, cy , ang)
set fx.fxpath = "MDX\\AxeMissile.mdx"
set fx.z = 50.0
set fx.speed = 1000
set fx.scale = 1.6
set fx.expirationTime = 0.80
set fx.source = c
set fx.dam = tttalldam
set fx.goc = Atan2(cy-ty,cx-tx)
set fx.goc2 = ang
endif
call EnableTrigger( GetTriggeringTrigger() )
set c=null
set t=null
endfunction
//===========================================================================
function InitTrig_ThrowingAxe takes nothing returns nothing
set gg_trg_TienThanTram = CreateTrigger( )
call TriggerAddAction( gg_trg_ThrowingAxe, function Trig_ThrowingAxe_Actions )
endfunction
endscopePlease help me!Thank you so much! |
| 05-14-2011, 09:05 PM | #2 |
Well, I copied your code into a test map and it works without any problems for multiple attacks. I did have to make some changes to your code, though:
This is my edited code that seems to work:scope ThrowingAxe //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ globals private constant integer abiID = 'A048' private constant integer buffID = 'Bspo' private integer isl = 0 private integer idl = 0 endglobals //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private struct Throw2 extends xecollider unit source unit tar real dam2 method onUnitHit takes unit target returns nothing // if IsUnitEnemy(target, GetOwningPlayer(this.source)) and (this.source != target) and GetWidgetLife(target)>0.405 and (this.tar != target) and GetUnitAbilityLevel(target, resID) == 0 then call DestroyEffect(AddSpecialEffectTarget("MDX\\HitStrike.mdx", target, "chest")) // call DamageTarget(this.source, target, this.dam2, AT,DAMAGE_TYPE_ENHANCED, true,true) set isl = (GetUnitAbilityLevel(this.source, 'A048')+20)+(GetUnitAbilityLevel(this.source,'A047')*2) set idl = (GetUnitAbilityLevel(this.source, 'A048')+20) if isl>GetRandomInt(1,100) then // call TargetCast(this.source,target,'A00C',"slow",1) endif if idl>GetRandomInt(1,100) then // call KBS_BeginEx(target,90,0.40,GetUnitFacing(this.source)-180,"Abilities\\Spells\\Other\\Stampede\\StampedeMissileDeath.mdl",0,false,true) endif // endif endmethod method onDestroy takes nothing returns nothing set this.source = null set this.tar = null endmethod method onExpire takes nothing returns nothing call this.terminate() endmethod endstruct private struct Throwa extends xecollider unit source unit tar real dam real goc real goc2 method onUnitHit takes unit target returns nothing // if IsUnitEnemy(target, GetOwningPlayer(this.source)) and (this.source != target) and GetWidgetLife(target)>0.405 and (this.tar != target) and GetUnitAbilityLevel(target, resID) == 0 then call DestroyEffect(AddSpecialEffectTarget("MDX\\HitStrike.mdx", target, "chest")) // call DamageTarget(this.source, target, this.dam, AT,DAMAGE_TYPE_ENHANCED, true,true) set isl = (GetUnitAbilityLevel(this.source,abiID)+20)+(GetUnitAbilityLevel(this.source,'A047')*2) if isl>GetRandomInt(1,100) then // call TargetCast(this.source,target,'A00C',"slow",1) endif // endif endmethod method onDestroy takes nothing returns nothing local Throw2 fx set fx = Throw2.create(GetLocationX(PolarProjectionBJ(GetUnitLoc(this.source), 800, this.goc2*bj_RADTODEG)), GetLocationY(PolarProjectionBJ(GetUnitLoc(this.source), 800, this.goc2*bj_RADTODEG)) , this.goc) set fx.fxpath = "Abilities\\Weapons\\SentinelMissile\\SentinelMissile.mdl" set fx.z = 50.0 set fx.speed = 1100 set fx.scale = 1.6 set fx.expirationTime = 0.80 set fx.source = this.source set fx.dam2 = this.dam //////////////////////////////////////////////////////////// set this.source = null set this.tar = null endmethod method onExpire takes nothing returns nothing call this.terminate() endmethod endstruct function Trig_ThrowingAxe_Actions takes unit damagedUnit, unit damageSource, real damage returns nothing local unit c=damageSource local unit t = damagedUnit local real cx=GetUnitX(c) local real cy=GetUnitY(c) local real tx=GetUnitX(t) local real ty=GetUnitY(t) local real ang=Atan2(ty-cy,tx-cx) local real tttdam=0 local real tttalldam=0 local Throwa fx call DisableTrigger( GetTriggeringTrigger() ) if (UnitHasBuffBJ(t,buffID)==true) then call UnitRemoveBuffBJ(buffID,t) // set Resist[GetPlayerId(GetOwningPlayer(c))] = 0.20 set tttdam = ((I2R(GetUnitAbilityLevel(c,abiID))))*GetRandomReal(145,160) set tttalldam = ((I2R(GetHeroStr(c,true)))*1.7) + tttdam set fx = Throwa.create(cx, cy , ang) set fx.fxpath = "Abilities\\Weapons\\SentinelMissile\\SentinelMissile.mdl" set fx.z = 50.0 set fx.speed = 1000 set fx.scale = 1.6 set fx.expirationTime = 0.80 set fx.source = c set fx.dam = tttalldam set fx.goc = Atan2(cy-ty,cx-tx) set fx.goc2 = ang endif call EnableTrigger( GetTriggeringTrigger() ) set c=null set t=null endfunction //=========================================================================== function InitTrig_ThrowingAxe takes nothing returns nothing call RegisterDamageResponse( Trig_ThrowingAxe_Actions ) call CreateUnit(Player(0), 'edry', 0.0,-500.0,0.0) endfunction endscope |
| 05-15-2011, 12:06 AM | #3 |
Yeah! It's very useful!DamageEvent was repair this error for me!And by you!Thank you so much!I did it and tested, it's best quality!!:) |
