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

Backpack

Status
Not open for further replies.
Level 14
Joined
Dec 29, 2009
Messages
931
Okie so I have this trigger and it does this thing...
Lol, it moves the backpack to the player's hero every 0.03 seconds so it appears as if the hero is carrying the backpack.
You've all seen this before.

But it feels to simple.. I have to be missing something, and I can't think straight right now.

  • Backpack 01
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set BackPack_TempInt = 1
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (gen_PlayerHero[BackPack_TempInt] is alive) Equal to True
        • Then - Actions
          • Set BackPack_TempLoc = (Position of gen_PlayerHero[BackPack_TempInt])
          • Unit - Move (Triggering unit) instantly to BackPack_TempLoc
          • Custom script: call RemoveLocation(udg_BackPack_TempLoc)
        • Else - Actions
          • Trigger - Turn off (This trigger)
There will be 8 copies of this trigger, each one being exactly the same except the BackPack_TempInt.
It will be a number between 1 and 8, for each trigger respectively, representing the player number.
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
There's no need to copy trigger 8 times, instead, you could add backpacks to a unit group and iterate group with a 0.03 period. When a backpack owner dies, remember to remove backpack as well.
Also, you forgot to replace triggering unit there.

What also might be good is to use SetUnitX/Y functions for moving backpack as these don't interrupt orders so you'll be able to issue backpack to give items to owner during movement or such.

It would look something like this:
  • BackpackAssignment
    • Event
      • whoknowswhat
    • Actions
      • Create backpack
      • add backpack to BackpackGroup
      • set backpacks[player id of owner] = created backpack
  • Backpack
  • Events
    • Every 0.03 seconds of game time
  • Actions
    • Unit group - pick every unit in BackpackGroup and do
      • Custom script: call SetUnitX(GetEnumUnit(), GetUnitX(udg_gen_PlayerHero[GetPlayerId(GetEnumUnit()) + 1]))
      • Custom script: call SetUnitY(GetEnumUnit(), GetUnitY(udg_gen_PlayerHero[GetPlayerId(GetEnumUnit()) + 1]))
  • Backpack removal
    • Events
      • Unit dies
    • Conditions
      • Triggering unit has backpack //Do some check here
    • Actions
      • Remove Backpacks[GetPlayerId(GetTriggerUnit())] from BackpackGroup
      • Remove unit Backpacks[GetPlayerId(GetTriggerUnit())]
 
Level 14
Joined
Dec 29, 2009
Messages
931
For the SetUnitX/Y wouldn't you use the variable for the backpack unit, not the player hero for the first part?

Something like this?

  • BackPacks Test
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer BP_TempInt) from 1 to 8, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (gen_PlayerHero[BP_TempInt] is alive) Equal to True
            • Then - Actions
              • Set BP_TempLoc = (Position of gen_PlayerHero[BP_TempInt])
              • Custom script: call SetUnitX(udg_BP_Unit[udg_BP_TempInt], GetLocationX(udg_BP_TempLoc))
              • Custom script: call SetUnitY(udg_BP_Unit[udg_BP_TempInt], GetLocationY(udg_BP_TempLoc))
              • Custom script: call RemoveLocation(udg_BP_TempLoc)
            • Else - Actions
              • Trigger - Turn off (This trigger)
 
Status
Not open for further replies.
Top