• 🏆 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!

[Spell] Spell Return : Reflect back a spell to the caster

Status
Not open for further replies.
Level 1
Joined
Apr 23, 2018
Messages
4
Hello Dear Hive Members,

I am trying to create a "spell return" trigger that would reflect back spells to their casters when a target has a specific custom buff.
If you know DotA/DotA², then you will understand that the objective is to reproduce the Lotus Orb object effect.

I imagined this simple algorithm :
* Event : When a unit casts a spell with a unit as a target
* Condition : Target unit of ability being cast has buff "Spell return"
* Actions :
- Create a Dummy unit on the target unit
- Add the same ability to it
- Order it to cast this ability on the initial caster

My current trigger looks like this (forgive me, I am using World Editor in French but you should understand most of it or at least the principle) :
Code:
Renvoi de sorts spell
    Events
        Unité - A unit Commence le lancement d'une compétence
    Conditions
        ((Target unit of ability being cast) has buff Renvoi de sorts ) Egal à TRUE
    Actions
        Unité - Order (Triggering unit) to Arrêter
        Set _point1 = (Position of (Target unit of ability being cast))
        Unité - Create 1 Dummy for (Owner of (Target unit of ability being cast)) at _point1 facing Orientation bâtiment par défaut 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é - Add a 10.00 second Générique expiration timer to (Last created unit)
        -------- - --------
        Set _bool_SpellCastOk = TRUE
        Set _ability1 = (Ability being cast)
        Set _unit_SpellCaster = (Last created unit)
        Set _unit_TargetUnit = (Triggering unit)
        Custom script:   set udg__bool_SpellCastOk = IssueTargetOrderById(udg__unit_SpellCaster, udg__ability1, udg__unit_TargetUnit)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            Si - Conditions
                _bool_SpellCastOk Egal à TRUE
            Alors - Actions
                Partie - Display to (All players) for 10.00 seconds the text: (Renvoi de sorts |c00ff40ff40successful|r :  + (Name of (Ability being cast)))
            Sinon - Actions
                Partie - Display to (All players) for 10.00 seconds the text: (Renvoi de sorts |c00ff0000FAIL|r :  + (Name of (Ability being cast)))
        -------- - --------
        Custom script:   call RemoveLocation(udg__point1)

This does not work. (I always have the message "FAIL", see above code).

Correct me if I'm wrong, but I think the problem is with the 2nd parameter of IssueTargetOrderById(...) which should be an ability string like "A000".
I have looked everywhere on the Internet, but I have never found anyone using something else than a ****ing CONSTANT string as second parameter of IssueTargetOrderById(..., <???>, ...).

Can you guys tell me how I can retrieve dynamically the code ("A002", "Aabs" etc.) of the ability being cast ?
(Ideally I would prefer a full GUI solution but as I think that's not possible, (minimal) custom calls to JASS will be OK).

In case I have not made myself clear, don't hesitate to ask details.

Thanks for your help
 
You do not need the ability number, you need the orderString(Id).
In your case this should do the trick and give the correct order: GetUnitCurrentOrder(GetTriggerUnit() )
also available in GUI:
  • Set Order = (Current order of (Triggering unit))
But you still need to do the ordering in Custom script as you do. using the the Order variable instead of abilityId.


Can you guys tell me how I can retrieve dynamically the code ("A002", "Aabs" etc.) of the ability being cast ?
'A002' 'Aabs' are numbers of a numeral system with base 256 (USACII), you have them already when you have the ability variable, but they don't help you much here.
 
Last edited:
Level 1
Joined
Apr 23, 2018
Messages
4
Oh god I did not think about this way to do so... It works, much thanks ! :)

However, my dummy takes a few seconds to bounce back the spell because I have set the property "Time to cast spell" ("Cast1" field of the spell) on it.
Is there a simple way to remove the delay ?
 
Not without drawbacks.
One could change the event to begins channeling, but in that case the unit's specific castpoint time is also inside the casttime and you dummy proably casts faster then the real caster. You could also try begins casting event.
It also would requier you to stop the dummy from casting the spell if the real caster decides to stop, before starting the effect of the ability.

Some other Idea would be to create instant fake spells of such spells.

I don't know others ways.
 
Status
Not open for further replies.
Top