| 02-08-2007, 04:28 AM | #1 |
Hello, i have an ability called Sandskin, consist in when the unit with this passive ability is attacked and the attacker are melee, the unit recives no damage and the attacker deal the damage to the closest creature (enemy or not) if there was one. If the attacker are ranged the damage is inflicted to the unit behind the attacked unit if there was one. The ability works fine, and has a chance of succes, but when a unit with the WC3 Envenomed Weapons (Neutral Hostile) attacks my unit (with the skill obviosly) the maps crash!! with no message of error, nothing!!! Well, the code is here: JASS:function Trig_Arena_Conditions takes nothing returns boolean return GetUnitAbilityLevel(GetTriggerUnit(),'A01T') > 0 endfunction function Arena_Do takes nothing returns nothing local unit victim = GetTriggerUnit() local unit source = GetEventDamageSource() local real damage = GetEventDamage() local real vida = GetUnitState(victim,UNIT_STATE_LIFE) local real x1 = GetUnitX(victim) local real y1 = GetUnitY(victim) local real x2 = GetUnitX(source) local real y2 = GetUnitY(source) local real xp local real yp local group g local unit j set g = CreateGroup() call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Undead\\ImpaleTargetDust\\ImpaleTargetDust.mdl",x1,y1)) call SetUnitState(victim,UNIT_STATE_LIFE,vida+damage) if(IsUnitType(source,UNIT_TYPE_MELEE_ATTACKER))then set xp =(x1+x2)/2 set yp =(y1+y2)/2 call GroupEnumUnitsInRange(g,xp,yp,200,null) set j = FirstOfGroup(g) loop set j = FirstOfGroup(g) call GroupRemoveUnit(g,j) exitwhen (j!=victim) and (j!=source) and (GetUnitState(j,UNIT_STATE_LIFE)>0.405) endloop call DestroyGroup(g) call SetUnitFacing(source,GetAngleBetweenPoints(x2,y2,GetUnitX(j),GetUnitY(j))) endif if(IsUnitType(source,UNIT_TYPE_RANGED_ATTACKER))then call GroupEnumUnitsInRange(g,x1,y1,200,null) set j = FirstOfGroup(g) loop set j = FirstOfGroup(g) call GroupRemoveUnit(g,j) exitwhen GetAngleBetweenPoints(x1,y1,x2,x2)-GetAngleBetweenPoints(x1,y1,GetUnitX(j),GetUnitY(j))<=30 and GetAngleBetweenPoints(x1,y1,GetUnitX(j),GetUnitY(j))-GetAngleBetweenPoints(x1,y1,x2,x2)>=30 endloop call DestroyGroup(g) endif call UnitDamageTarget(source,j,damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null) set victim = null set source = null set j = null set g = null endfunction function Trig_Arena_Actions takes nothing returns nothing local unit u = GetTriggerUnit() local integer l = GetUnitAbilityLevel(u,'A01T')*8 local integer i = GetRandomInt(1,100) local trigger t if(i<=l)then set t = CreateTrigger() call TriggerRegisterUnitEventDamaged(t,u) call TriggerAddAction(t, function Arena_Do) call TriggerSleepAction(1.5) call DestroyTrigger(t) endif set u = null set t = null endfunction //=========================================================================== function InitTrig_Arena takes nothing returns nothing set gg_trg_Arena = CreateTrigger( ) call TriggerRegisterAnyUnitEventBJ( gg_trg_Arena, EVENT_PLAYER_UNIT_ATTACKED ) call TriggerAddCondition( gg_trg_Arena, Condition( function Trig_Arena_Conditions ) ) call TriggerAddAction( gg_trg_Arena, function Trig_Arena_Actions ) endfunction Thanks in advance |
| 02-08-2007, 04:36 AM | #2 | |
Quote:
Just try this -- Instead of using JASS:call UnitDamageTarget(source,j,damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null) JASS:call DisableTrigger(GetTriggeringTrigger()) call UnitDamageTarget(source,j,damage,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,null) call EnableTrigger(GetTriggeringTrigger()) |
| 02-08-2007, 04:38 AM | #3 |
Ok, thanks now is fine!!! |
