• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!

Some weird bugs with a JASS spell

Status
Not open for further replies.
Level 16
Joined
Dec 15, 2011
Messages
1,423
Hey guys I am having some really ridiculous bugs with a JASS spell. Long story short, I took care of the JASS spells for The Chosen Ones campaign (created by Aeroblyctos) and after some heavy testing to confirm that my spell worked perfectly I finally imported an ability to the campaign. A few days after the initial release of the campaign version with the spell some guys reported these bugs:

MYSTIC STORM KILLS ANYTHING IN ONE STRIKE, you get no gold or XP as well. Against Ch 2 Epic, it worked properly for a while. Reduced HP and armor with each strike. When he summones zombies, a secondary red strike would emit from the cloud and one hit kill them. At one time it OHK'd the epic boss too. I reloaded and it didn't do that again. It kills the ELITE boss just the same as any other enemy though, instant death.

And to add insult to injury, when I test the ability (imported into the campaign) myself no bug happens at all. This is just way too wrong. I am really desperate because this is my first time experiencing something of this calibre.

Here is the code for those interested

JASS:
function Trig_Mystic_Storm_Conditions takes nothing returns boolean
    return ( GetSpellAbilityId() == 'A6N1' ) 
endfunction

function FilterUnit takes nothing returns boolean
    return (IsUnitEnemy(GetFilterUnit(), Player(0)) == true and GetWidgetLife(GetFilterUnit()) > 0.405 and GetUnitAbilityLevel(GetFilterUnit(), 'Avul') == 0 and IsUnitType (GetFilterUnit(), UNIT_TYPE_MAGIC_IMMUNE) == false and IsUnitVisible(GetFilterUnit(), Player(0)) == true)
endfunction

function GroupCallBack takes nothing returns nothing
    call UnitRemoveAbility( GetEnumUnit(), 'A6N8')
endfunction

function ReduceArmor takes unit target returns nothing
local integer array armor
local integer level1 = GetUnitAbilityLevel(target, 'A6N6')
local integer level2 = GetUnitAbilityLevel(target, 'A6N7')
local real armorreduce = I2R(level1*1+level2*10)
local real armorcalc
local integer tempdivider
local integer tempint
local integer i

set armor[0] = 'A6N7'
set armor[1] = 'A6N6'
if armorreduce == 0 then
call UnitAddAbility( target, 'A6N8')
else
set armorreduce = I2R((level1-1)*1+(level2-1)*10)
set armorcalc = armorreduce + 1
set i = 0
set tempint = 0
set tempdivider = 10
loop
exitwhen i == 2
set tempint = R2I(armorcalc/tempdivider)
call SetUnitAbilityLevel(target, armor[i], tempint+1)
set armorcalc = armorcalc - I2R(tempint*tempdivider)
set tempdivider = tempdivider/10
set i = i + 1
endloop
endif
endfunction

function DamageTarget takes nothing returns nothing
local timer t = GetExpiredTimer()
local group g = CreateGroup()
local unit caster = LoadUnitHandle(udg_Hashtable, GetHandleId(t), 0)
local unit target = LoadUnitHandle(udg_Hashtable, GetHandleId(t), 1)
local integer id = LoadInteger (udg_Hashtable, GetHandleId(t), 2)

call UnitDamageTarget(caster, target, I2R(udg_YMultiboard__MYSTICSTORM), true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, null)
call ReduceArmor (target)
call GroupAddUnit (g, target)
call SaveGroupHandle(udg_Hashtable, id, 3, g)

call PauseTimer(t)
call DestroyTimer(t)
set caster = null
set target = null
set g = null
set t = null
endfunction

function LifeCheck takes unit caster, unit stormfx, integer id returns nothing
local group g = CreateGroup()
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local unit target
local timer t
local unit u

call GroupEnumUnitsInRange(g, x, y, 600, Condition(function FilterUnit))
set u = GroupPickRandomUnit(g)
set target = u
call GroupRemoveUnit(g, u)
call DestroyGroup(g)
set g = null
set u = null
if target != null then
call IssueTargetOrder (stormfx, "fingerofdeath", target)
set t = CreateTimer ()
call SaveUnitHandle(udg_Hashtable, GetHandleId(t), 0, caster)
call SaveUnitHandle(udg_Hashtable, GetHandleId(t), 1, target)
call SaveInteger(udg_Hashtable, GetHandleId(t), 2, id)
call SaveUnitHandle(udg_Hashtable, GetHandleId(t), 4, stormfx)
call TimerStart (t, 0.3, false, function DamageTarget)

set caster  = null
set stormfx = null
set target = null
set t = null
endif
endfunction

function Mystic_Storm_Periodic takes nothing returns nothing
local trigger trig = GetTriggeringTrigger()
local unit caster = LoadUnitHandle(udg_Hashtable, GetHandleId(trig), 1)
local unit stormfx = LoadUnitHandle(udg_Hashtable, GetHandleId(trig), 2)
local unit dummy1 = LoadUnitHandle(udg_Hashtable, GetHandleId(trig), 5)
local unit dummy2 = LoadUnitHandle(udg_Hashtable, GetHandleId(trig), 6)
local triggeraction tga = LoadTriggerActionHandle(udg_Hashtable, GetHandleId(trig), 0)
local integer evalcount = GetTriggerEvalCount(trig)
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local group g
local group g1
local integer i = 0

