• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Problems with changing the owner pls help

Status
Not open for further replies.
Level 7
Joined
Feb 4, 2005
Messages
289
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.
 
Level 7
Joined
Feb 4, 2005
Messages
289
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.
 
Level 22
Joined
Jan 10, 2005
Messages
3,426
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
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
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
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 ...
JASS:
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.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
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.
 
Level 7
Joined
Feb 4, 2005
Messages
289
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.
 
Status
Not open for further replies.
Top