• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Deny Spell Casting

Status
Not open for further replies.
Level 12
Joined
Nov 20, 2007
Messages
660
Hello guys, I'm making a arena like map and I need some help.
The problem is that I want heroes to be able to cast spells only across the arena. So when they cast a spell out of arena (let's say blink) I want to intrerupt them and show a message to the player ("Invalid Zone" or something :ogre_haosis:)

117257d1345989366-deny-spell-casting-arena.jpg


That's what I tried and it works good enough
  • Cast DeadZones
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Level of Dummy (Misc) for (Triggering unit)) Equal to 0
    • Actions
      • Set Game_LeakPoint = (Target point of ability being cast)
      • Unit - Create 1 Dummy (0) for Neutral Hostile at Game_LeakPoint facing Default building facing degrees
      • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Arena Region <gen> contains (Last created unit)) Not equal to True
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
But it bugs when you cast non-target spells (casting non-target spells creates my dummy in middle of arena :vw_sad:)

Can anyone help ?
 

Attachments

  • Arena.jpg
    Arena.jpg
    13.6 KB · Views: 211
Level 12
Joined
Nov 20, 2007
Messages
660
  • Set Game_LeakPoint = (Position of triggering unit)
Then check again.

ALTERNATIVELY:
Catch the spell when the unit is ordered to cast it - you'll have to separate this into 3 phases - one for no target, one for unit target, and one for point target.

1.Tested -> Not working at all.
2.I have too many spells and checking if casting spell is non-target / non-point it's not a good option because it will dramatically increase fps.

Any other suggestions ?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Instead of creating a dummy, there's a condition like this:
  • (ArenaRegion contains Game_LeakPoint) Equal to False
Also, ruleofiron99 is correct. (No target shouldn't be checked though, as it should always work).
Edit: So just creating an Or - Condition with all point-target spells won't do? I think it wouldn't increase FPS at all.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Hmh, I just thought of something else.

  • Stop Casting
    • Events
      • Unit - A unit Begins channeling an ability
    • Conditions
    • Actions
      • Set tempLoc1 = (Target point of ability being cast)
      • Set tempLoc2 = (Center of (Entire Map))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Region 000 <gen> contains tempLoc1) Equal to False
          • (X of tempLoc1) Not equal to (X of tempLoc2)
          • (Y of tempLoc1) Not equal to (Y of tempLoc2)
        • Then - Actions
          • Unit - Order (Triggering unit) to Stop
        • Else - Actions
      • Custom script: call RemoveLocation( udg_tempLoc1 )
      • Custom script: call RemoveLocation( udg_tempLoc2 )
If the order is an order with no target, then "Target point of ability being cast" would be the same as "Center of (Playable Map Area)".
Thus, if tempLoc1 == tempLoc2, then the spell should always work (as it doesn't have a target and therefore cannot be cast outside the area).
But if they are not the same, that means the spell has a target (whether that is a unit or point doesn't matter). If that point is outside the area, stop the caster.

Tested it for all 3 types, it should work.
 
Last edited:
Level 33
Joined
Mar 27, 2008
Messages
8,035
Unit - A unit Begins channeling an ability
Are you sure it's channeling instead of casting ?
Also, to order unit to stop right after an Event, does that works ?
I always add a Wait of 0.00 seconds, it works (it is MUI, don't worry).
If I don't add that, the Stop Unit action never gets fired (it happens too fast, that's why)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
What if you cast an unwanted spell (point) in Center of Playable area ?
System won't stop it
That never happens. No matter how hard you may try.
The coordinates should be exactly 0.000. Even if you have 0.001 as 1 of the coordinates it will cancel the order (and trust me, to aim that well with even 1 coordinate is something I have yet to see - to do it with both is outright impossible).
If you want to prove me wrong, then go ahead. I would actually love that :p

Edit: I actually tested it. Since I couldn't get it right, I tried to do it with cheats.
As said before, unless you're more accurate than "0.001", the spell will get canceled (0.0009 and less will allow the spell to be cast).

I also noticed it should be "Center of (Entire Map)". Changed that in the original post as well.
 
Status
Not open for further replies.
Top