if(GetTriggerEventId()==EVENT_UNIT_DEATH)then
if(GetDyingUnit() == caster)then
call KillUnit (stormfx)
endif
set g = LoadGroupHandle(udg_Hashtable, GetHandleId(trig), 3)
call ForGroup (g, function GroupCallBack)
call DestroyGroup (g)
set g = null
set caster = null
set dummy1 = null
set dummy2 = null
set stormfx = null
call DisableTrigger (trig)
call TriggerRemoveAction (trig, tga)
call DestroyTrigger (trig)
set tga = null
set trig = null
else
if ModuloInteger(evalcount, 10) == 0 or evalcount == 1 then
set g1 = CreateGroup()
call GroupEnumUnitsInRange(g1, x, y, 600, Condition(function FilterUnit))
set i = CountUnitsInGroup(g1)
if i == 1 then
call LifeCheck(caster, stormfx, GetHandleId(trig))
elseif i == 2 then
call LifeCheck(caster, stormfx, GetHandleId(trig))
call LifeCheck(caster, dummy1, GetHandleId(trig))
else
call LifeCheck(caster, stormfx, GetHandleId(trig))
call LifeCheck(caster, dummy1, GetHandleId(trig))
call LifeCheck(caster, dummy2, GetHandleId(trig))
endif
call DestroyGroup (g1)
set g1 = null
endif
call SetUnitPosition(stormfx, x, y)
call SetUnitPosition(dummy1, x, y)
call SetUnitPosition(dummy2, x, y)
endif
endfunction

function Trig_Mystic_Storm_Actions takes nothing returns nothing
local trigger trig = CreateTrigger()
local unit caster = GetTriggerUnit()
local real x = GetUnitX(caster)
local real y = GetUnitY(caster)
local unit stormfx = CreateUnit(GetOwningPlayer(caster), 'h65M', x, y, bj_UNIT_FACING)
local unit dummy1 = CreateUnit(GetOwningPlayer(caster), 'h66V', x, y, bj_UNIT_FACING)
local unit dummy2 = CreateUnit(GetOwningPlayer(caster), 'h66V', x, y, bj_UNIT_FACING)

call UnitAddAbility(stormfx, 'A6N5')
call UnitApplyTimedLife (stormfx, 'BTLF', 30.00)
call UnitAddAbility(dummy1, 'A6NE')
call UnitApplyTimedLife (dummy1, 'BTLF', 30.00)
call UnitAddAbility(dummy2, 'A6NF')
call UnitApplyTimedLife (dummy2, 'BTLF', 30.00)
call TriggerRegisterTimerEvent(trig, 0.05, true)
call TriggerRegisterUnitEvent(trig, caster, EVENT_UNIT_DEATH)
call TriggerRegisterUnitEvent(trig, stormfx, EVENT_UNIT_DEATH)
call SaveTriggerActionHandle(udg_Hashtable , GetHandleId (trig), 0, TriggerAddAction( trig, function Mystic_Storm_Periodic ))
call SaveUnitHandle( udg_Hashtable, GetHandleId(trig), 1, caster)
call SaveUnitHandle( udg_Hashtable, GetHandleId(trig), 2, stormfx)
call SaveUnitHandle( udg_Hashtable, GetHandleId(trig), 5, dummy1)
call SaveUnitHandle( udg_Hashtable, GetHandleId(trig), 6, dummy2)

set dummy1 = null
set dummy2 = null
set caster = null
set trig = null
set stormfx = null
endfunction

//===========================================================================
function InitTrig_Mystic_Storm_I_Ultimate_Ability takes nothing returns nothing
    local integer i = 0    
    set gg_trg_Mystic_Storm_I_Ultimate_Ability = CreateTrigger(  )
    loop
    exitwhen i == 15
    call TriggerRegisterPlayerUnitEvent(gg_trg_Mystic_Storm_I_Ultimate_Ability,Player(i),EVENT_PLAYER_UNIT_SPELL_EFFECT,null)
    set i = i + 1
    endloop
    call TriggerAddCondition( gg_trg_Mystic_Storm_I_Ultimate_Ability, Condition( function Trig_Mystic_Storm_Conditions ) )
    call TriggerAddAction( gg_trg_Mystic_Storm_I_Ultimate_Ability, function Trig_Mystic_Storm_Actions )
endfunction

I would be really grateful if someone could help me pinpoint the cause for the bugs and suggest a solution. And +rep of course. Thanks in advance.

P/S: Should you guys need proof that I am not some kind of creep who shamelessly use the name TCO for my own gain, contact Aeroblyctos himself and rule out your doubts. In addition, if you guys need the test campaign send me a PM and I will give the link.
 
Status
Not open for further replies.
Top