[Solved] Making Spawned Destructible Drop Loot on Death

Status
Not open for further replies.
Level 5
Joined
Jan 19, 2018
Messages
126
Hello hive!
I am working on a simple system that spawns a destructible like crates and barrels in designated regions on the map. These barrels have a chance to drop some loot on death, my problem is getting them to drop loot on death, since they are spawned randomly in game I cannot use standard item tables. I created some triggers to handle the issue but it is not working. The trigger that makes the barrels have a chance to spawn in designated regions works, but when I destroy the crates/barrels nothing drops even though I set the chance in my trigger to 100% for testing purposes. I even made the game echo "worked" when the destructible dies but it doesn't echo.
Here are the triggers that make up my system:
This trigger sets all possible spawn zones for the loot crates. (works)
  • Loot Crate Zone Initialization
    • Events
    • Conditions
    • Actions
      • Set BonusLootCrateSpawnZone[0] = Loot Crate Spawn Zone 1 <gen>
      • Set BonusLootCrateSpawnZone[1] = Loot Crate Spawn Zone 12 <gen>
      • Set BonusLootCrateSpawnZone[2] = Loot Crate Spawn Zone 13 <gen>
      • Set BonusLootCrateSpawnZone[3] = Loot Crate Spawn Zone 15 <gen>
      • Set BonusLootCrateSpawnZone[4] = Loot Crate Spawn Zone 5 <gen>
      • Set BonusLootCrateSpawnZone[5] = Loot Crate Spawn Zone 8 <gen>
      • Set BonusLootCrateSpawnZone[6] = Loot Crate Spawn Zone 9 <gen>
      • Set BonusLootCrateSpawnZone[7] = Loot Crate Spawn Zone 16 <gen>
      • Set BonusLootCrateSpawnZone[8] = Loot Crate Spawn Zone 14 <gen>
      • Set BonusLootCrateSpawnZone[9] = Loot Crate Spawn Zone 11 <gen>
      • Set BonusLootCrateSpawnZone[10] = Loot Crate Spawn Zone 2 <gen>
      • Set BonusLootCrateSpawnZone[11] = Loot Crate Spawn Zone 3 <gen>
      • Set BonusLootCrateSpawnZone[12] = Loot Crate Spawn Zone 6 <gen>
      • Set BonusLootCrateSpawnZone[13] = Loot Crate Spawn Zone 7 <gen>
      • Set BonusLootCrateSpawnZone[14] = Loot Crate Spawn Zone 10 <gen>
      • Set BonusLootCrateSpawnZone[15] = Loot Crate Spawn Zone 4 <gen>
      • Set BonusLootCrateSpawnZone[16] = Loot Crate Spawn Zone 21 <gen>
      • Set BonusLootCrateSpawnZone[17] = Loot Crate Spawn Zone 20 <gen>
      • Set BonusLootCrateSpawnZone[18] = Loot Crate Spawn Zone 17 <gen>
      • Set BonusLootCrateSpawnZone[19] = Loot Crate Spawn Zone 22 <gen>
      • Set BonusLootCrateSpawnZone[20] = Loot Crate Spawn Zone 19 <gen>
      • Set BonusLootCrateSpawnZone[21] = Loot Crate Spawn Zone 35 <gen>
      • Set BonusLootCrateSpawnZone[22] = Loot Crate Spawn Zone 35 <gen>
      • Set BonusLootCrateSpawnZone[23] = Loot Crate Spawn Zone 37 <gen>
      • Set BonusLootCrateSpawnZone[24] = Loot Crate Spawn Zone 39 <gen>
      • Set BonusLootCrateSpawnZone[25] = Loot Crate Spawn Zone 40 <gen>
      • Set BonusLootCrateSpawnZone[26] = Loot Crate Spawn Zone 38 <gen>
      • Set BonusLootCrateSpawnZone[27] = Loot Crate Spawn Zone 36 <gen>
      • Set BonusLootCrateSpawnZone[28] = Loot Crate Spawn Zone 34 <gen>
      • Set BonusLootCrateSpawnZone[29] = Loot Crate Spawn Zone 33 <gen>
      • Set BonusLootCrateSpawnZone[30] = Loot Crate Spawn Zone 25 <gen>
      • Set BonusLootCrateSpawnZone[31] = Loot Crate Spawn Zone 28 <gen>
      • Set BonusLootCrateSpawnZone[32] = Loot Crate Spawn Zone 27 <gen>
      • Set BonusLootCrateSpawnZone[33] = Loot Crate Spawn Zone 26 <gen>
      • Set BonusLootCrateSpawnZone[34] = Loot Crate Spawn Zone 32 <gen>
      • Set BonusLootCrateSpawnZone[35] = Loot Crate Spawn Zone 31 <gen>
      • Set BonusLootCrateSpawnZone[36] = Loot Crate Spawn Zone 23 <gen>
      • Set BonusLootCrateSpawnZone[37] = Loot Crate Spawn Zone 30 <gen>
      • Set BonusLootCrateSpawnZone[38] = Loot Crate Spawn Zone 29 <gen>
      • Set BonusLootCrateSpawnZone[39] = Loot Crate Spawn Zone 24 <gen>
