Confusion spell (like control mental)

Level 14
Joined
Dec 12, 2021
Messages
167
Someone will have a spell which has an area of effect that consists of confusing enemies so that they can attack their closest allies for X seconds and after that time they return to normal, but during that time the enemy player cannot control your units or prevent them from attacking them. NOTE: it is a confusion skill, not a mental control skill like many I have seen here, I am not looking to control the enemy unit and pass it on to my army, just make it attack its allies (my enemies)
 
Level 25
Joined
Feb 9, 2009
Messages
1,798
Can't find it on hive for whatever reason; but, Dinowc made this necromancer showcase that has that ability.

Code:
//TESH.scrollpos=22 //TESH.alwaysfold=0 scope confusion initializer init //CONFIGURABLE: globals private constant integer SPELL_ID = 'A003' private constant integer CURSE_DUMMY = 'h002' private constant integer CURSE_SPELL = 'A004' private constant integer CURSE_BUFF = 'B000' private constant real INTERVAL = 0.1 private constant real AOE_BASE = 300. private constant real AOE_INCREMENT = 50. private constant real SEARCH_AOE = 500. //Note: Duration depends on CURSE_SPELL duration; change it in object editor endglobals //NOT SO MUCH CONFIGURABLE: globals private group G1 = CreateGroup() private group G2 = CreateGroup() private group CURSED = CreateGroup() private timer T = CreateTimer() private unit DUMMY private integer COUNT = 0 private unit array TARGET private integer ID private player OWNER private unit U endglobals private function AoE takes integer lvl returns real return AOE_BASE + (lvl - 1) * AOE_INCREMENT endfunction private function SearchTargets takes nothing returns boolean local unit picked = GetFilterUnit() if picked != U and GetWidgetLife(picked) > 0. then call GroupAddUnit(G2, picked) endif set picked = null return false endfunction private function ForceAttack takes nothing returns nothing local unit picked = GetEnumUnit() set ID = GetUnitId(picked) if TARGET[ID] == null or GetWidgetLife(TARGET[ID]) == 0 then set U = picked call GroupEnumUnitsInRange(G1, GetUnitX(picked), GetUnitY(picked), SEARCH_AOE, Filter(function SearchTargets)) set TARGET[ID] = GroupPickRandomUnit(G2) call GroupClear(G2) else call ClearSelectionForPlayer(GetOwningPlayer(picked)) call IssueTargetOrder(picked, "attack", TARGET[ID]) endif if GetUnitAbilityLevel(picked, CURSE_BUFF) == 0 then call IssueImmediateOrder(picked, "stop") call GroupRemoveUnit(CURSED, picked) set COUNT = COUNT - 1 endif set picked = null endfunction private function callback takes nothing returns nothing call ForGroup(CURSED, function ForceAttack) if COUNT == 0 then call PauseTimer(T) endif endfunction private function filterFunc takes nothing returns boolean local unit picked = GetFilterUnit() if IsUnitEnemy(picked, OWNER) and GetWidgetLife(picked) > 0. and IsUnitType(picked, UNIT_TYPE_MAGIC_IMMUNE) == false then call SetUnitX(DUMMY, GetUnitX(picked)) call SetUnitY(DUMMY, GetUnitY(picked)) call IssueTargetOrder(DUMMY, "curse", picked) call GroupAddUnit(CURSED, picked) set COUNT = COUNT + 1 endif set picked = null return false endfunction private function actions takes nothing returns boolean local unit caster local integer lvl if GetSpellAbilityId() == SPELL_ID then set caster = GetTriggerUnit() set lvl = GetUnitAbilityLevel(caster, SPELL_ID) set OWNER = GetOwningPlayer(caster) call SetUnitOwner(DUMMY, OWNER, false) call SetUnitAbilityLevel(DUMMY, CURSE_SPELL, lvl) if COUNT == 0 then call TimerStart(T, INTERVAL, true, function callback) endif call GroupEnumUnitsInRange(G1, GetSpellTargetX(), GetSpellTargetY(), AoE(lvl), Filter(function filterFunc)) endif set caster = null return false endfunction private function init takes nothing returns nothing local trigger t = CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT) call TriggerAddCondition(t, Condition(function actions)) set DUMMY = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), CURSE_DUMMY, 0., 0., 0.) endfunction endscope
 

Attachments

  • Necro Walker v1.2.w3x
    406.1 KB · Views: 6
Level 25
Joined
Feb 9, 2009
Messages
1,798
Id be happy to try but you might be having trouble because Jass helper isn't turned on, as soon as you try to edit a jass map it will have a hissy fit if this isn't checked before you test it:
1728286176828.png
 
