Warcraft III resources & community, 2003–2006 · archived
Problems with changing the owner pls help
8 posts
Impac7
#1
Problems with changing the owner pls help
Unit - A unit Starts the effect of an ability
(Ability being cast) Equal to Cluster Rockets
Unit Group - Pick every unit in (Units within 80.00 of (Target point of ability being cast)) and do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Picked unit) is A structure) Equal to False ((Picked unit) is A Hero) Equal to False ((Picked unit) is alive) Equal to True Then - Actions Unit - Change ownership of (Picked unit) to (Owner of (Casting unit)) and Change color Unit - Change color of (Picked unit) to Green Wait 10.00 seconds - PROBLEM. DOESNT CHANGE BACK Unit - Change ownership of (Picked unit) to (Previous owner) and Change color Else - Actions Do nothing
It changes the units in the area to owner of casting unit, then it doesnt change them back to previous owner.
Any ideas what changes to these triggers should i make so as to make the changing of onwer back to previous onwer work ? Pls find it out for me and it is done.
try saving the owner of the units (before changing) as a player variable, then after 10 sec set it the owner of the units to the player variable
Impac7
#3
Could you put the code with the variables within these triggers up there because i didnt quite get it what to make the variable equal to (i tried some with the sets variable but obviously i didnt make it correctly and didnt understand u). Variable is
Name: Type: Value: Player Player -None-
Yes i tried set player=previous owner put it before wait 10 secs (i think u meant smth else i didnt understand u )nothing happened.
Unit Group - Pick every unit in (Units within 80.00 of (Target point of ability being cast)) and do (Actions) Loop - Actions If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions ((Picked unit) is A structure) Equal to False ((Picked unit) is A Hero) Equal to False ((Picked unit) is alive) Equal to True Then - Actions Set Variable - Set *.....* (player variable) to 'owner of picked unit' Unit - Change ownership of (Picked unit) to (Owner of (Casting unit)) and Change color Unit - Change color of (Picked unit) to Green Wait 10.00 seconds Unit - Change ownership of (Picked unit) to *the plauer variable* Else - Actions Do nothing
LOL you two have little idea how the pick all unit action works. . . You can NOT use wait action in a pick units action and doing so will cause it to skip all the actions after the wait as if they were not there.
Well enough of that and back to the spell. . .
Using globals will result in a lack of multi incastibility. Some leaks occure. Spell does not function properly.
that was what it was like before.
Now here is the fixed all JASS version that took me 1 hour to make ...
function Trig_AoE_Convert_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'ANcs'
endfunction
function Trig_AoE_Convert_Actions takes nothing returns nothing
local location L = GetSpellTargetLoc()
local group G = GetUnitsInRangeOfLocAll(80.00,L)
local group G2 = GetUnitsInRangeOfLocAll(80.00,L)
local player array P
local integer I = 0
local unit U
call RemoveLocation(L)
loop
set U = FirstOfGroup(G)
exitwhen U == null
if GetUnitState(U,UNIT_STATE_LIFE) >= 1 and IsUnitType(U,UNIT_TYPE_HERO) == false and IsUnitType(U,UNIT_TYPE_STRUCTURE) == false then
set P[I] = GetOwningPlayer(U)
call SetUnitOwner(U,GetOwningPlayer(GetSpellAbilityUnit()),true)
call SetUnitColor(U,PLAYER_COLOR_GREEN)
endif
call GroupRemoveUnit(G,U)
set U = null
set I = I+1
endloop
call DestroyGroup(G)
call TriggerSleepAction(10.00)
set I = 0
loop
set U = FirstOfGroup(G2)
exitwhen U == null
call SetUnitOwner(U,P[I],true)
set P[I] = null
call GroupRemoveUnit(G2,U)
set U = null
set I = I+1
endloop
call DestroyGroup(G2)
set L = null
set G = null
set G2 = null
endfunction
function InitTrig_AoE_Convert takes nothing returns nothing
set gg_trg_AoE_Convert = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_AoE_Convert,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_AoE_Convert,Condition(function Trig_AoE_Convert_Conditions))
call TriggerAddAction(gg_trg_AoE_Convert,function Trig_AoE_Convert_Actions)
endfunction
It is WAY better than GUI could ever make. No leaks, few functions, multincastable and last but not least, works. Even the flaw that you never saw of if more than 1 enemy player's units are in the area give them back to the rightfull owners and not all to one it supports.
Like in your script all parameters (AoE and duration) are the same and it runs by casting normal cluster rockets.
Please give me credits for the coding of the spell in eithor the tooltips of the spell or in the quest section since I do not waste one hour of my time not to be even thanked.
Im not saying wait functions in loops DO NOT work im saying wait functions in pick all units in group and do actions DO NOT work!
In loops it delays the loop X time before continuing. In the pick all units in group and do action it abborts the next order after the wait because all units must be picked and have had their actions done without delay and this includes if there is a loop in the actions.
Well anyway my method i used jass to instead of picking all units to loop picks all units. When loop picking you can use wait but I did not for a logical reason (would cause each unit to be given, wait 10 secs and given back singualy one at a time(not like wanted)).
I tested my script and it worked perfectly so hope you enjoy.
Impac7
#8
Thx Ramza for at least giving me ideas no matter they didnt work and thanks Dr Super good for actually making it work, + read your PMs i also asked about 1 little fix if possible, if not ok.