• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Spawn System w/o Building!

Status
Not open for further replies.
Level 6
Joined
Feb 12, 2008
Messages
207
Ok, I already have a spawn system. But it's not working the way I want to. The system just spawns some units in <Playable Map Area> and they always spawn everywhere, even underwater and in the middle of a cliff! Is there any way to prevent this easily? I didn't tried by automatically moving the unit a little so it comes out of the cliff. Going to try and edit post while I wait for a good answer.

Here is the trigger:
  • Spawn Stag
    • Events
      • Time - Every 15.00 seconds of game time
    • Conditions
      • (Number of living Stag units owned by Neutral Hostile) Less than 100
    • Actions
      • Set AntiLeakPosition = (Random point in (Playable map area))
      • Unit - Create 1 Stag for Neutral Hostile at AntiLeakPosition facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_AntiLeakPosition)
Thanks in advance!
 
Level 11
Joined
Feb 14, 2009
Messages
884
You can use a pathability check function, but that also means you have to use JASS.
 
Level 6
Joined
Mar 20, 2008
Messages
208
IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) and not(IsTerrainPathable(x,y,PATHING_TYPE_AMPHIBIOUSPATHING))

x,y would be the coordinates.


Possibly PATHING_TYPE_BUILDABILITY too to make sure theres no structures in the way of it. But that might be atken care of with the placement.
 
Level 5
Joined
May 3, 2009
Messages
129
well you could put pathing blockers in the places but that would take a long time if your map is huge. thats if you wanted to place the stags fully random or make lots of regions
 
Level 6
Joined
Feb 12, 2008
Messages
207
ok good, my trigger is now converted into JASS and I've been able to stop the spawning in the water. But they keep appearing on the edge of cliffs, so they are unable to move.
Heres the full trigger:

JASS:
function Trig_Spawn_Stag_Conditions takes nothing returns boolean
    if ( not ( CountLivingPlayerUnitsOfTypeId('n000', Player(PLAYER_NEUTRAL_AGGRESSIVE)) < 100 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Spawn_Stag_Actions takes nothing returns nothing
    local location AntiLeakPosition
    set AntiLeakPosition = GetRandomLocInRect(GetPlayableMapRect())
    if (IsTerrainPathableBJ(AntiLeakPosition,PATHING_TYPE_WALKABILITY) == true) and (not(IsTerrainPathableBJ(AntiLeakPosition,PATHING_TYPE_AMPHIBIOUSPATHING) == true)) then 
       call TriggerExecute( GetTriggeringTrigger() )
    else
       call CreateNUnitsAtLoc( 1, 'n000', Player(PLAYER_NEUTRAL_AGGRESSIVE), AntiLeakPosition, bj_UNIT_FACING )
       set AntiLeakPosition = null
       call RemoveLocation(udg_Temp_Point)
    endif
endfunction

//===========================================================================
function InitTrig_Spawn_Stag takes nothing returns nothing
    set gg_trg_Spawn_Stag = CreateTrigger(  )
    call DisableTrigger( gg_trg_Spawn_Stag )
    call TriggerRegisterTimerEventPeriodic( gg_trg_Spawn_Stag, 5.00 )
    call TriggerAddCondition( gg_trg_Spawn_Stag, Condition( function Trig_Spawn_Stag_Conditions ) )
    call TriggerAddAction( gg_trg_Spawn_Stag, function Trig_Spawn_Stag_Actions )
endfunction

Oh and please if any moderator comes to this post. Change it to JASS!
 
Level 6
Joined
Feb 12, 2008
Messages
207
hmm. not going to change. They appear in the middle of the cliffs edges so i dont think it would fix it. Anyway, not spawning on water is an advance.
 
Level 11
Joined
Feb 14, 2009
Messages
884
Well, there's no way to spawn units in areas except those you decide to unless you use multiple regions :/
 
Status
Not open for further replies.
Top