• 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.

[GUI] Respawn Neutral Hostile variations

Status
Not open for further replies.
Level 17
Joined
Nov 13, 2006
Messages
1,814
1. Respawn unit in last position, with same faceing angle than was when he died and same hero level if he is a hero unit

  • Unit dieing
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
    • Actions
      • Custom script: local unit u = GetDyingUnit()
      • Custom script: local integer utype=GetUnitTypeId(u)
      • Custom script: local real ang = GetUnitFacing(u)
      • Custom script: local integer herolv = GetHeroLevel(u)
      • Custom script: local real x = GetUnitX(u)
      • Custom script: local real y = GetUnitY(u)
      • Wait 2.00 seconds
      • Custom script: call RemoveUnit(u)
      • Custom script: set u = CreateUnit(GetTriggerPlayer(),utype,x,y,ang)
      • Custom script: if herolv > 1 then
      • Custom script: call SetHeroLevel(u,herolv,false)
      • Custom script: endif
      • Custom script: set u = null
2. Respawn unit to attached region, so i give example: forest trolls respawn in in forest area (random point) - this also useable if u want make different respawn spot to different unit types

map init
  • Define regions
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Regions[0] = Forest <gen>
      • Set Regions[1] = Mountain <gen>
      • Set Regions[2] = Desert <gen>
      • -------- u can declare here the regions, then check the unit point values in object editor-units --------
  • Unit dieing
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
    • Actions
      • Custom script: local unit u = GetDyingUnit()
      • Custom script: local integer utype=GetUnitTypeId(u)
      • Custom script: local real ang = GetUnitFacing(u)
      • Custom script: local integer pv = GetUnitPointValueByType(utype)
      • Custom script: local integer herolv = GetHeroLevel(u)
      • Custom script: local real x = GetRandomReal(GetRectMinX(udg_Regions[pv]), GetRectMaxX(udg_Regions[pv]))
      • Custom script: local real y = GetRandomReal(GetRectMinY(udg_Regions[pv]), GetRectMaxY(udg_Regions[pv]))
      • Wait 2.00 seconds
      • Custom script: call RemoveUnit(u)
      • Custom script: set u = CreateUnit(GetTriggerPlayer(),utype,x,y,ang)
      • Custom script: if herolv > 1 then
      • Custom script: call SetHeroLevel(u,herolv,false)
      • Custom script: endif
      • Custom script: set u = null
3. Respawn unit to starting position (where unit was in begining the game) with arrays

Requiment the unit indexer
  • Set the unit coordinate
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Custom script: local unit u = udg_UDexUnits[udg_UDex]
      • Custom script: set udg_CreepX[udg_UDex]=GetUnitX(u)
      • Custom script: set udg_CreepY[udg_UDex]=GetUnitY(u)
      • Custom script: set udg_CreepAng[udg_UDex] = GetUnitFacing(u)
      • Custom script: set u = null
  • Respawn
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
    • Actions
      • Custom script: local unit u = GetDyingUnit()
      • Custom script: local integer id = GetUnitTypeId(u)
      • Custom script: local integer lv = GetHeroLevel(u)
      • Custom script: local integer cv = GetUnitUserData(u)
      • Wait 5.00 seconds
      • Custom script: call RemoveUnit( u )
      • Custom script: set u = CreateUnit(GetTriggerPlayer(),id,udg_CreepX[cv],udg_CreepY[cv],udg_CreepAng[cv])
      • Custom script: if lv > 1 then
      • Custom script: call SetHeroLevel(u,lv,false)
      • Custom script: endif
      • Custom script: set u = null
4. Respawn unit to starting position (where unit was in begining the game) with hashtable

Requiment the unit indexer
map init
  • Mapinit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_CreepTable = InitHashtable()
  • Set the unit coordinate
    • Events
      • Game - UnitIndexEvent becomes Equal to 1.00
    • Conditions
    • Actions
      • Custom script: local unit u = udg_UDexUnits[udg_UDex]
      • Custom script: call SaveReal(udg_CreepTable, udg_UDex, 1, GetUnitX(u))
      • Custom script: call SaveReal(udg_CreepTable, udg_UDex, 2, GetUnitY(u))
      • Custom script: call SaveReal(udg_CreepTable, udg_UDex, 3, GetUnitFacing(u))
      • Custom script: set u = null
  • Respawn
    • Events
      • Unit - A unit owned by Neutral Hostile Dies
    • Conditions
    • Actions
      • Custom script: local unit u = GetDyingUnit()
      • Custom script: local integer id = GetUnitTypeId(u)
      • Custom script: local integer lv = GetHeroLevel(u)
      • Custom script: local integer cv = GetUnitUserData(u)
      • Custom script: local real x = LoadReal(udg_CreepTable, cv, 1)
      • Custom script: local real y = LoadReal(udg_CreepTable, cv, 2)
      • Custom script: local real ang = LoadReal(udg_CreepTable, cv, 3)
      • Wait 5.00 seconds
      • Custom script: call RemoveUnit( u )
      • Custom script: set u = CreateUnit(GetTriggerPlayer(),id,x,y,ang)
      • Custom script: if lv > 1 then
      • Custom script: call SetHeroLevel(u,lv,false)
      • Custom script: endif
      • Custom script: set u = null
 

Attachments

  • Respawn_LastPosition.w3x
    22.4 KB · Views: 158
  • Respawn_Region.w3x
    23.1 KB · Views: 150
  • Respawn_StartPosition.w3x
    21.8 KB · Views: 318
  • Respawn_StartPositionWithHashtable.w3x
    21.8 KB · Views: 211
Status
Not open for further replies.
Top