1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Trigger] A certain hookshot spell

Discussion in 'Triggers & Scripts' started by LimitingBounds, May 30, 2016.

  1. LimitingBounds

    LimitingBounds

    Joined:
    May 12, 2016
    Messages:
    39
    Resources:
    0
    Resources:
    0
    Hello! Hoping to get some help on this one. So, here are my two concerns for this spell I made...which will be included in a spellset I'll upload here eventually.

    Triggers
    [trigger="Bandage Toss Cast"]
    Bandage Toss Cast
    Events
    Unit - A unit Starts the effect of an ability
    Conditions
    (Ability being cast) Equal to AbilityIndex[0]
    Actions
    -------- Indexing --------
    Set IndexMax[0] = (IndexMax[0] + 1)
    For each (Integer Index[0]) from 0 to (IndexMax[0] - 1), do (Actions)
    Loop - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    IndexOccupied[Index[0]] Equal to False
    Then - Actions
    -------- Instance Index Activate --------
    Set IndexOccupied[Index[0]] = True
    -------- Variable Setup --------
    Set Caster[Index[0]] = (Triggering unit)
    Set SourcePoint[Index[0]] = (Position of Caster[Index[0]])
    Set TargetPoint[Index[0]] = (Target point of ability being cast)
    Set DummyPoint[Index[0]] = (SourcePoint[Index[0]] offset by Speed[0] towards (Angle from SourcePoint[Index[0]] to TargetPoint[Index[0]]) degrees)
    Set Distance[Index[0]] = (Distance[Index[0]] + Speed[0])
    -------- Lasso Create --------
    Lightning - Create a Drain Life lightning effect from source SourcePoint[Index[0]] to target DummyPoint[Index[0]]
    Set Lightning[Index[0]] = (Last created lightning effect)
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    (BT Cast Loop <gen> is on) Not equal to True
    Then - Actions
    Trigger - Turn on BT Cast Loop <gen>
    Else - Actions
    Skip remaining actions
    Else - Actions
    [/trigger]

    [trigger="BT Loop (initially off)"]
    BT Cast Loop
    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
    IndexMax[0] Greater than 0
    Then - Actions
    For each (Integer Index[0]) from 0 to (IndexMax[0] - 1), do (Actions)
    Loop - Actions
    Unit - Pause Caster[Index[0]]
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    Target[Index[0]] Equal to No unit
    Then - Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    Distance[Index[0]] Less than MaxDistance[0]
    Then - Actions
    Set CasterPoint[Index[0]] = (Position of Caster[Index[0]])
    Set DummyPoint[Index[0]] = (DummyPoint[Index[0]] offset by Speed[0] towards (Angle from SourcePoint[Index[0]] to TargetPoint[Index[0]]) degrees)
    Set Group[Index[0]] = (Units within 50.00 of DummyPoint[Index[0]] matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) belongs to an ally of (Owner of Caster[Index[0]])) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((Matching
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    (Number of units in Group[Index[0]]) Greater than 0
    Then - Actions
    Set Target[Index[0]] = (Random unit from Group[Index[0]])
    Set TargetPoint[Index[0]] = (Position of Target[Index[0]])
    -------- Stun --------
    Unit - Create 1 Dummy for (Owner of Caster[Index[0]]) at DummyPoint[Index[0]] facing TargetPoint[Index[0]]
    Set Dummy[Index[0]] = (Last created unit)
    Unit - Add DummyAbi[0] to Dummy[Index[0]]
    Unit - Set level of DummyAbi[0] for Dummy[Index[0]] to (Level of AbilityIndex[0] for Caster[Index[0]])
    Unit - Order Dummy[Index[0]] to Human Mountain King - Storm Bolt Target[Index[0]]
    Unit - Remove Dummy[Index[0]] from the game
    Unit - Turn collision for Caster[Index[0]] Off
    -------- Cleaning --------
    Set Dummy[Index[0]] = No unit
    Custom script: call RemoveLocation(udg_CasterPoint[udg_Index[0]])
    Else - Actions
    Lightning - Move Lightning[Index[0]] to source CasterPoint[Index[0]] and target DummyPoint[Index[0]]
    Set Distance[Index[0]] = (Distance[Index[0]] + Speed[0])
    Custom script: call RemoveLocation(udg_CasterPoint[udg_Index[0]])
    Custom script: call DestroyGroup(udg_Group[udg_Index[0]])
    Else - Actions
    -------- De-indexing --------
    Set IndexOccupied[Index[0]] = False
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    And - All (Conditions) are true
    Conditions
    IndexMax[0] Greater than 0
    Index[0] Equal to (IndexMax[0] - 1)
    Then - Actions
    Set IndexMax[0] = (IndexMax[0] - 1)
    Else - Actions
    -------- Cleaning --------
    Lightning - Destroy Lightning[Index[0]]
    Unit - Unpause Caster[Index[0]]
    Set Distance[Index[0]] = 0.00
    Set Caster[Index[0]] = No unit
    Custom script: call RemoveLocation(udg_SourcePoint[udg_Index[0]])
    Custom script: call RemoveLocation(udg_DummyPoint[udg_Index[0]])
    Custom script: call RemoveLocation(udg_TargetPoint[udg_Index[0]])
    Custom script: call RemoveLocation(udg_CasterPoint[udg_Index[0]])
    Else - Actions
    Set SourcePoint[Index[0]] = (Position of Caster[Index[0]])
    Set TargetPoint[Index[0]] = (Position of Target[Index[0]])
    Set Distance[Index[0]] = (Distance between SourcePoint[Index[0]] and TargetPoint[Index[0]])
    Quest - Display to (All players) the Hint message: (Dist: + (String(Distance[Index[0]])))
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    Distance[Index[0]] Greater than or equal to 125.00
    Then - Actions
    -------- Reel --------
    Set DummyPoint[Index[0]] = (SourcePoint[Index[0]] offset by Speed[0] towards (Angle from SourcePoint[Index[0]] to TargetPoint[Index[0]]) degrees)
    Unit - Move Caster[Index[0]] instantly to DummyPoint[Index[0]], facing TargetPoint[Index[0]]
    Lightning - Move Lightning[Index[0]] to source DummyPoint[Index[0]] and target TargetPoint[Index[0]]
    Else - Actions
    -------- De-indexing --------
    Set IndexOccupied[Index[0]] = False
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
    And - All (Conditions) are true
    Conditions
    IndexMax[0] Greater than 0
    Index[0] Equal to (IndexMax[0] - 1)
    Then - Actions
    Set IndexMax[0] = (IndexMax[0] - 1)
    Else - Actions
    -------- Cleaning --------
    Lightning - Destroy Lightning[Index[0]]
    Unit - Unpause Caster[Index[0]]
    Unit - Turn collision for Caster[Index[0]] On
    Set Target[Index[0]] = No unit
    Set Caster[Index[0]] = No unit
    Set Distance[Index[0]] = 0.00
    Custom script: call RemoveLocation(udg_DummyPoint[udg_Index[0]])
    Custom script: call RemoveLocation(udg_SourcePoint[udg_Index[0]])
    Custom script: call RemoveLocation(udg_TargetPoint[udg_Index[0]])
    Else - Actions
    Trigger - Turn off (This trigger)

    [/trigger]


    Details
    This spell's a Hookshot spell, that channels a lasso with a configurable speed and maximum distance before getting destroyed. When it finds a target before its destruction, it casts its secondary effect (variable DummyAbi[Index[0]]) to it, clings, and reels the caster to the target's position.

    Notes:
    - First time I used dynamic indexing for a spell.


    My questions for this one are...:
    1. On a scale of 1 to 10, 10 as the clearest, how comprehensible are my triggers?
    2. It's working well enough, but do you think this is properly executed and cleaned? Why or why not?

    Answers and suggestions will be much appreciated. Thank you. :grin:
     
    Last edited: May 30, 2016
  2. KILLCIDE

    KILLCIDE

    Administrator

    Joined:
    Jul 22, 2015
    Messages:
    3,501
    Resources:
    20
    Models:
    2
    Icons:
    10
    Spells:
    7
    Tutorials:
    1
    Resources:
    20
    If you want your spell to be reviewed, just upload it into the spell section. Anyway, to answer your questions:
    1. I give it a 6. You should add more comments about what your If/Then/Else check for.
    2. You do a lot of strange things like starting at 0 with a GUI loop and decrementing the index in the for loop statement "from 0 to (IndexMax[0] - 1". The indexing system is also strange, do you mind linking where you learned it from? I would list more things, but that's what the spell section is for :3
     
  3. LimitingBounds

    LimitingBounds

    Joined:
    May 12, 2016
    Messages:
    39
    Resources:
    0
    Resources:
    0
    Thanks for the answers~!
    I uploaded it here because I want to get minor feedback, especially formatting-related, to be used for the rest of spells as well before uploading the full spellset. Anyways,
    1. Noted. Thank you for the suggestion~ :)
    2. After getting the basics from reading this, I'm still getting the hang of it. I'll be changing this a bit, heh.
     
    Last edited: May 30, 2016