Spell Bug Help :(

spectre37

New Member
Reaction score
1
My spell is Death Coil that cause damage and fear effect to the enemy target. There are 33% chance that debuff will be removed if target takes damage.

It's work well on first cast, but if I cast it on the same target. It will often cause no damage and debuff. :S


JASS:
scope deathcoil initializer Deathcoil_Init
function Trig_Death_Coil_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00R' 
endfunction

function Break_Fear takes nothing returns nothing
    local unit c = GetTriggerUnit()
    local integer i
    set i = GetRandomInt(1, 100)
    
    if i <= 33 and UnitHasBuffBJ(c, 'B00J') then
        call UnitRemoveBuffBJ('B00J', c)
        set c = null
    endif
endfunction

function Trig_Death_Coil_Actions takes nothing returns nothing
    local unit c = GetSpellAbilityUnit()
    local unit a = GetSpellTargetUnit()
    local location r = GetUnitLoc(a)
    local rect t = RectFromCenterSizeBJ(r, 1000, 1000)
    local trigger trg
    local real DC
    local location l
    local real e = 0
    set DC = I2R( (GetUnitAbilityLevelSwapped('A00R', c)*50) + 50 ) 
   
    loop
         exitwhen UnitHasBuffBJ(a, 'B00J') == true or e > 8.0
         set e = e + 0.1
         call TriggerSleepAction(0.1)
    endloop    
    call UnitDamageTargetBJ( c, a, DC, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC )
    set trg = CreateTrigger()
    call TriggerRegisterUnitEvent( trg, a, EVENT_UNIT_DAMAGED )
    call TriggerAddAction( trg, function Break_Fear ) 
    loop
        exitwhen UnitHasBuffBJ(a, 'B00J') == false
        set l = GetRandomLocInRect(t)
        call IssuePointOrderLoc(a, "move", l)
        call TriggerSleepAction(0.27)
        set l = null
    endloop
    set a = null
    call RemoveLocation(l)
endfunction

//===========================================================================
function Deathcoil_Init takes nothing returns nothing
    set gg_trg_Death_Coil = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Death_Coil, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Death_Coil, Condition( function Trig_Death_Coil_Conditions ) )
    call TriggerAddAction( gg_trg_Death_Coil, function Trig_Death_Coil_Actions )
endfunction
endscope
 

Frozenhelfir

set Gwypaas = Guhveepaws
Reaction score
56
While there are many many things wrong with this coding, I can point out what is giving you the trouble.
JASS:
    call TriggerRegisterUnitEvent( trg, a, EVENT_UNIT_DAMAGED )
    call TriggerAddAction( trg, function Break_Fear )


Here, you register the unit to a trigger. This trigger will stay around long after your spell ends, and it will stack up each time the spell is cast. If the spell is cast twice on this unit, it effectively has a 66% chance to break the fear. Third time is effectively 100% chance. This never goes away. How do you fix it? In your Break_Fear function, you have to unregister the events/actions and destroy "this trigger". That way, when the fear breaks, the Break_Fear is no longer being called.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
it effectively has a 66% chance to break the fear. Third time is effectively 100% chance.
False.

There is always a chance for it to not be removed.

Chance to be removed:

1 - (1 - ChancePerInstance)^(Instances)

So in this case:

1 - .67 ^ (Instances)

3rd time is only a 70% chance for removal :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top