• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Need help fine-tuning spell

Status
Not open for further replies.
Level 10
Joined
Apr 9, 2004
Messages
502
Recently i finished the crude prototype as ill call it of a spell system that i'd managed to create. However, things still don't seem to be running smoothly and it still seems to slow down the game whiel this ability is working. This is going to be a long post, showing each inidividual trigger as is. This way, perhaps someone can help me reduce it's size and make it more efficient. Here are the triggers in mostly Gui Format. I'll explaina little before each trigger. BTW this is kind of the carrier meets locust swarm...

Code:
Create sentinel- 

this one is merely to create the unit and check for open positions.
    
Events
        Unit - Mobile Crypt Machine Pilot 0051 <gen> Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Manufacture Sentinels 
    Actions
        Unit - Create 1 Sentry for (Owner of Mobile Crypt Machine Pilot 0051 <gen>) at (Position of Mobile Crypt Machine Pilot 0051 <gen>) facing Default building facing degrees
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Sentinel[1] Equal to No unit
            Then - Actions
                Set Sentinel[1] = (Last created unit)
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Sentinel[2] Equal to No unit
                    Then - Actions
                        Set Sentinel[2] = (Last created unit)
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                Sentinel[3] Equal to No unit
                            Then - Actions
                                Set Sentinel[3] = (Last created unit)
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Sentinel[4] Equal to No unit
                                    Then - Actions
                                        Set Sentinel[4] = (Last created unit)
                                    Else - Actions
                                        Do nothing
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Sentry) and (((Matching unit) is alive) Equal to True)))) Equal to 4
            Then - Actions
                Unit Group - Pick every unit in (Units of type Less than 4 sentinels built.) and do (Actions)
                    Loop - Actions
                        Unit - Kill (Picked unit)
                        Unit - Remove (Picked unit) from the game
            Else - Actions
                Do nothing

Keep sentinel 1 housed

There are four triggers like this, each one for each unit (there are 4 max) that i'm tracking.  This ability merely moves the units ot set locations, to make it look like they are ported on my heroes back.

    Events
        Time - Every 0.01 seconds of game time
    Conditions
        (Distance between (Position of Mobile Crypt Machine Pilot 0051 <gen>) and (Position of Sentinel[1])) Less than or equal to 140.00
    Actions
        Unit - Set life of Sentinel[1] to ((Life of Sentinel[1]) + (0.02 x (Real((Level of Manufacture Sentinels  for Mobile Crypt Machine Pilot 0051 <gen>)))))
        Set SentinelPoint[1] = ((Position of Mobile Crypt Machine Pilot 0051 <gen>) offset by 90.00 towards ((Facing of Mobile Crypt Machine Pilot 0051 <gen>) - 150.00) degrees)
        Unit - Move Sentinel[1] instantly to SentinelPoint[1], facing ((Facing of Mobile Crypt Machine Pilot 0051 <gen>) + 180.00) degrees
        Custom script:   call RemoveLocation(udg_SentinelPoint[1])


Fix when sentinel dies

-This is to open the correct unit varaible so i can replace that unit with the spawn trigger.  This ability was alos dependant on a single unit whcih this one creates to activate so you can make more of the units.

    Events
        Unit - A unit Dies
    Conditions
        (Unit-type of (Dying unit)) Equal to Sentry
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in (Units of type Less than 4 sentinels built.)) Less than 1
            Then - Actions
                Unit - Create 1 Less than 4 sentinels built. for (Owner of Mobile Crypt Machine Pilot 0051 <gen>) at (Center of (Playable map area)) facing Default building facing degrees
            Else - Actions
                Do nothing
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Dying unit) Equal to Sentinel[1]
            Then - Actions
                Set Sentinel[1] = No unit
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Dying unit) Equal to Sentinel[2]
                    Then - Actions
                        Set Sentinel[2] = No unit
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Dying unit) Equal to Sentinel[3]
                            Then - Actions
                                Set Sentinel[3] = No unit
                            Else - Actions
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        (Dying unit) Equal to Sentinel[4]
                                    Then - Actions
                                        Set Sentinel[4] = No unit
                                    Else - Actions
                                        Do nothing


Increase Sentinel stats

-this is just how i wanted to boost my units.  It's just used to initiate the innate i made to work with this.  not much more than that.

    Events
        Unit - Mobile Crypt Machine Pilot 0051 <gen> Learns a skill
    Conditions
        (Learned Hero Skill) Equal to Manufacture Sentinels 
    Actions
        Player - Set the current research level of Sentinal Upgrades  to (Level of Manufacture Sentinels  for Mobile Crypt Machine Pilot 0051 <gen>) for (Owner of Mobile Crypt Machine Pilot 0051 <gen>)
        Player - Enable Areal Assault (catsable) for (Owner of Mobile Crypt Machine Pilot 0051 <gen>)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in (Units of type Less than 4 sentinels built.)) Equal to 1
            Then - Actions
                Do nothing
            Else - Actions
                Unit - Create 1 Less than 4 sentinels built. for (Owner of Mobile Crypt Machine Pilot 0051 <gen>) at (Center of (Playable map area)) facing Default building facing degrees


