Mines

master maste

New Member
Reaction score
32
Trying to make a trigger that detects if a unit comes within 250 of any footman then make only that footman explode.

Tried this in the editor and can't seem to get it going.

Any help would be greatly appreciated.
 

elmstfreddie

The Finglonger
Reaction score
203
If it's only a certain unit that blows up footmen, then use
E - A unit comes within range of (blower upper dude)
C - unit type of triggering unit = footman
A - boom!
 

Icyculyr

I'm a Mac
Reaction score
68
Any footman? try this:

Variables
Code:
UGroup, Unit Group
Code:
[B]AddEventToKillFooty[/B]
Events
    Map Initilization
Conditions
Actions
    Set UGroup = Units in playable map area Matching condition unit-type of matching unit equal to YourUnit
    Pick every unit in UGroup and do Multiple Actions
        Add to KillFooty the event A unit comes within range of 250 of picked unit
    Custom script:   call DestroyGroup(udg_UGroup)

Code:
[B]KillFooty[/B]
Events
    (Added from link, yes this does work I have done it 1,000 times)
Conditions
    Unit-Type of Triggering Unit equal to Footman
Actions
    Kill Triggering Unit

So if the footman walks near the hero, or visa versa, the footman will die.
 

master maste

New Member
Reaction score
32
Made the trigger and tested it, and it did not work. . . btw this needs to work for units that are created at any point in the game.

+rep if you can help me get it to work. :)
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
JASS:
function CreateMine_MineId takes nothing returns integer
    return 'n000'
endfunction

function CreateMine_DetonationRange takes nothing returns real
    return 300.
endfunction

function CreateMine_Detonate takes nothing returns boolean
    local unit footy=GetTriggerUnit()
    if(GetUnitTypeId(footy)=='hfoo')then
        call SetUnitExploded(footy,true)
        call KillUnit(footy)
    endif
    set footy=null
    return false
endfunction

function CreateMine takes nothing returns boolean
    local unit mine=GetEnteringUnit()
    if(GetUnitTypeId(mine)==CreateMine_MineId())then
        call TriggerRegisterUnitInRange(CreateTrigger(),mine,CreateMine_DetonationRange(),Condition(function CreateMine_Detonate))
    endif
    set mine=null
    return false
endfunction
                                                    
//========================================================================================================
function InitTrig_CreateMine takes nothing returns nothing
    local region r=CreateRegion()
    call RegionAddRect(r,GetPlayableMapRect())
    call TriggerRegisterEnterRegion(CreateTrigger(),r,Condition(function CreateMine))
    set r=null
endfunction
 

Icyculyr

I'm a Mac
Reaction score
68
Can you please post your code, so I can see exactly what you are doing?

Because it will work, and just whenever you create the unit

use the same event to add that to the trigger when it is added
 

Halo_king116

Working As Intended
Reaction score
153
If I understand you, then elmstfreddie's trigger should work. It makes absoloutly perfect sense that it would.

UNLESS, the unit it is approaching has the ability that makes in unselectable. You know, the one so no one can click on it, yet it's still there? (Locust?) Anyways... Yea, it should work.


Other than that I am not sure. It should be simple I would think.


Have a good one.
 

Icyculyr

I'm a Mac
Reaction score
68
I think he wants any footman to blow up that come near it, not a specific one.

My code works, I just need to see what he has done with it.

So once again, master maste, please post what you did with my code.
 

master maste

New Member
Reaction score
32
waaaaagh what does the n000 get replaced with?

edit: I would prefer jass as I'm using jass, and the footman has locust, and is not allow to explode if another footman comes within range.

edit2: I edited waaaagh's trigger wrong by changing the two fields to ones they shouldnt and it crashed my map, and I had to go to a backup :p
 

Icyculyr

I'm a Mac
Reaction score
68
I do not think 'n000' is replaced with anything

it is a unit type id, I think he meant it to stay that way.

And are you going to post that code? I can not you if you do not do it, but who cares anyway.

Cheers
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
The raw value of your mine unit. If you don't know what that is, find the unit in the object editor, then press Ctrl+D. You will get a string 4 digits long. Put that, in " ' "s (apostrophes) in place of n000

More literally, the MineId (just like the function name says :p)
 

master maste

New Member
Reaction score
32
ok so I get this right, what two fields do I change.
because I have had WE crash 2 times now while saving because of that.

This is what I'm writing in:

JASS:
function CreateMine_MineId takes nothing returns integer
    return 'h009'
endfunction

function CreateMine_DetonationRange takes nothing returns real
    return 300.
endfunction

function CreateMine_Detonate takes nothing returns boolean
    local unit footy=GetTriggerUnit()
    if(GetUnitTypeId(footy)=='h009')then
        call SetUnitExploded(footy,true)
        call KillUnit(footy)
    endif
    set footy=null
    return false
endfunction

function CreateMine takes nothing returns boolean
    local unit mine=GetEnteringUnit()
    if(GetUnitTypeId(mine)==CreateMine_MineId())then
        call TriggerRegisterUnitInRange(CreateTrigger(),mine,CreateMine_DetonationRange,Condition(function CreateMine_Detonate))
    endif
    set mine=null
    return false
endfunction

//========================================================================================================
function InitTrig_CreateMine takes nothing returns nothing
    call TriggerRegisterEnterRegion(CreateTrigger(),GetPlayableMapRect(),Condition(function CreateMine))
endfunction


h009 is teh number after my custom unit (if you press Ctrl D)
 

Icyculyr

I'm a Mac
Reaction score
68
And umm

Waaaaagh, why are you using functions that return booleans instead of nothing, I am not sure that will work for adding the trigger

I have never tried, so it might, but it looks like your using a function to execute code, which your returning false, so you can use that function as a condition to create a new trigger..

Not sure if that made sense, and also

Master Maste, make sure your unit ID is exactly as it is,

If not use my code and convert it to jass:p
 

Waaaaagh

I lost all my rep and my title being a jerk
Reaction score
70
I use conditions instead of actions because conditions are faster. Both conditions and actions run when a trigger fires, conditions just need a boolean. Therefore, I simply always return false, so that I get an action in a condition. (Oh, and conditions don't leak) The function is called Condition(). It is used to convert a regular piece of code into a boolexpr. That boolexpr is what makes it faster, I think.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top