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. Ride into the sunset with the 32nd Modeling Contest. The contest is optionally paired. Best of luck, people!
    Dismiss Notice
  4. This adventure has come to an end. Congratulate our heroes in the 16th Mini Mapping Contest Results.
    Dismiss Notice
  5. From the gates of hell, the 5th Special Effect Contest Results have emerged.
    Dismiss Notice
  6. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  7. 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] Drain Mana Target Point?

Discussion in 'Triggers & Scripts' started by Serefkana, Feb 19, 2009.

  1. Serefkana

    Serefkana

    Joined:
    Jan 28, 2009
    Messages:
    15
    Resources:
    0
    Resources:
    0
    Need Help on a Fishing Trigger (and how to make Random Integer?)

    Solved: Everything works perfectly^.^
    check out my 3rd post if you want to download the map.






    ~ORIGINAL POST~

    I have a dummy spell, and I want to trigger it so that it shows the drain mana effect(the blue line thing) between the caster and the target point...

    And I also want the target to not be able to move while casting/channeling it (like 5-10sec)
    *could use casting time on dummy spell for this though

    (if you are curious, its for fishing...)

    Thanks, -Seref
     
    Last edited: Feb 20, 2009
  2. Lord_BoNes

    Lord_BoNes

    Joined:
    Sep 5, 2007
    Messages:
    264
    Resources:
    0
    Resources:
    0
    Use "air-shackles" as your base ability, change the art to the art for mana drain (lightning effect included), then change the targets allowed to allow you to target your "fish". :thumbs_up:
     
  3. Serefkana

    Serefkana

    Joined:
    Jan 28, 2009
    Messages:
    15
    Resources:
    0
    Resources:
    0
    Aerial Shackles didn't allow me to target the ground(water), but I found a way to do it with my skill... But I have some problems:

    1) I want to make it so the caster doesn't move while its happening(but if i make cast time, the effects dont happen till after casttime). So I tryed pausing the unit, but when i unpaused it continues the skill thus having an infinite loop... I corrected it by removing the skill after unpausing and adding it again after .5sec, but there must be a more efficient way to do that.

    2) I want to make it so I can only target water, but all I could do was limit the caster to have to be in water... Any ideas?

    3) How do I make a random integer? aka probability...

    Heres what I have so far:
    • Untitled Trigger 001
      • Events
        • Unit - A unit Begins casting an ability
      • Conditions
        • (Ability being cast) Equal to Fishing fosjomg
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Land <gen> contains (Triggering unit)) Equal to False
          • Then - Actions
            • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Other\Drain\ManaDrainCaster.mdl
            • Lightning - Create a Drain Mana lightning effect from source (Position of (Triggering unit)) to target (Target point of ability being cast)
            • Countdown Timer - Start fTimer[(Player number of (Triggering player))] as a One-shot timer that will expire in 5.00 seconds
            • Unit - Remove Fishing fosjomg from (Triggering unit)
            • Unit - Pause all units . . . . . . . . test map only has 1 unit, didn't wanna bother making a variable
          • Else - Actions
            • Game - Display to (All allies of (Owner of (Triggering unit))) the text: You cannot fish on ...


    • Untitled Trigger 002
      • Events
        • Time - fTimer[1] expires
      • Conditions
      • Actions
        • Lightning - Destroy (Last created lightning effect)
        • Special Effect - Destroy (Last created special effect)
        • Unit - Unpause all units
        • Wait 0.50 seconds
        • Unit - Add Fishing fosjomg to Peasant 0001 <gen>


    Any ideas/corrections that can make this more efficent/do what I want are appreciated.

    Thanks, -Seref
     
  4. Lord_BoNes

    Lord_BoNes

    Joined:
    Sep 5, 2007
    Messages:
    264
    Resources:
    0
    Resources:
    0
    You can use "begins casting an ability" to do your water check, if the destination isn't water, then just order casting unit to "stop". Use "starts effect of ability" to do the actual triggering.

    As for the movement issue:
    clone Neutral Passive>Slow Aura, set "movement speed factor" to -10 (just to be sure, incase of bonuses). If you can't set the value to a negative, then hold shift while you double-click it. You can change the buff to say something like: "This unit is fishing". Make sure the "targets allowed" is set to self.
    In your "starts effect" trigger, give this cloned ability to your caster.
    For this to work, you need to goto Advanced>Gameplay Constants, set "Movement - Unit Speed Minimum" to zero.

    For a random value (real or integer) just scoll down the action list to "maths - random value".

    To check if your unit has changed orders, just do a periodic check, to see if its "current order" is the order string of your fishing ability, if not then remove the cloned ability (allowing the unit to move).
     
  5. Serefkana

    Serefkana

    Joined:
    Jan 28, 2009
    Messages:
    15
    Resources:
    0
    Resources:
    0
    [edit]

    Everything works perfectly now^.^
    Thanks for all the help, +rep

    ps. heres the map if anyone wants to check it out...
    the only area that counts as "land" is the starting island(cuz i'm too lazy)
     

    Attached Files:

    Last edited: Feb 20, 2009
  6. Lord_BoNes

    Lord_BoNes

    Joined:
    Sep 5, 2007
    Messages:
    264
    Resources:
    0
    Resources:
    0
    Use "target point of ability being cast". Use an "if/then/else" check to see if it's on land.
    • WaterCheck
      • Events
        • Unit - A unit Begins casting an ability
      • Conditions
        • (Ability being cast) Equal to Fishing (fosjomg)
      • Actions
        • if
          • (Land <gen> contains (Target point of ability being cast)) Equal to True
        • then
          • Unit - Order (Casting unit) to Stop
          • Game - Display to (All allies of (Owner of (Casting unit))) the text: You cannot fish on ...
        • else
          • <do the actual fishing>


    As for your triggers... do a search for "memory leaks".

    Memory leaks are, mostly, temporary variables that hold information, if a leak isn't cleaned up then the memory that the variable was using isn't freed up... there are many kinds of leaks, and many ways to clean them up. GUI doesn't have access to these ways, however, you have to use what's called "custom scipt" to do it. Just remember that any variable used in custom script need to have "udg_" in front of them, and "_" where any spaces are.

    Basicly, a "memory leak" is like a locker, you need the combination(variable) to open the locker(memory location), if you go into something else(different trigger/function), you forget that combination, and have to get a whole new locker... then, another & another, etc. Over time, the locker room runs out of space, and Wc3 starts lag.

    These are the leaks in the above trigger:
    • (Land <gen> contains *leak*(Target point of ability being cast)) Equal to True


    • Unit - Order *leak*(Casting unit) to Stop


    • Game - Display to *leak*(All allies of (Owner of (Casting unit))) the text: You cannot fish on ...


    To fix these leaks you need to assign them to variables to be able to clean them afterwards.
    • set <location variable> to (Target point of ability being cast)
    • (Land <gen> contains <location variable>) Equal to True
    • custom scipt: call DestroyLocation(<location variable>)
    • custom scipt: set udg_<location variable> = null


    To do your text and "unit stop", you're better off just using only custom scipt:
    • set <unit variable> to (casting unit)
    • set <player variable> to (owner of <unit variable>)
    • custom scipt: call DisplayTextToPlayer(udg_<player variable>, 0, 0, <text>)
    • custom scipt: set udg_<player variable> = null
    • custom scipt: set udg_<unit variable> = null


    This may not seem straight forward at first, but just work on it one line at a time. :thumbs_up:
     
  7. Justify

    Justify

    Joined:
    Mar 16, 2008
    Messages:
    935
    Resources:
    5
    Models:
    1
    Icons:
    1
    Spells:
    3
    Resources:
    5
    Sry BoNes, but the stuff you wrote about leaks isn't completly true :p

    • Unit - Order *leak*(Casting unit) to Stop

    Doesn't leak, "casting unit" returns a unit, but without assigning it to a variable there is no leak. In addition, only locals need to be nulled because you use globals again and again, so even if you store "casting unit" in a variable
    • custom scipt: set udg_<unit variable> = null

    it's not needed to null it. Also you NEVER need to null players, neither in GUI nor in Jass.

    The rest is ok :p
     
  8. Lord_BoNes

    Lord_BoNes

    Joined:
    Sep 5, 2007
    Messages:
    264
    Resources:
    0
    Resources:
    0
    I've always nulled units and players... I was informed (can't remember who by) that it was better to do it, and that they leak if not nulled. But, I'm open to constructive criticism... thanx for the input. :thumbs_up: