• 🏆 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!

Help with Spawns

Status
Not open for further replies.
Level 4
Joined
Dec 28, 2008
Messages
58
Hi guys.I'm working on a spawn based map and i need some help with the spanws...I want this to happen...I train a unit at a building,the unit dissapears when finnish training,the unit is added to the spawn and every 1 min the spawn takes place at the rigion i choose.
Then i also want to have a trigger to remove the unit from the spawn,and place an other unit.Thanks....Your help will be greatly appriciated

If it is not in my abilities to make this then im gonna ask somebody to make this for me
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Here's how to spawn as many units of type as you have trained:

  • Untitled Trigger 077
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Trained unit)) Equal to Footman
        • Then - Actions
          • Set Temp_Integer_1 = (Temp_Integer_1 + 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to Rifleman
            • Then - Actions
              • Set Temp_Integer_2 = (Temp_Integer_2 + 1)
            • Else - Actions
      • Unit - Remove (Trained unit) from the game
  • Untitled Trigger 078
    • Events
      • Time - Every 10.00 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Loc_1 = (Center of Region 003 <gen>)
      • Set Temp_Loc_2 = (Center of Region 005 <gen>)
      • Unit - Create Temp_Integer_1 Footman for Player 1 (Red) at Temp_Loc_1 facing Default building facing degrees
      • Unit - Create Temp_Integer_2 Rifleman for Player 1 (Red) at Temp_Loc_2 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_Temp_Loc_1)
      • Custom script: call RemoveLocation(udg_Temp_Loc_2)
You could create a separate trigger for every unit type, and when you want to replace unit type with another you can turn off the old unit's trigger and turn on the new unit's trigger. Or you can use unit-type variable, save the unit type of units to be spawned there. If you need to make this MPI, then use:

  • Set Temp_Integer_1[(Player number of (Owner of (Trained unit)))] = (Temp_Integer_1[(Player number of (Owner of (Trained unit)))] + 1)
Make the variable an array. Then loop through it when creating units.
 
Level 4
Joined
Dec 28, 2008
Messages
58
Thank U your help is greatly appriciate :)

{EDIT}
What about

Set Temp_Loc_1 = (Center of Region 003 <gen>)
Set Temp_Loc_2 = (Center of Region 005 <gen>)

Im sorry but variables and cinematics are my weakness in editor
 
Last edited by a moderator:
Level 4
Joined
Dec 28, 2008
Messages
58
When i try to test the map makes an error and shows me that the seccond trigger was been disabled due errors

function Trig_Test2_Actions takes nothing returns nothing
call RemoveLocation(udg_Temp_Loc_2)
call RemoveLocation(udg_Temp_Loc_1)
call CreateNUnitsAtLoc( udg_Temp_Interger_2, 'n000', Player(0), udg_temp_lock_2, bj_UNIT_FACING )
call CreateNUnitsAtLoc( udg_Temp_Interger_1, 'h000', Player(0), udg_temp_lock_1, bj_UNIT_FACING )
set udg_temp_lock_1 = GetRectCenter(gg_rct_Region_000)
set udg_temp_lock_2 = GetRectCenter(gg_rct_Region_000)
endfunction

//===========================================================================
function InitTrig_Test2 takes nothing returns nothing
set gg_trg_Test2 = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Test2, 10.00 )
call TriggerAddAction( gg_trg_Test2, function Trig_Test2_Actions )
endfunction

//===========================================================================
function InitCustomTriggers takes nothing returns nothing
call InitTrig_Test1( )
call InitTrig_Test2( )
endfunction

//***************************************************************************
//*
//* Players
//*
//***************************************************************************

function InitCustomPlayerSlots takes nothing returns nothing

// Player 0
call SetPlayerStartLocation( Player(0), 0 )
call SetPlayerColor( Player(0), ConvertPlayerColor(0) )
call SetPlayerRacePreference( Player(0), RACE_PREF_HUMAN )
call SetPlayerRaceSelectable( Player(0), true )
call SetPlayerController( Player(0), MAP_CONTROL_USER )

endfunction

function InitCustomTeams takes nothing returns nothing
// Force: TRIGSTR_006
call SetPlayerTeam( Player(0), 0 )

endfunction

//***************************************************************************
//*
//* Main Initialization
//*
//***************************************************************************

//===========================================================================
function main takes nothing returns nothing
call SetCameraBounds( -15744.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -15360.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 15360.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 14848.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -15744.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 14848.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 15360.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -15360.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
call SetDayNightModels( "Environment\\DNC\\DNCAshenvale\\DNCAshenvaleTerrain\\DNCAshenvaleTerrain.mdl", "Environment\\DNC\\DNCAshenvale\\DNCAshenvaleUnit\\DNCAshenvaleUnit.mdl" )
call NewSoundEnvironment( "Default" )
call SetAmbientDaySound( "AshenvaleDay" )
call SetAmbientNightSound( "AshenvaleNight" )
call SetMapMusic( "Music", true, 0 )
call CreateRegions( )
call CreateAllUnits( )
call InitBlizzard( )
call InitGlobals( )
call InitCustomTriggers( )

endfunction

//***************************************************************************
//*
//* Map Configuration
//*
//***************************************************************************

function config takes nothing returns nothing
call SetMapName( "TRIGSTR_001" )
call SetMapDescription( "TRIGSTR_003" )
call SetPlayers( 1 )
call SetTeams( 1 )
call SetGamePlacement( MAP_PLACEMENT_USE_MAP_SETTINGS )

call DefineStartLocation( 0, 12160.0, 16128.0 )

// Player setup
call InitCustomPlayerSlots( )
call SetPlayerSlotAvailable( Player(0), MAP_CONTROL_USER )
call InitGenericPlayerSlots( )
endfunction
 
Status
Not open for further replies.
Top