Start Patrolling

This is a big one; it's meant to control whether or not the units go back to port, or if they patrol, or when they retreat to repair.

    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Mobile Crypt Machine Pilot 0051 <gen> has buff Seige ) Equal to True
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Percentage life of Sentinel[1]) Less than or equal to 30.00
                    Then - Actions
                        Trigger - Turn on Keep sentinel 1 housed <gen>
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Percentage life of Sentinel[1]) Greater than or equal to 70.00
                            Then - Actions
                                Trigger - Turn off Keep sentinel 1 housed <gen>
                            Else - Actions
                                Do nothing
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Percentage life of Sentinel[2]) Less than or equal to 30.00
                    Then - Actions
                        Trigger - Turn on Keep sentinel 2 housed <gen>
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Percentage life of Sentinel[2]) Greater than or equal to 70.00
                            Then - Actions
                                Trigger - Turn off Keep sentinel 2 housed <gen>
                            Else - Actions
                                Do nothing
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Percentage life of Sentinel[3]) Less than or equal to 30.00
                    Then - Actions
                        Trigger - Turn on Keep sentinel 3 housed <gen>
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Percentage life of Sentinel[3]) Greater than or equal to 70.00
                            Then - Actions
                                Trigger - Turn off Keep sentinel 3 housed <gen>
                            Else - Actions
                                Do nothing
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Percentage life of Sentinel[4]) Less than or equal to 30.00
                    Then - Actions
                        Trigger - Turn on Keep sentinel 4 housed <gen>
                    Else - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Percentage life of Sentinel[4]) Greater than or equal to 70.00
                            Then - Actions
                                Trigger - Turn off Keep sentinel 4 housed <gen>
                            Else - Actions
                                Do nothing
                Trigger - Turn on Patrol Sentinel 1 <gen>
                Trigger - Turn on Patrol Sentinel 2 <gen>
                Trigger - Turn on Patrol Sentinel 3 <gen>
                Trigger - Turn on Patrol Sentinel 4 <gen>
            Else - Actions
                Trigger - Turn on Keep sentinel 1 housed <gen>
                Trigger - Turn on Keep sentinel 2 housed <gen>
                Trigger - Turn on Keep sentinel 3 housed <gen>
                Trigger - Turn on Keep sentinel 4 housed <gen>


Patrol Sentinel 1

This is the ai movement that i made that seemed to work best.  There are 4 of these that work for each unit independantly.  Just tells it when to attack, when to patrol, and when to retreat or redock.

    Events
        Time - Every 0.10 seconds of game time
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Mobile Crypt Machine Pilot 0051 <gen> has buff Seige ) Equal to False) or ((Percentage life of Sentinel[1]) Less than or equal to 30.00)
            Then - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Current order of Sentinel[1]) Not equal to (Order(move))
                    Then - Actions
                        Unit - Order Sentinel[1] to Right-Click Mobile Crypt Machine Pilot 0051 <gen>
                    Else - Actions
                        Do nothing
            Else - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Current order of Sentinel[1]) Not equal to (Order(attack))
                    Then - Actions
                        Unit - Order Sentinel[1] to Attack-Move To (Random point in (Region centered at (Position of Mobile Crypt Machine Pilot 0051 <gen>) with size (800.00, 800.00)))
                    Else - Actions
                        Do nothing
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Distance between (Position of Mobile Crypt Machine Pilot 0051 <gen>) and (Position of Sentinel[1])) Greater than 800.00
            Then - Actions
                Unit - Order Sentinel[1] to Move To (Random point in (Region centered at (Position of Mobile Crypt Machine Pilot 0051 <gen>) with size (400.00, 400.00)))
            Else - Actions
                Do nothing

There's the complete set of triggers (more or less). Now i am in dire need of some fine tuning. I am begging for help. Anywaything that will stop this form slowing down my game!!

BTW it seems to slow down only while units are docked.
 
Level 7
Joined
May 16, 2004
Messages
355
Well one reason you may be experiencing some slowdown is the large amount of "If then else" statements you have. As it is its kind of messy and long so I cant really take the time to read it all but you might want to think about replacing all those duplicates with a
Code:
for loop A 1-4
     If- Sentinel [Loop A] is equal to [no unit]
     Then- Blah blah blah
[quote]
In my experience lots of "if then elses" always led to slowdown for me.[/quote]
 
Status
Not open for further replies.
Top