HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Probably an easy question and answer

07-23-2008, 08:59 PM#1
Azhag
When a unit dies in a region, how do I trigger it so another unit of the same type gets created in that same region at a random point 25 seconds later? (GUI)

Also how do you hide a passive ability such as Critial Strike and Evasion, so it doesn't show on a unit, but still triggers as if it was still there.

Thanks for all the help.
07-23-2008, 09:04 PM#2
Fireeye
Use the event A Unit Dies and check with the boolean condition if the unit is within the desired region, if you have multiple regions, you gonna need a loop.
The place a wait in first line, then use the CreateUnit Action with a random point of the desired region (look out for leaks).
That's it, i might post an example trigger later.

To your 2nd question, give the unit a spellbook with the critical strike and evasion in it and disable the skill (Spellbook) for the corresponding player on map init.
It will not be shown then anymore, however Crit and Evasion should still fire.

---Edit---
Here ya go with the basic trigger (you can also use a loop + if / then / else in the actions if you want to use the trigger for multiple regions.

Trigger:
RespawnUnit
Collapse Events
Unit - A unit Dies
Collapse Conditions
(<Your Region> contains (Triggering unit)) Equal to True
Collapse Actions
Wait <Your sleep time> seconds
Set tmp_loc = (Random point in (<Your Region>))
Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at tmp_loc facing <whatever degree> degrees
Custom script: call RemoveLocation(udg_tmp_loc)

---Edit2---
The Spellbook is an item ability.
And the leak is fixed (as much as possible in GUI) in my example trigger
07-23-2008, 09:05 PM#3
Azhag
The spellbook is an item correct?
Or is it a ability I am currently not seeing.

EDIT:
And is there a way to prevent leaks as well then?

EDIT2: Thank you for your help.
07-24-2008, 08:37 AM#4
Azhag
Just a quick question for that trigger you provided for me, that can work for multiple regions right?

EDIT 1:
And as for the spellbook idea.
The reason why I want it to be disabled is because I want every unit on the map to be able to have Critical Strike and Evasion.
Will it disable the spellbook for all units by the player?
And will it even disable the book for newly created units as well?
07-24-2008, 09:34 AM#5
Fireeye
If you want to make it work with multiple regions, you'll need a loop.
It would look like this. However it's not really MUI and thus it can bug sometimes, if you want it MUI you'll need JASS to do it.
Following vars are used: tmp_rec {Region}, tmp_check {boolean} and tmp_loc {location}
Trigger:
RespawnLoop
Collapse Events
Unit - A unit Dies
Collapse Conditions
<Whatever Generic Conditions>
Collapse Actions
Collapse For each (Integer A) from 1 to 10, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse IF - Conditions
((<Your Region>) contains (Triggering unit)) Equal to True
Collapse THEN - Actions
Set tmp_check = True
Set tmp_rec = <Your Region>
ELSE - Actions
Wait <Your sleep time> seconds
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse IF - Conditions
tmp_check Equal to True
Collapse THEN - Actions
Set tmp_check = False
Set tmp_loc = (Random point in tmp_rec)
Unit - Create 1 (Unit-type of (Triggering unit)) for (Owner of (Triggering unit)) at tmp_loc facing <whatever angle> degrees
Custom script: call RemoveLocation(udg_tmp_loc)
ELSE - Actions
Same trigger in JASS and MUI.
Collapse JASS:
function Blank takes nothing returns boolean
    return true
endfunction

function Trig_RespawnLoop_Actions takes nothing returns nothing
    local integer i = 0 //looping integer
    local integer exit = 10 //or whatever arrayindex you last used
    local unit u = GetTriggerUnit() //Getting the dying unit
    local real array x //Variables used for the x and y coordinates
    local real array y
    local boolean b = false
    
    set x[0] = GetUnitX(u) //Getting the x coord of the dying unit
    set y[0] = GetUnitY(u) //Same with the y coord
    
    loop
    
        set x[1] = GetRectMinX(udg_Rects[i]) //udg_Rects is a Region array variable
        set y[1] = GetRectMinY(udg_Rects[i]) //You need to assign all used regions
        set x[2] = GetRectMaxX(udg_Rects[i]) //in the map init to one of its slots
        set y[2] = GetRectMaxY(udg_Rects[i]) //don't forget to set exit to the last array slot used
        
        if x[0] >= x[1] and x[0] <= x[2] and y[0] >= y[1] and y[0] <= y[2] then //Checking if unit is in rect
            set b = true //If unit is inside the rect, the loop will be exit after
            set x[3] = GetRandomReal(x[1],x[2]) //Setting the new spawn location within the rect
            set y[3] = GetRandomReal(y[1],y[2])
        endif
        
        exitwhen i > exit or b //Checking for exit conditions
        
        set i = i + 1 //If loop isn't aborted the integer will be increased and the entire check for the next rec will happen
    endloop
    
    call TriggerSleepAction( 25.00 ) //Waiting till respawn should happen (timers would be more accurate)
    
    if b then //Checking for successful check
        //If positive 1 unit of same type will be created somewhere in the corresponding region
        call CreateUnit(GetOwningPlayer(u),GetUnitTypeId(u),x[3],y[3],270)
    endif
    
    //setting local unit u = null
    set u = null
endfunction

//===========================================================================
function InitTrig_RespawnLoop takes nothing returns nothing
    local integer i = 0
    set gg_trg_RespawnLoop = CreateTrigger(  )
    loop
        exitwhen i > 15
        call TriggerRegisterPlayerUnitEvent(gg_trg_RespawnLoop,Player(i),EVENT_PLAYER_UNIT_DEATH,Condition(function Blank))
        set i = i + 1
    endloop
    call TriggerAddAction( gg_trg_RespawnLoop, function Trig_RespawnLoop_Actions )
endfunction
Sorry if there's any error, didn't have the time to check the triggers.
---Edit---
About disabling an ability, you'll find the action in the Player Section of the Actions.
07-24-2008, 06:50 PM#6
Azhag
Well like any mapper, I want to make it as less buggy as possible, so you would suggest the JASS and MUI correct?

EDIT: And sorry what I meant with the disable, is when you disable the ability, it will do it for all units, even newly created ones for the corrisponding player?
07-24-2008, 06:53 PM#7
Fireeye
I personally would always suggest vJASS or normal JASS.
I prefer vJASS, because it reduce the amount to write and make quite some things much easier.
07-24-2008, 06:59 PM#8
Azhag
Is vJass easier to learn as well?
I mean I tried reading some tutorials on learning JASS, just to big, and unfortunatly I couldn't wrap my brain around it at the current moment. (Probably had to do with the fact I was running on no sleep)