Need Help with a loop in an ability

robinremue

Member
Reaction score
16
Long time since I've posted something here :) Anyway here's my problem.

I got this ability that targets every unit in an area around the caster and shoots a stream of fire at each target. My problems now are:

- The stream goes through the unit and a lot further then it should go.
- I want the stream to loop, so the stream hits a target, then the stream dissapears and a new stream is created going to the target, over and over again.

Hope you guys understand my problems

Code:
Spell
    Events
        Unit - A unit Begins channeling an ability
    Conditions
        (Ability being cast) Equal to Apocalypse 
    Actions
        Set Angle = (Angle from Caster_Point to Target_Point)
        Set Caster_Point = (Position of (Casting unit))
        Set Spell_Point = (Region centered at Caster_Point with size (2048.00, 2048.00))
        Set tmpReal = (Real(((Number of units in (Units in Spell_Point)) / 2)))
        Set tmpInteger = (Integer(((Distance between Caster_Point and Target_Point) / tmpReal)))
        Set Target_Point = (Position of Target_Unit)
        Set Distance = 0.00
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in (Units in Spell_Point)) Greater than 0
            Then - Actions
                Set Target_Unit = (Random unit from (Units in Spell_Point owned by Player 2 (Blue)))
                For each (Integer A) from 1 to tmpInteger, do (Actions)
                    Loop - Actions
                        Unit Group - Pick every unit in (Units in Spell_Point matching ((Owner of (Picked unit)) Not equal to (Owner of (Casting unit)))) and do (Actions)
                            Loop - Actions
                                Set Distance = (Distance + tmpReal)
                                Set Target_Unit = (Picked unit)
                                Set Target_Point = (Position of Target_Unit)
                                Set Angle = (Angle from Caster_Point to Target_Point)
                                Special Effect - Create a special effect at (Caster_Point offset by Distance towards Angle degrees) using Environment\SmallBuildingFire\SmallBuildingFire2.mdl
                                Set Flame_effects[(Integer A)] = (Last created special effect)
                                Wait 0.10 seconds
                        Wait 0.10 seconds
                Wait 2.00 seconds
                For each (Integer A) from 1 to tmpInteger, do (Actions)
                    Loop - Actions
                        Special Effect - Destroy Flame_effects[(Integer A)]
            Else - Actions
                Do nothing
 
S

Scourgey

Guest
You cannot use waits inside a "pick every unit in unit group" action, doing so causes problems.
 
S

Scourgey

Guest
I don't understand the spell fully. Can each stream hit another target if there is another target in the way?

Or is it like starfall but with prettier graphics?

If it is starfall with prettier graphics, I would make a dummy unit cast fan of knives with modified art periodically (if the Apocalypse spell is still being channelled).
 

robinremue

Member
Reaction score
16
The spell is just a channel. And it's not starfall at all.
It creates several rays of fire that shoot (at the same time) to their respective targets (who are all the enemy units in a radius around the caster).
 

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
well u got a lot to fix including leaks here's what u need:
Code:
Spell
    Events
        Unit - A unit Begins channeling an ability
    Conditions
        (Ability being cast) Equal to Apocalypse 
    Actions
        Set Caster_Point = (Position of (Casting unit))
        Set Spell_Point = (Region centered at Caster_Point with size (2048.00, 2048.00))
        Set Target_Point = (Position of Target_Unit)
        Set Distance = 0.00
        Set Angle = (Angle from Caster_Point to Target_Point)
        Set UnitGroup = Units in Spell_Point
        Set tmpInteger = ((Number of units in UnitGroup / 2)
        Set tmpReal = ((Distance between Caster_Point and Target_Point) / tmpInteger)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in UnitGroup) Greater than 0
            Then - Actions
                Set UnitGroup2 = Units in Spell_Point owned by Player 2 (Blue))
                Set Target_Unit = (Random unit from UnitGroup2)
                For each (Integer A) from 1 to tmpReal, do (Actions)
                    Loop - Actions
                                Set UnitGroup3 = Units in Spell_Point matching ((Owner of (Matching unit)) Not equal to (Owner of (Casting unit)))
                                Custom script:    loop
                                Set Target_Unit = First of group (UnitGroup3)
                                Custom script:    exitwhen (udg_Target_Unit == null)
                                Set Distance = (Distance + tmpReal) 
                                Set Target_Point = (Position of Target_Unit)
                                Set Angle = (Angle from Caster_Point to Target_Point)
                                Set Point = (Caster_Point offset by Distance towards Angle degrees)
                                Special Effect - Create a special effect at Point using Environment\SmallBuildingFire\SmallBuildingFire2.mdl
                                Set Flame_effects[(Integer A)] = (Last created special effect)
                                Custom scirpt:   call RemoveLocation(udg_Point)
                                Custom scirpt:   call RemoveLocation(udg_Target_Point)
                                Wait 0.10 seconds
                                Custom script:   endloop
                                Wait 0.10 seconds
                        Wait 0.10 seconds
                Wait 2.00 seconds
                For each (Integer A) from 1 to tmpInteger, do (Actions)
                    Loop - Actions
                        Special Effect - Destroy Flame_effects[(Integer A)]
               Custom scirpt:   call DestroyGroup(udg_UnitGroup2)
               Custom scirpt:   call DestroyGroup(udg_UnitGroup3)
            Else - Actions
       Custom scirpt:   call DestroyGroup(udg_UnitGroup)
tried to fix it all but it was pretty much but i still didn't understand what is ur calculation here what u tried to do this trigger looks hell messy to me....
also i replaced the tmp Real and Integer since it doesn't seem logical to use real to count something which u convert from integer......

anyway u got a lot of stuff to do here be4 this thing is gonna work
i just gave u a few fixes (or at least tried to....)
 
S

Scourgey

Guest
The spell is just a channel. And it's not starfall at all.
It creates several rays of fire that shoot (at the same time) to their respective targets (who are all the enemy units in a radius around the caster).

But if you take away the graphics, your overall aim is to damage all enemy units in a radius around the caster. Which is what starfall is. If the spell isn't even a channelling spell (I assumed it was because the start of the trigger is "begins channelling"), then you can simply base your ability on fan of knives and you won't need to do anything but modify the art in the datafields

Feel free to go the hard way if you want, but from what I see in the trigger, there'd be a lot more work required.
 

robinremue

Member
Reaction score
16
Aight thanks :) Gonna work about more on it and see what else I can find out on my own :p this was just a part I really couldn't find myself for some reason :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top