• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[vJASS] Spell Problem leaks

Status
Not open for further replies.
Level 4
Joined
Apr 7, 2012
Messages
63
When the unit is attacked there is a chance that the attacker will be stunned.The problem is the unit doesn't even have the ability and the attacker still get stunned.

JASS:
scope MiniStun initializer Init

globals
      private constant integer MiniStunId = 'A005'
      private constant integer DummyId = 'o000'
      private constant integer EarthSkinId = 'A004'
      private constant string MiniStunEffect = "Objects\\Spawnmodels\\Demon\\DemonLargeDeathExplode\\DemonLargeDeathExplode.mdl"
endglobals

private function Chance takes integer level returns integer
    //returns the chance that the unit will be stunned
          return 15+level*2
    endfunction

private function Duration takes integer level returns integer
    
          return level*1
    endfunction

    private function Targets takes unit Enemy returns boolean
    //the units the spell will effect
         return (GetWidgetLife(Enemy) > 0.405) and(IsUnitType(Enemy, UNIT_TYPE_STRUCTURE) == false) and(IsUnitType(Enemy, UNIT_TYPE_MAGIC_IMMUNE) == false) and(IsUnitType(Enemy, UNIT_TYPE_MECHANICAL) == false)  
    endfunction 
    
private function MiniStun_Conditions takes nothing  returns boolean 
    return GetUnitTypeId(GetTriggerUnit()) == 'H003'
     return GetUnitAbilityLevel(GetTriggerUnit(),EarthSkinId) >= 1
endfunction

    
     
private function Actions takes nothing returns nothing
     local unit Enemy = GetAttacker()
     local unit AttackedUnit = GetTriggerUnit()
     local real EnemyX
     local real EnemyY
     local unit dummy
     local integer level = GetUnitAbilityLevel(AttackedUnit,EarthSkinId)
     
     if GetRandomInt(0,100) <= Chance then 
          set dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DummyId, GetUnitX(Enemy), GetUnitY(Enemy), 0)
     endif
     call UnitAddAbility(dummy,MiniStunId)
     if Duration == 1 then  
         call SetUnitAbilityLevel(AttackedUnit,MiniStunId,1)
     
     elseif Duration == 2 then
         call SetUnitAbilityLevel(AttackedUnit,MiniStunId,2)
     
     elseif Duration == 3 then
        call SetUnitAbilityLevel(AttackedUnit,MiniStunId,3)
     endif                   
         call IssueTargetOrder(dummy,"thunderbolt",Enemy)
         call DestroyEffect(AddSpecialEffectTarget(MiniStunEffect, Enemy, "origin")) 
         call UnitApplyTimedLife(dummy,'BTLF',2) 
 endfunction      
      

//===========================================================================
private function Init takes nothing returns nothing
    local trigger MiniStunTrg = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( MiniStunTrg, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( MiniStunTrg, Condition( function MiniStun_Conditions ) )
    call TriggerAddAction( MiniStunTrg, function Actions )
    call Preload(MiniStunEffect)
endfunction
endscope

Any ideas?
 
Last edited:
Level 29
Joined
Mar 10, 2009
Messages
5,016
JASS:
private function MiniStun_Conditions takes nothing  returns boolean 
    return GetUnitTypeId(GetTriggerUnit()) == 'H003'
     return GetUnitAbilityLevel(GetTriggerUnit(),EarthSkinId) >= 1
endfunction

--->
JASS:
private function MiniStun_Conditions takes nothing  returns boolean 
     return GetUnitAbilityLevel(GetTriggerUnit(),EarthSkinId) >= 1 and GetUnitTypeId(GetTriggerUnit()) == 'H003'
endfunction
 
Status
Not open for further replies.
Top