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 haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  4. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  5. 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.

[Solved] The Farther I cast the spell, the longer the delay in effect

Discussion in 'Triggers & Scripts' started by VitaminLight, Sep 8, 2016.

  1. VitaminLight

    VitaminLight

    Joined:
    Sep 8, 2016
    Messages:
    8
    Resources:
    0
    Resources:
    0
    Projectile has an arc of 0.35, but I'm pretty sure that isn't the problem since the effect is being DELAYED at long distances instead of it being early. Spell is based off of cluster rockets.

    Works completely fine in short distances. ( <300 )

    • Frag Grenade
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Frag Grenade
      • Actions
        • Set grenade_count = (grenade_count + 1)
        • Set grenade_caster[grenade_count] = (Triggering unit)
        • Set grenade_pos[grenade_count] = (Position of (Triggering unit))
        • Set grenade_targetpos[grenade_count] = (Target point of ability being cast)
        • Set grenade_wait[grenade_count] = ((Distance between (Position of (Triggering unit)) and (Target point of ability being cast)) / 300.00)
        • Wait grenade_wait[grenade_count] seconds
        • Set grenade_index = (grenade_index + 1)
        • Special Effect - Create a special effect at grenade_targetpos[grenade_index] using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
        • Special Effect - Destroy (Last created special effect)
        • Unit - Cause grenade_caster[grenade_index] to damage circular area after 0.00 seconds of radius 300.00 at grenade_targetpos[grenade_index], dealing 100.00 damage of attack type Spells and damage type Demolition
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • grenade_index Equal to grenade_count
          • Then - Actions
            • Set grenade_count = 0
            • Set grenade_index = 0
          • Else - Actions
            • Do nothing
     
  2. WereElf

    WereElf

    Joined:
    Jan 2, 2016
    Messages:
    962
    Resources:
    1
    Spells:
    1
    Resources:
    1
    I see that you have location leaks xP You should start clearing them..
    I also notice that once 8191 granades have been cast on your map - the skill will stop working :p

    And... "Wait" isn't as accurate as you'd like it to be. The longer the wait - the less accurete it becomes (in multiplayer games).
    And are you sure the projectile speed is 300? xP

    EDIT: And I also notice, that if a hero/unit casts the skill far away - it will be indexed as (f. ex 3), then another one casts the skill close to it, and it will be indexed as 4.
    Then the 4-th one will arrive to its location before the 3-rd one (since it's closer to its destination), thus the wrong unit will deal the damage...
     
    Last edited: Sep 8, 2016
  3. ic3_water

    ic3_water

    Joined:
    Sep 7, 2008
    Messages:
    313
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Leak at :
    Set grenade_wait[grenade_count] = ((Distance between (Position of (Triggering unit)) and (Target point of ability being cast)) / 300.00)

    Suggesttion:
    For 1 shoot skill, you should use local variable instead
     
  4. VitaminLight

    VitaminLight

    Joined:
    Sep 8, 2016
    Messages:
    8
    Resources:
    0
    Resources:
    0
    I see, thanks a lot guys, really eye opening. I have the JASS version of this trigger but it didn't seem to fix the issue I had with it being delayed.

    I resorted to using pocket factory to spawn a grenade that expires in 3 seconds, and then I used this trigger:

    • Frag Grenade Explosion
      • Events
        • Unit - A unit Dies
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Grenade (Dummy)
      • Actions
        • Unit - Create 1 Ambush Dummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
        • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
        • Unit - Cause (Last created unit) to damage circular area after 0.00 seconds of radius 300.00 at (Position of (Triggering unit)), dealing 100.00 damage of attack type Spells and damage type Demolition
        • Special Effect - Create a special effect at (Position of (Triggering unit)) using Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
        • Special Effect - Destroy (Last created special effect)


    Works like a charm since it doesn't spawn the grenade until the projectile hits, thanks for the help guys!
     
  5. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,640
    Resources:
    3
    Spells:
    3
    Resources:
    3
    To make things easy, you have to remove the "Wait" functions from your GUI function list. (Yes, it makes things easier as you will try to use a proper solution... or at least a working one.)

    Waits arent synced, so once a wait ends, it has to poll the other clients to see if their waits also ended. (I think this is how it works, but at least it requires some net traffic an syncing stuff.)
    Apart from waits not taking game speed into account, they also have a slight delay up to 0.2 seconds in single player, and because of the syncing, it could be 0.2 seconds + sync time (which could be up to 10 seconds if someone has a bad connection) in multiplayer.

    IIrc, Cluster Rockets is point targeted instead of unit targeted, so your calculation would be correct (a unit could walk away which increases the total duration).

    To do this properly, you could either start a timer with that duration (as it is point targeted), use a missile system and trigger/script the missile's behavior or have a unit targeted spell at a dummy unit and use a DDS to catch the on-hit effect.
    Ofcourse, for obvious reasons, the missile system approach is the best one... and sometimes even easier as well.