Level 14
Joined
Dec 12, 2021
Messages
167
Sorry for the delay, I was a little loaded with university topics, getting back to the topic, friend, I tried to open it in my world editor but it is not possible and I get the following message, maybe it is because I use a version older than yours. Anyway, maybe you could show me the triggers and commands you made in GUI through a screenshot that way I can configure it on my map and try it to see how it goes, or maybe there is another way to open the map with the version that I have and I don't know that way.
 

Attachments

  • ERROR WE.jpg
    ERROR WE.jpg
    55.8 KB · Views: 9
Level 25
Joined
Feb 9, 2009
Messages
1,798
Sorry for the delay, I was a little loaded with university topics, getting back to the topic, friend, I tried to open it in my world editor but it is not possible and I get the following message, maybe it is because I use a version older than yours. Anyway, maybe you could show me the triggers and commands you made in GUI through a screenshot that way I can configure it on my map and try it to see how it goes, or maybe there is another way to open the map with the version that I have and I don't know that way.
No problem, I've attached the wtg file, you can attempt to see if you can import the triggers instead.
World_Editor>Trigger_Editor>File>Import_Triggers...>Attached .wtg file
1728698749835.png


Changes:
Removed Dummy, and triggering spell is based on silence spell to apply buff, obviously silence toggled off.

