• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Simple Spell Problem

Status
Not open for further replies.
Level 10
Joined
Oct 31, 2009
Messages
352
Simple Spell Problem (unsolved)

The following spell causes a fatal error when used and I can't for the life of me figure out why.

Heres what I have found:

- I THINK it only causes a fatal error at level 4
- It does not ALWAYS cause a fatal error (even if the ability is level 4)


Heres what it does:

Conjures a bolt of lightning that deals damage and then jumps to nearby enemy units. Each jump reduces damage dealt by 15%.

Level 1 - Deals 70-110 damage, jumps up to 3 times
Level 2 - Deals 160-200 damage, jumps up to 4 times
Level 3 - Deals 250-290 damage, jumps up to 5 times
Level 4 - Deals 340-380 damage, jumps up to 6 times


Heres the GUI code for it:

  • Chain Lightning Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chain Lightning (Ogre Magi)
    • Actions
      • Set ChainLight_Pos = (Position of (Target unit of ability being cast))
      • Set ChainLight_Caster = (Triggering unit)
      • Set ChainLight_Count = 0
      • Set ChainLight_AntiCount = (2 + (Level of Chain Lightning (Ogre Magi) for ChainLight_Caster))
      • Set ChainLight_Group = (Units within 650.00 of ChainLight_Pos matching ((((Matching unit) is A structure) Equal to False) and (((Matching unit) belongs to an enemy of (Owner of ChainLight_Caster)) Equal to True)))
      • Unit Group - Remove (Target unit of ability being cast) from ChainLight_Group
      • Set ChainLight_RL = (((90.00 x (Real((Level of Chain Lightning (Ogre Magi) for ChainLight_Caster)))) + ((Random real number between 0.00 and 40.00) - 20.00)))
      • Unit - Cause ChainLight_Caster to damage (Target unit of ability being cast), dealing ChainLight_RL damage of attack type Spells and damage type Normal
      • Trigger - Turn on Chain Lightning Tick <gen>

  • Chain Lightning Tick
    • Events
      • Time - Every 0.16 seconds of game time
    • Conditions
    • Actions
      • Set ChainLight_Count = (ChainLight_Count + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ChainLight_Count Less than ChainLight_AntiCount
        • Then - Actions
          • Unit Group - Pick every unit in ChainLight_Group and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Or - Any (Conditions) are true
                    • Conditions
                      • ((Picked unit) is dead) Equal to True
                      • (Owner of (Picked unit)) Equal to Neutral Passive
                • Then - Actions
                  • Unit Group - Remove (Picked unit) from ChainLight_Group
                • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in ChainLight_Group) Greater than 0
            • Then - Actions
              • Set ChainLight_TempGroup = (Random 1 units from ChainLight_Group)
              • Unit Group - Pick every unit in ChainLight_TempGroup and do (Actions)
                • Loop - Actions
                  • Set ChainLight_Pos2 = (Position of (Picked unit))
                  • Lightning - Create a Chain Lightning - Primary lightning effect from source ChainLight_Pos to target ChainLight_Pos2
                  • Custom script: call RemoveLocation(udg_ChainLight_Pos2)
                  • Custom script: call RemoveLocation(udg_ChainLight_Pos)
                  • Set ChainLight_Pos = (Position of (Picked unit))
                  • Set ChainLight_Lightning[ChainLight_Count] = (Last created lightning effect)
                  • Unit Group - Remove (Picked unit) from ChainLight_Group
                  • Set ChainLight_RL = (ChainLight_RL x 0.85)
                  • Unit - Cause ChainLight_Caster to damage (Picked unit), dealing ChainLight_RL damage of attack type Spells and damage type Normal
              • Custom script: call DestroyGroup(udg_ChainLight_TempGroup)
            • Else - Actions
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ChainLight_Count Less than ((ChainLight_AntiCount x 2) - 1)
            • Then - Actions
              • Lightning - Destroy ChainLight_Lightning[(1 + (ChainLight_Count - ChainLight_AntiCount))]
            • Else - Actions
              • Custom script: call DestroyGroup(udg_ChainLight_Group)
              • Custom script: call RemoveLocation(udg_ChainLight_Pos)
              • Trigger - Turn off (This trigger)


If anybody could please help I would greatly appreciate it. I really need this spell to work properly and cannot just use the basic chain lightning ability b/c I am planning to do some other things w/ it like give it the ability to crit and add to its damage.

Any useful help will be rewarded +rep
 
Last edited:
Level 9
Joined
Oct 11, 2009
Messages
477
I think this is the problem, its in the first trigger.

  • Set ChainLight_RL = (((90.00 x (Real((Level of Chain Lightning (Ogre Magi) for ChainLight_Caster)))) + ((Random real number between 0.00 and 40.00) - 20.00)))
Is this part, ((Random real number between 0.00 and 40.00) - 20.00))). Because there is no negative value damage, what some think that if a unit takes a negative valued damage, they will be healed instead of taking damage well they are wrong. If the value of this "(Random real number between 0.00 and 40.00)" is less than 20, then the result will be -1, -2, -3, bla...bla...bla... and so forth and is unacceptable in the WC3 engine and I THINK that's why you get an error.
 
Level 9
Joined
Oct 11, 2009
Messages
477
sephiroth1234, the first part contains 90 though. So, even if the random real is 1.00 and it returns -19, the least result the first part can get is 90 (if we assume the ability's level is 1), so it will be 90-19 = positive value.

"(((90.00 x (Real((Level of Chain Lightning (Ogre Magi) for ChainLight_Caster)))) + ((Random real number between 0.00 and 40.00) - 20.00)))".
Wait, I want to tell it like this and it think this is the sequence of the whole numerical expression;
(((90.00 x (Real((Level of Chain Lightning (Ogre Magi) for ChainLight_Caster))))=X
((Random real number between 0.00 and 40.00) - 20.00)))=Y

Then we have no problem on the X value because it always returns positive value and the whole numerical expression even if there is the Y number but the numbers X and Y are computed separately by the engine(Look at the parentheses). If the engine computed X then it is accepted but if it computed Y and its result is -1, -2, -3, so on and so forth then the error ocurrs.


Try it MAYBE it will work.
 
Status
Not open for further replies.
Top