• 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.

Lightnings cause Crash

Status
Not open for further replies.
Level 7
Joined
Aug 31, 2006
Messages
132
Well, i make some heroes and spells for them, but some spells i made lately give me headache.

First ability - synergy creates a lightning between the caster and target that binds them and gives them bonus atk speed. (The lightning is moved every 0.10 sec to according position between the both)

Everything went well till something terrible happened... other lightning effect just dont like it as it seems. If i cast another spell that causes another 2 lightnings to "rotate" around an unit shortly after casting synergy, the lightnings begin to go crazy, change their type and start to blink and soonly the game crashed (As i noticed it crahses always when the according bugged lightning is about to be destroyed).

This is the weirdest bug i ever saw and i really dont know whats going on.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
If you delete a already deleted lightning it will crash your map.
This is exactly the problem.

Basically, your spells are not MI (multi instant castable). You obviously do not handle the lightning effect properly and so they collide and start fighting over which spell that affect belongs to. You then destroy the same affect twice (once when first spell ends then the second when the other spell ends) which causes your crash. It sounds like this is caused by the lack of propper variable use resulting in the same object being usable twice when it is not meant to be.

Posting both the spell triggers will enable us to comment further and even go onto how to fix it, if it is not already clear to you how to.
 
Level 7
Joined
Aug 31, 2006
Messages
132
Well those are the triggers used.
(Variables used are SynergyCaster and SynergyTarget as units and CircleTarget as target of the Circle of Death spell (SynergyCaster and SynergyTarget were needed to trigger the movement of the lightning, otherwise i could just use Casting Unit and Target Unit of Ability being cast). SynergyLightning is lightning of synergy. Lightning1 and Lightning2 are lightnings of Circle of Death. Synergy ability is based off Chain Lightning spell and Circle of death off Aerial Shackles. Also RitualOn is boolean used to look if Circle of Death is channeled or not.


//Circle of Death

This when started channeling makes 2 special effects circle around an unit that loses damage because of the Aerial Shackle's dmg per second. This circle gets shorter and shorter if the targeted enemy has lower hp and it also paints more dark and transparent. From the points of those moving special effects also move lightnings to the position of the unit. When the unit dies while the spell was used, the "else" of if then else creates a copy of it and adds it a 30 second expiration time, all further actions get skipped. If the spell is canceled prematurely, all actions get skipped too. If the normal duration of spell is completed, hero automaticly stop casting what makes the RitualOn to go off (Also happens if prematurely stopped) what again makes the spell skip all actions.

  • CircleOfDeath
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
      • (Ability being cast) Equal to Circle of Death
    • Actions
      • Set RitualOn = True
      • Set CircleTarget[(Player number of (Owner of (Casting unit)))] = (Target unit of ability being cast)
      • Lightning - Create a Drain Life lightning effect from source ((Position of CircleTarget[(Player number of (Owner of (Casting unit)))]) offset by (5.00 x (Percentage life of CircleTarget[(Player number of (Owner of (Casting unit)))])) towards 1.00 degrees) to target (Position of CircleTarget[(Player number of (Owner of (Casting unit)))])
      • Set CircleLightning1 = (Last created lightning effect)
      • Lightning - Create a Drain Life lightning effect from source ((Position of CircleTarget[(Player number of (Owner of (Casting unit)))]) offset by (5.00 x (Percentage life of CircleTarget[(Player number of (Owner of (Casting unit)))])) towards 181.00 degrees) to target (Position of CircleTarget[(Player number of (Owner of (Casting unit)))])
      • Set CircleLightning2 = (Last created lightning effect)
      • For each (Integer A) from 1 to 2000, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RitualOn Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CircleTarget[(Player number of (Owner of (Casting unit)))] is alive) Equal to True
                • Then - Actions
                  • Special Effect - Create a special effect at ((Position of (Target unit of ability being cast)) offset by (5.00 x (Percentage life of (Target unit of ability being cast))) towards ((Real((Integer A))) x 5.00) degrees) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Special Effect - Create a special effect at ((Position of (Target unit of ability being cast)) offset by (5.00 x (Percentage life of (Target unit of ability being cast))) towards (((Real((Integer A))) x 5.00) + 180.00) degrees) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Animation - Change (Target unit of ability being cast)'s vertex coloring to ((Percentage life of (Target unit of ability being cast))%, (Percentage life of (Target unit of ability being cast))%, (Percentage life of (Target unit of ability being cast))%) with (100.00 - (Percentage life of (Target unit of ability being cast)))% transparency
                  • Lightning - Move CircleLightning1 to source ((Position of CircleTarget[(Player number of (Owner of (Casting unit)))]) offset by (5.00 x (Percentage life of CircleTarget[(Player number of (Owner of (Casting unit)))])) towards ((Real((Integer A))) x 5.00) degrees) and target (Position of CircleTarget[(Player number of (Owner of (Casting unit)))])
                  • Lightning - Move CircleLightning2 to source ((Position of CircleTarget[(Player number of (Owner of (Casting unit)))]) offset by (5.00 x (Percentage life of CircleTarget[(Player number of (Owner of (Casting unit)))])) towards (((Real((Integer A))) x 5.00) + 180.00) degrees) and target (Position of CircleTarget[(Player number of (Owner of (Casting unit)))])
                  • Wait 0.01 seconds
                • Else - Actions
                  • Lightning - Destroy CircleLightning1
                  • Lightning - Destroy CircleLightning2
                  • Special Effect - Create a special effect at (Position of CircleTarget[(Player number of (Owner of (Casting unit)))]) using Objects\Spawnmodels\Undead\UDeathSmall\UDeathSmall.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • Unit - Create 1 (Unit-type of CircleTarget[(Player number of (Owner of (Casting unit)))]) for (Owner of (Casting unit)) at (Position of CircleTarget[(Player number of (Owner of (Casting unit)))]) facing Default building facing degrees
                  • Unit - Add classification of Undead to (Last created unit)
                  • Unit - Remove CircleTarget[(Player number of (Owner of (Casting unit)))] from the game
                  • Unit - Add a 30.00 second Raise Dead expiration timer to (Last created unit)
                  • Skip remaining actions
            • Else - Actions
              • Lightning - Destroy CircleLightning1
              • Lightning - Destroy CircleLightning2
              • Animation - Change (Target unit of ability being cast)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
              • Skip remaining actions
      • Animation - Change (Target unit of ability being cast)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
  • CircleOfDeathEnd
    • Events
      • Unit - A unit Finishes casting an ability
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Circle of Death
    • Actions
      • Wait 0.02 seconds
      • Animation - Change CircleTarget[(Player number of (Owner of (Casting unit)))]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
      • Lightning - Destroy CircleLightning1
      • Lightning - Destroy CircleLightning2
      • Set RitualOn = False
