• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Spell Help

Status
Not open for further replies.
Level 3
Joined
Jul 24, 2007
Messages
40
This is one is of my first Jass attempts...it works perfectly then doesn't work after about 4 tests of the spells. Any ideas?
I am using NewGen.

JASS:
function Trig__Blinding_Light1_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endfunction

function Trig_Blinding_Light1_Actions takes nothing returns nothing
  //variables begin
  local player castplayer
  local unit castunit //Casting unit
  local location temploc //Targets location
  local location castloc
  local unit temp
  local group enemies = CreateGroup()
  local integer lcount
  local effect e1
  local effect ec

    set castunit = GetTriggerUnit()
    set castloc = GetUnitLoc(castunit)
    set castplayer = GetOwningPlayer(castunit)
  // variables end
  
  //Spell Begins

set ec = AddSpecialEffectLoc("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",castloc)
set enemies = GetUnitsInRangeOfLocAll(300,castloc)
set lcount = 2 + (2 * GetUnitAbilityLevel(castunit,'A002'))

loop
  set temp = FirstOfGroup(enemies)
  exitwhen temp == null or lcount == 0

 if IsUnitEnemy(temp,GetOwningPlayer(castunit)) then
   set temploc = GetUnitLoc(temp)
   set lcount = lcount - 1
   set e1 =  AddSpecialEffectLoc("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl",temploc)
   call TriggerSleepAction(.05)
   call UnitDamageTarget( castunit, temp, 40 * GetUnitAbilityLevel(castunit,'A002'), false,true,ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL,null )
   call DestroyEffect(e1)
   call RemoveLocation(temploc)
   set temploc = null
   set e1 = null
endif
   call GroupRemoveUnit(enemies, temp)   
endloop
  //Clean
call RemoveLocation(temploc)  
call RemoveLocation(castloc)
call DestroyEffect(e1)
call DestroyGroup(enemies)
call DestroyEffect(e1)
call DestroyEffect(ec)
set castplayer = null
set castunit = null
set temploc = null
set castloc = null
set temp = null
set e1 = null
set ec = null
set enemies = null
endfunction

//===========================================================================
function InitTrig_Holy_Eruption takes nothing returns nothing
    set gg_trg_Holy_Eruption = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Holy_Eruption, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Holy_Eruption, Condition( function Trig__Blinding_Light1_Conditions ) )
    call TriggerAddAction( gg_trg_Holy_Eruption, function Trig_Blinding_Light1_Actions )
endfunction
 
Last edited:
Level 8
Joined
Sep 25, 2007
Messages
382
i dont see anithing bad... do you change something in the code in the last test ?... maybe that could change something... if not.. i dunno , maybe a bug ? =S---
 
Level 3
Joined
Jul 24, 2007
Messages
40
no, commenting the wait did nothing
i should explain what happens, after the fourth attempt it doesn't damage units and the effects are brought showed in random places.
 
Level 3
Joined
Jul 24, 2007
Messages
40
alright, but when i did it the eyecandy still popped up, but not ALL of the damage was distributed. (damaged some
units and didnt damage others)

~~update
still, whenever i cast it it over about 6 times it targets the ground sometimes and sometimes it targets less units then it is supposed....please look closeley again
 
Last edited:
Level 5
Joined
Oct 27, 2007
Messages
158
alright, but when i did it the eyecandy still popped up, but not ALL of the damage was distributed. (damaged some
units and didnt damage others)

~~update
still, whenever i cast it it over about 6 times it targets the ground sometimes and sometimes it targets less units then it is supposed....please look closeley again


JASS:
function Trig__Blinding_Light1_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A002'
endfunction

function FilterTargets takes nothing returns boolean
    local unit u = GetFilterUnit()
    local boolean is_target = IsUnitEnemy(u, GetOwningPlayer(GetTriggerUnit())) and GetUnitState(u, UNIT_STATE_LIFE) > 0

    set u = null
    return is_target
endfunction

function Trig_Blinding_Light1_Actions takes nothing returns nothing
  //variables begin
    local group targets = CreateGroup()
    local unit caster = GetTriggerUnit() //Casting unit
    local unit target
    local effect e1
    local effect ec
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    local integer lcount = 2 + (2 * GetUnitAbilityLevel(caster, 'A002'))
  // variables end

  //Spell Begins
    set ec = AddSpecialEffect("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", x, y)
    call GroupEnumUnitsInRange(targets, x, y, 300, Filter(function FilterTargets)) //Trying to kill already dead peasants or footmen won't do much...
    loop
        set target = FirstOfGroup(targets)
        exitwhen target == null or lcount == 0
        set x = GetUnitX(target)
        set y = GetUnitY(target)
        set e1 = AddSpecialEffect("Abilities\\Spells\\Human\\HolyBolt\\HolyBoltSpecialArt.mdl", x, y)
        call TriggerSleepAction(.05)
        call UnitDamageTarget(caster, target, 40 * GetUnitAbilityLevel(caster, 'A002'), true, true, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_NORMAL, null)
        call DestroyEffect(e1)
        call GroupRemoveUnit(targets, target)
        set lcount = lcount - 1
    endloop
  //Clean
    call DestroyEffect(ec)
    call DestroyGroup(targets)
    set ec = null
    set e1 = null
    set target = null
    set caster = null
    set targets = null
endfunction

//===========================================================================
function InitTrig_Holy_Eruption takes nothing returns nothing
    set gg_trg_Holy_Eruption = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Holy_Eruption, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Holy_Eruption, Condition(function Trig__Blinding_Light1_Conditions))
    call TriggerAddAction(gg_trg_Holy_Eruption, function Trig_Blinding_Light1_Actions)
endfunction
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Does not compute...
locations are in most of case useless, cause you need to create/destroy them, and the functions using locations are slower than the functions using x/y.
And it seems with your code you simply remplace them, or maybe i miss something else, i have read your code quickly

EDIT : and you use a filter, it's better ok but his code must theorically work.
 
Last edited:
Level 5
Joined
Oct 27, 2007
Messages
158
locations are in most of case useless, cause you need to create/destroy them, and the functions using locations are slower than the functions using x/y.
And it seems with your code you simply remplace them, or maybe i miss something else, i have read your code quickly

Yes I've replaced them with coordinates because it's simply better in this case. I just cleaned the trigger code and optimized it.

EDIT : and you use a filter, it's better ok but his code must theorically work.

I use a filter because there's no need to enumerate units that aren't supposed to be in the target group.
 
Level 5
Joined
Oct 27, 2007
Messages
158
yep but as i said his code must theorically work, so where is the bug (don't talk again about unefficient scripting plz)

He DIDN'T check for already dead units. His code enumerated all units, including dead ones, within a 300 radius. That's why it didn't work, because the more units that died, the higher the chance a dead unit is picked. That's why it didn't work like expected, and it explains why it works the first few times. While I added the check for dead units I optimized and cleaned the code in the process. Maybe you should examine the code a bit more thorough next time before bitching at me. What is your problem...
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
He DIDN'T check for already dead units. His code enumerated all units, including dead ones, within a 300 radius. That's why it didn't work, because the more units that died, the higher the chance a dead unit is picked. That's why it didn't work like expected, and it explains why it works the first few times. While I added the check for dead units I optimized and cleaned the code in the process. Maybe you should examine the code a bit more thorough next time before bitching at me. What is your problem...

oops such a newbie error, don't worry i've "only" 2 problems
- the jass window is not enough large so i didn't see the and in your filter
- i'm too lazy to read the right part of the window

i didn't bitching you but you just said about optimisation before this post (and yes i know that i didn't read all your code)
 
Status
Not open for further replies.
Top