• 🏆 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 with spell

Status
Not open for further replies.
Level 2
Joined
Apr 7, 2016
Messages
15
So I've been thinking, if it is possible to make an effect like: "Mark an enemy unit. Whenever any enemy unit casts a spell on your hero, cast a copy of it on the marked enemy"

So here is what I had in mind it may look like:

Event:
-Unit activates (uses) a spell

Conditions:
-Marked Unit is alive
and
-Casting (triggering) unit belongs to an enemy of owner target of ability being cast

Actions:
-Set CopyOrigin = Casting (triggering) unit
-Set CopySpell = Ability being cast
-Set CopyLevel = Level of CopySpell for CopyOrigin
-Create a unit "Dummy Caster" for owner of target of ability at position of MarkedUnit
-Set CopyCaster = Last Created Unit
-Add CopySpell to CopyCaster
-Set level of CopySpell for CopyCaster to CopyLevel
--------------------------------
and that is where've I met a problem: I don't know for sure what kind of ability will be cast so I can't set one defined order and if I set CopyOrder = Issued order (or whatever) I still can't access it via "-Issue order targeting a unit"

With that given can anyone help me with that problem, please?
 
Level 9
Joined
Apr 23, 2011
Messages
527
Editing from a previous post of mine, could help:

Ah, in that case, you'd probably need a custom script to detect the order id. Something like this?
JASS:
set order_id = GetIssuedOrderId()

Then to make the unit cast the ability, use this (replace the unit variable to whatever you use):
JASS:
call IssueImmediateOrderById(unit_var, order_id)

I am not sure if setting the variable like that works.
 
Level 7
Joined
Dec 28, 2014
Messages
83
The only way to get order ID of the ability being cast is by using Custom Script or JASS.

Here's how it should look like:
  • Custom script: call IssueTargetOrderById(bj_lastCreatedUnit, GetUnitCurrentOrder(GetTriggerUnit()),GetTriggerUnit())
Since your idea catch my interest, I made my own version.


  • Spell Reflect
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to Dummy
      • (Level of Spell Reflect for (Target unit of ability being cast)) Greater than 0
      • ((Target unit of ability being cast) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
    • Actions
      • Unit - Create 1 Dummy for (Owner of (Target unit of ability being cast)) at (Position of (Triggering unit)) facing Default building facing degrees
      • Unit - Add (Ability being cast) to (Last created unit)
      • Unit - Set level of (Ability being cast) for (Last created unit) to (Level of (Ability being cast) for (Triggering unit))
      • Unit - For Unit (Last created unit), Set mana cost of ability (Ability being cast), Level: (Level of (Ability being cast) for (Last created unit)) to 0
      • Custom script: call IssueTargetOrderById(bj_lastCreatedUnit, GetUnitCurrentOrder(GetTriggerUnit()),GetTriggerUnit())
      • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)


To proof it works, I added a sample map in the attachment.
 

Attachments

  • Spell Reflect.w3x
    10.4 KB · Views: 28
Status
Not open for further replies.
Top