//Synergy

When activated on an allied unit it creates an lightning between caster and the target and gives both an item ability that gives 50% atk speed. Also it shuts on the periodic spell script that moves the lightning between those 2 units. The spell then waits until the unit variable (target unit of ability being cast) is too far away or if one of the 2 units is dead. Then it shuts the periodic script off and ends the spell (and removes the ability from both units).

  • Synergy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Synergy
    • Actions
      • Unit - Remove Synergy Bonus from SynergyCaster
      • Unit - Remove Synergy Bonus from SynergyTarget
      • Lightning - Create a Finger of Death lightning effect from source (Position of (Casting unit)) to target (Position of (Target unit of ability being cast))
      • Set SynergyLightning = (Last created lightning effect)
      • Set SynergyCaster = (Casting unit)
      • Set SynergyTarget = (Target unit of ability being cast)
      • Unit - Add Synergy Bonus to (Casting unit)
      • Unit - Add Synergy Bonus to (Target unit of ability being cast)
      • Trigger - Turn on SynergyWork <gen>
      • Wait until (((SynergyTarget is in (Units within (350.00 + (150.00 x (Real((Level of Synergy for SynergyCaster))))) of (Position of SynergyCaster))) Equal to False) or (((SynergyCaster is alive) Equal to False) or ((SynergyTarget is alive) Equal to False))), checking every 0.10 seconds
      • Trigger - Turn off SynergyWork <gen>
      • Lightning - Destroy SynergyLightning
      • Unit - Remove Synergy Bonus from SynergyCaster
      • Unit - Remove Synergy Bonus from SynergyTarget
 
Last edited by a moderator:
Level 7
Joined
Aug 31, 2006
Messages
132
Ok, i tried to rewrite it in jass today, but looks like i made numerous mistakes :(. (By now the effect is only supposed to make lightnings go around the unit as long as the spell is channeled)

(Edit: Tried to fix it, now it says something like "Wrong Argument (Integer)" or "Cant convert Integer to String in JassCraft")

function Trig_CircleOfDeathJass_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00K'
endfunction

function Trig_CircleOfDeathJass_Actions takes nothing returns nothing
local unit caster
local unit target
local lightning lightning1
local lightning lightning2
local real lightning1angle
local real lightning2angle
local real turn
set caster = GetTriggerUnit()
set target = GetSpellTargetUnit()
set lightning1angle = 0.00
set lightning2angle = 179.00
set lightning1 = AddLightning('DRAL', true, GetLocationX(PolarProjectionBJ(GetUnitLoc(target), 6 * GetUnitLifePercent(target), lightning1angle)), GetLocationX(PolarProjectionBJ(GetUnitLoc(target), 6 * GetUnitLifePercent(target), lightning1angle)), GetUnitX(target), GetUnitY(target))
set lightning2 = AddLightning('DRAL', true, GetLocationX(PolarProjectionBJ(GetUnitLoc(target), 6 * GetUnitLifePercent(target), lightning2angle)), GetLocationX(PolarProjectionBJ(GetUnitLoc(target), 6 * GetUnitLifePercent(target), lightning2angle)), GetUnitX(target), GetUnitY(target))
loop
exitwhen UnitHasBuffBJ(target, 'Bmlt') == true
MoveLightning(lightning1, true, GetLocationX(PolarProjectionBJ(GetUnitLoc(target), 6 * GetUnitLifePercent(target), lightning1angle)), GetLocationX(PolarProjectionBJ(GetUnitLoc(target), 6 * GetUnitLifePercent(target), lightning1angle)), GetUnitX(target), GetUnitY(target))
MoveLightning(lightning2, true, GetLocationX(PolarProjectionBJ(GetUnitLoc(target), 6 * GetUnitLifePercent(target), lightning2angle)), GetLocationX(PolarProjectionBJ(GetUnitLoc(target), 6 * GetUnitLifePercent(target), lightning2angle)), GetUnitX(target), GetUnitY(target))
endloop
endfunction


function InitTrig_CircleOfDeathJass takes nothing returns nothing
local trigger CODJ = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(CODJ, EVENT_PLAYER_UNIT_SPELL_CHANNEL)
call TriggerAddCondition(CODJ, Condition(function Trig_CircleOfDeathJass_Conditions) )
call TriggerAddAction(CODJ, function Trig_CircleOfDeathJass_Actions )
endfunction
 
Last edited:
Status
Not open for further replies.
Top