Recommendation:
Get damage engine that works for your version to ensure kills made during this effect credit the owner of the caster.

  • CoFu Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- SPELL / DUMMY / DUMMY SPELL / SPELL BUFF --------
      • Set VariableSet CoFu_C_Spell_ID[0] = Confusion (Neutral Hostile)
      • Set VariableSet CoFu_C_Curse_Buff = Confusion
      • -------- --------
      • -------- INTERVAL --------
      • Set VariableSet CoFu_C_Config_Real[0] = 0.10
      • -------- --------
      • -------- AOE_BASE --------
      • Set VariableSet CoFu_C_Config_Real[1] = 300.00
      • -------- --------
      • -------- AOE INCREMENT --------
      • Set VariableSet CoFu_C_Config_Real[2] = 50.00
      • -------- --------
      • -------- SEARCH AOE --------
      • Set VariableSet CoFu_C_Config_Real[3] = 500.00
      • -------- --------
      • Set VariableSet CoFu_C_Timer_Periodic = 0.03
      • Trigger - Add to CoFu Loop <gen> the event (Time - Every CoFu_C_Timer_Periodic seconds of game time)

  • CoFu Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to CoFu_C_Spell_ID[0]
    • Actions
      • Set VariableSet CoFu_A_Unit[0] = (Triggering unit)
      • Set VariableSet CoFu_A_Point[1] = (Target point of ability being cast)
      • Set VariableSet CoFu_C_Config_Real[4] = (CoFu_C_Config_Real[1] + (((Real((Level of CoFu_C_Spell_ID[0] for CoFu_A_Unit[0]))) - 1.00) x CoFu_C_Config_Real[2]))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within (CoFu_C_Config_Real[4] + 125.00) of CoFu_A_Point[1].) and do (Actions)
        • Loop - Actions
          • Custom script: if IsUnitInRangeLoc(GetEnumUnit(), udg_CoFu_A_Point[1], udg_CoFu_C_Config_Real[4]) then
          • Set VariableSet CoFu_A_Point[2] = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) belongs to an enemy of (Owner of CoFu_A_Unit[0]).) Equal to True
            • Then - Actions
              • Set VariableSet CoFu_A_Index = (CoFu_A_Index + 1)
              • Set VariableSet CoFu_B_Unit_Owner[CoFu_A_Index] = (Owner of CoFu_A_Unit[0])
              • Set VariableSet CoFu_B_Unit_Target[CoFu_A_Index] = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CoFu_A_Index Equal to 1
                • Then - Actions
                  • Trigger - Turn on CoFu Loop <gen>
                • Else - Actions
            • Else - Actions
          • Custom script: call RemoveLocation(udg_CoFu_A_Point[2])
          • Custom script: endif
      • Custom script: call RemoveLocation(udg_CoFu_A_Point[1])

  • CoFu Loop
    • Events
    • Conditions
    • Actions
      • For each (Integer CoFu_A_Loop) from 1 to CoFu_A_Index, do (Actions)
        • Loop - Actions
          • Selection - Clear selection for (Owner of CoFu_B_Unit_Target2[CoFu_A_Loop]).
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • CoFu_B_Unit_Target2[CoFu_A_Loop] Equal to No unit
                  • (CoFu_B_Unit_Target2[CoFu_A_Loop] is dead) Equal to True
            • Then - Actions
              • Set VariableSet CoFu_A_Point[3] = (Position of CoFu_B_Unit_Target[CoFu_A_Loop])
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within (CoFu_C_Config_Real[3] + 125.00) of CoFu_A_Point[3].) and do (Actions)
                • Loop - Actions
                  • Custom script: if IsUnitInRangeLoc(GetEnumUnit(), udg_CoFu_A_Point[3], udg_CoFu_C_Config_Real[3]) then
                  • Set VariableSet CoFu_A_Point[4] = (Position of (Picked unit))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is alive) Equal to True
                      • ((Picked unit) belongs to an enemy of CoFu_B_Unit_Owner[CoFu_A_Loop].) Equal to True
                      • (Picked unit) Not equal to CoFu_B_Unit_Target[CoFu_A_Loop]
                    • Then - Actions
                      • Unit Group - Add (Picked unit) to CoFu_B_Group
                    • Else - Actions
                  • Custom script: call RemoveLocation(udg_CoFu_A_Point[4])
                  • Custom script: endif
              • Set VariableSet CoFu_B_Unit_Target2[CoFu_A_Loop] = (Random unit from CoFu_B_Group)
              • Unit - Order CoFu_B_Unit_Target[CoFu_A_Loop] to Attack CoFu_B_Unit_Target2[CoFu_A_Loop]
              • Unit Group - Remove all units from CoFu_B_Group.
              • Custom script: call RemoveLocation(udg_CoFu_A_Point[3])
            • Else - Actions
              • Unit - Order CoFu_B_Unit_Target[CoFu_A_Loop] to Attack CoFu_B_Unit_Target2[CoFu_A_Loop]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (CoFu_B_Unit_Target[CoFu_A_Loop] is alive) Equal to False
                  • (CoFu_B_Unit_Target[CoFu_A_Loop] has buff CoFu_C_Curse_Buff) Equal to False
            • Then - Actions
              • Set VariableSet CoFu_B_Unit_Target2[CoFu_A_Loop] = No unit
              • Unit - Order CoFu_B_Unit_Target[CoFu_A_Loop] to Stop.
              • Set VariableSet CoFu_B_Unit_Owner[CoFu_A_Loop] = CoFu_B_Unit_Owner[CoFu_A_Index]
              • Set VariableSet CoFu_B_Unit_Target2[CoFu_A_Loop] = CoFu_B_Unit_Target2[CoFu_A_Index]
              • Set VariableSet CoFu_B_Unit_Target[CoFu_A_Loop] = CoFu_B_Unit_Target[CoFu_A_Index]
              • Set VariableSet CoFu_A_Index = (CoFu_A_Index - 1)
              • Set VariableSet CoFu_A_Loop = (CoFu_A_Loop - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CoFu_A_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 

Attachments

  • Confusion GUI by Devalut - ORIGINAL SPELLS AND MAP BY Dinowc.wtg
    10.9 KB · Views: 4
Last edited:
Level 14
Joined
Dec 12, 2021
Messages
167
I still can't open maps or detonators that you gave me, maybe it's because of the old version I have, it doesn't matter, anyway I tried to copy the detonators that you gave me but the in-game ability doesn't work for me, I suspect a detonator is missing that you didn't publish here and that's why I couldn't complete the detonators on my map (I think the casting detonator is missing). If you would be so kind, could you check what I did on the map, and put the GUI configuration of the CAST detonator


EDIT: I would like to specify that you place the missing detonator (CAST) here in HIVE, since the maps that you are giving me are impossible for me to load.
 

Attachments

  • Confuuu.w3x
    18.7 KB · Views: 5
Level 14
Joined
Dec 12, 2021
Messages
167
wow brother, I'm really freaking out, you did a perfect job, it works completely fine for me in the game, thank you very much you are a God in this.

Extra: This issue is completely resolved but since we are here I would like to take the opportunity to ask you to help with a spell that I have but it is somewhat "incomplete", it is an area spell that I want to make channelable, that is, when the unit move, stun it, or otherwise interrupt the spell, the latter stopping. The truth is that I tried everything but I don't know how to do it, if you could help me by telling me which detonators to add to make it look great, please.

I could send you the file once you confirm your help and of course, if you would have a little time to help me
 

Attachments

  • Confuuu.w3x
    20.1 KB · Views: 6
Level 25
Joined
Feb 9, 2009
Messages
1,798
wow brother, I'm really freaking out, you did a perfect job, it works completely fine for me in the game, thank you very much you are a God in this.

Extra: This issue is completely resolved but since we are here I would like to take the opportunity to ask you to help with a spell that I have but it is somewhat "incomplete", it is an area spell that I want to make channelable, that is, when the unit move, stun it, or otherwise interrupt the spell, the latter stopping. The truth is that I tried everything but I don't know how to do it, if you could help me by telling me which detonators to add to make it look great, please.

I could send you the file once you confirm your help and of course, if you would have a little time to help me
Happy to help :)

As for the other item, we must be polite and either move this to a direct message or create a second request.
 
Top