This trigger loops through all possible spawns zones and gives a 25% chance to spawn a destructible (works).
  • Loot Crate Spawn Initialization
    • Events
    • Conditions
    • Actions
      • Set LootCrateType[0] = Barrel
      • Set LootCrateType[1] = Barrel
      • Set LootCrateType[2] = Barrel
      • Set LootCrateType[3] = Crates
      • Set LootCrateType[4] = Crates
      • Set LootCrateType[5] = Crates
      • Set LootZoneCounter = 0
      • For each (Integer A) from 1 to 40, do (Actions)
        • Loop - Actions
          • Set LootCrateSpawnChance = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LootCrateSpawnChance Less than or equal to 25
            • Then - Actions
              • Destructible - Create a LootCrateType[(Random integer number between 0 and 5)] at (Random point in BonusLootCrateSpawnZone[LootZoneCounter]) facing (Random angle) with scale 1.00 and variation 0
              • Set LootZoneCounter = (LootZoneCounter + 1)
            • Else - Actions
              • Set LootZoneCounter = (LootZoneCounter + 1)
This trigger handles what drops from the crate, right now set to 100% for testing purposes (Doesn't work).
  • Loot Crate Drops
    • Events
      • Destructible - A destructible within Loot Crate Spawn Zone 1 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 2 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 3 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 4 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 5 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 6 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 7 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 8 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 9 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 10 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 11 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 12 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 13 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 14 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 15 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 16 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 17 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 18 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 19 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 20 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 21 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 22 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 23 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 24 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 25 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 26 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 27 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 28 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 29 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 30 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 31 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 32 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 33 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 34 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 35 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 36 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 37 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 38 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 39 <gen> dies
      • Destructible - A destructible within Loot Crate Spawn Zone 40 <gen> dies
    • Conditions
    • Actions
      • Set LootChance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (LootChance Greater than or equal to 1) and (LootChance Less than or equal to 100)
        • Then - Actions
          • Game - Display to (All players) the text: worked
          • Set LootTypeRoll = (Random integer number between 1 and 6)
          • If (LootTypeRoll Equal to 1) then do (Item - Create LowGradeConsumableItem[(Random integer number between 0 and LGC_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 2) then do (Item - Create LowGradeConsumableItem[(Random integer number between 0 and LGC_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 3) then do (Item - Create LowGradePowerUp[(Random integer number between 0 and LGPU_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 4) then do (Item - Create LowGradePowerUp[(Random integer number between 0 and LGPU_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 5) then do (Item - Create MidGradeConsumableItem[(Random integer number between 0 and MGC_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 6) then do (Item - Create MidGradePowerUp[(Random integer number between 0 and MGPU_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
        • Else - Actions
Thanks in advance!
 
Level 12
Joined
Jan 25, 2017
Messages
213
You need to register the destructible death in the trigger after they are created not before-

So I'd go and delete all the events for 'Loot Crate Drops' and add this to the Loot Crate Spawn Init loop after creating the destructible
  • Trigger - Add to myTrigger the event (Destructible - (Last created destructible) dies)
Edit: you could also loop through all the regions, pick all destructibles, and add them to the trigger in that way but the way I did it is simpler and less overhead.
 
Level 5
Joined
Jan 19, 2018
Messages
126
Hello and thank you for responding to my thread!
Didn't work =[
Here are the updated triggers:
  • Loot Crate Spawn Initialization
    • Events
    • Conditions
    • Actions
      • Set LootCrateType[0] = Barrel
      • Set LootCrateType[1] = Barrel
      • Set LootCrateType[2] = Barrel
      • Set LootCrateType[3] = Crates
      • Set LootCrateType[4] = Crates
      • Set LootCrateType[5] = Crates
      • Set LootZoneCounter = 0
      • For each (Integer A) from 1 to 40, do (Actions)
        • Loop - Actions
          • Set LootCrateSpawnChance = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LootCrateSpawnChance Less than or equal to 25
            • Then - Actions
              • Destructible - Create a LootCrateType[(Random integer number between 0 and 5)] at (Random point in BonusLootCrateSpawnZone[LootZoneCounter]) facing (Random angle) with scale 1.00 and variation 0
              • Trigger - Add to Loot Crate Drops <gen> the event (Destructible - A destructible within BonusLootCrateSpawnZone[LootZoneCounter] dies)
              • Set LootZoneCounter = (LootZoneCounter + 1)
            • Else - Actions
              • Set LootZoneCounter = (LootZoneCounter + 1)
  • Loot Crate Drops
    • Events
    • Conditions
    • Actions
      • Set LootChance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (LootChance Greater than or equal to 1) and (LootChance Less than or equal to 100)
        • Then - Actions
          • Game - Display to (All players) the text: worked
          • Set LootTypeRoll = (Random integer number between 1 and 6)
          • If (LootTypeRoll Equal to 1) then do (Item - Create LowGradeConsumableItem[(Random integer number between 0 and LGC_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 2) then do (Item - Create LowGradeConsumableItem[(Random integer number between 0 and LGC_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 3) then do (Item - Create LowGradePowerUp[(Random integer number between 0 and LGPU_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 4) then do (Item - Create LowGradePowerUp[(Random integer number between 0 and LGPU_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 5) then do (Item - Create MidGradeConsumableItem[(Random integer number between 0 and MGC_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
          • If (LootTypeRoll Equal to 6) then do (Item - Create MidGradePowerUp[(Random integer number between 0 and MGPU_Highest_Index)] at (Position of (Dying destructible))) else do (Do nothing)
        • Else - Actions
 
Last edited:
Level 11
Joined
May 16, 2016
Messages
730
Hello hive!
I am working on a simple system that spawns a destructible like crates and barrels in designated regions on the map. These barrels have a chance to drop some loot on death, my problem is getting them to drop loot on death, since they are spawned randomly in game I cannot use standard item tables. I created some triggers to handle the issue but it is not working. The trigger that makes the barrels have a chance to spawn in designated regions works, but when I destroy the crates/barrels nothing drops even though I set the chance in my trigger to 100% for testing purposes. I even made the game echo "worked" when the destructible dies but it doesn't echo.
Poor guy. These triggers writing is a huge nerved work. Here is normal system for you without this masoсhism.
 

Attachments

  • Destructible Loot.w3x
    24.8 KB · Views: 67
Level 5
Joined
Jan 19, 2018
Messages
126
Poor guy. These triggers writing is a huge nerved work. Here is normal system for you without this masoсhism.
Hello Fruit Forest and thank you for replying to my thread!
I cannot download the attachment apparently hive gives me an error saying attachment not found.
P.S. That thing in your profile pick is... strangely cute LOL
Edit: Nvm I got it to download.
 
Level 12
Joined
Jan 25, 2017
Messages
213
Haha I looked at your triggers a little more closely and found that you leak a bunch of points. Position of Unit and random point in region for example. Make sure you check the tutorials on how to remove leaks.

But I would use the destructible dies event and not the 'destructible in region dies event' unless you loop through all the regions- which currently you're not doing (just adding all destructibles from BonusLootZone...[0] over and over again). I don't know what you're trying to achieve with the counter- but it's not doing anything for you atm. But if you can get a better system from Fruit Forest that's great too :)
 
Level 5
Joined
Jan 19, 2018
Messages
126
Haha I looked at your triggers a little more closely and found that you leak a bunch of points. Position of Unit and random point in region for example. Make sure you check the tutorials on how to remove leaks.

But I would use the destructible dies event and not the 'destructible in region dies event' unless you loop through all the regions- which currently you're not doing (just adding all destructibles from BonusLootZone...[0] over and over again). I don't know what you're trying to achieve with the counter- but it's not doing anything for you atm. But if you can get a better system from Fruit Forest that's great too :)
Without the counter adding 1 every time all the destructibles would spawn in the same region. The counter just makes the loop move to the next index in the SpawnZone array. As for the leaks I will handle that right now and see if it is the cause.
I am looking at @Fruit Forest's system as well.
 
Level 5
Joined
Jan 19, 2018
Messages
126
The trigger leaks were the problem.
Thank you very much @Alethos and @Fruit Forest!!!
  • Loot Crate Spawn Initialization
    • Events
    • Conditions
    • Actions
      • Set LootCrateType[0] = Barrel
      • Set LootCrateType[1] = Barrel
      • Set LootCrateType[2] = Barrel
      • Set LootCrateType[3] = Crates
      • Set LootCrateType[4] = Crates
      • Set LootCrateType[5] = Crates
      • Set LootZoneCounter = 0
      • For each (Integer A) from 1 to 40, do (Actions)
        • Loop - Actions
          • Set LootCrateSpawnChance = (Random integer number between 1 and 100)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LootCrateSpawnChance Less than or equal to 25
            • Then - Actions
              • Set temp_destructible_region = BonusLootCrateSpawnZone[LootZoneCounter]
              • Destructible - Create a LootCrateType[(Random integer number between 0 and 5)] at (Random point in temp_destructible_region) facing (Random angle) with scale 1.00 and variation 0
              • Trigger - Add to Loot Crate Drops <gen> the event (Destructible - A destructible within BonusLootCrateSpawnZone[LootZoneCounter] dies)
              • Custom script: call RemoveRect(udg_temp_destructible_region) //Region
              • Set LootZoneCounter = (LootZoneCounter + 1)
            • Else - Actions
              • Set LootZoneCounter = (LootZoneCounter + 1)
  • Loot Crate Drops
    • Events
    • Conditions
    • Actions
      • Set LootChance = (Random integer number between 1 and 100)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (LootChance Greater than or equal to 1) and (LootChance Less than or equal to 100)
        • Then - Actions
          • Game - Display to (All players) the text: worked
          • Set LootTypeRoll = (Random integer number between 1 and 6)
          • Set dying_destructible_point = (Position of (Dying destructible))
          • If (LootTypeRoll Equal to 1) then do (Item - Create LowGradeConsumableItem[(Random integer number between 0 and LGC_Highest_Index)] at dying_destructible_point) else do (Do nothing)
          • If (LootTypeRoll Equal to 2) then do (Item - Create LowGradeConsumableItem[(Random integer number between 0 and LGC_Highest_Index)] at dying_destructible_point) else do (Do nothing)
          • If (LootTypeRoll Equal to 3) then do (Item - Create LowGradePowerUp[(Random integer number between 0 and LGPU_Highest_Index)] at dying_destructible_point) else do (Do nothing)
          • If (LootTypeRoll Equal to 4) then do (Item - Create LowGradePowerUp[(Random integer number between 0 and LGPU_Highest_Index)] at dying_destructible_point) else do (Do nothing)
          • If (LootTypeRoll Equal to 5) then do (Item - Create MidGradeConsumableItem[(Random integer number between 0 and MGC_Highest_Index)] at dying_destructible_point) else do (Do nothing)
          • If (LootTypeRoll Equal to 6) then do (Item - Create MidGradePowerUp[(Random integer number between 0 and MGPU_Highest_Index)] at dying_destructible_point) else do (Do nothing)
          • Custom script: call RemoveLocation(udg_dying_destructible_point)
        • Else - Actions
I did like the system you created @Fruit Forest, but it was easier for me to just fix up my triggers, also your system does a couple of things that I don't want. (Multiple destructibles in the same region and destructibles can drop multiple items). In terms of overhead, and efficiency is yours also better than mine or are they about the same?

Thanks again to both of you!
 
Level 11
Joined
May 16, 2016
Messages
730
I did like the system you created @Fruit Forest, but it was easier for me to just fix up my triggers, also your system does a couple of things that I don't want. (Multiple destructibles in the same region and destructibles can drop multiple items).
Actually my system is quite flexible. If you doN'T want multible desrtuctibles you justt need to set all destr types (1..6) as one destr type. (or set majority of it as one type and minority - as second type if you have 2 types).
If you don't want multiple items drop then left only items you want to drop.

EDIT:
is yours also better than mine or are they about the same?
My system removes dead destructibles. Because dead destructibles aren't removed from the game unlike unit coprses.
 
Last edited:
Level 5
Joined
Jan 19, 2018
Messages
126
Actually my system is quite flexible. If you doN'T want multible desrtuctibles you justt need to set all destr types (1..6) as one destr type. (or set majority of it as one type and minority - as second type if you have 2 types).
If you don't want multiple items drop then left only items you want to drop.

EDIT:

My system removes dead destructibles. Because dead destructibles aren't removed from the game unlike unit coprses.
I see, thank you!
 
Status
Not open for further replies.
Top