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

[General] One trigger to give multiple creatures unique items on spawning?

Status
Not open for further replies.
Level 2
Joined
Nov 17, 2016
Messages
9
So, I have an issue with a map I am making. In short, it's a map where you collect the souls of creatures and can use them for various purposes. When a creature is created, it spawns with an item (i.e. Ghoul Soul) and you can kill it to acquire its soul. However, the issue with this is that every creature has its own unique item it's supposed to spawn with and I don't want to have to create a trigger for every single creature or to use a massive string of If/Then/Else comparisons. What I want is a less convoluted solution.

My original idea was to use a string check to create the item (Name of creature+Soul), but that doesn't work without having the items stored somewhere like a hashtable as a point of reference first. Going through and manually adding every item to the hashtable kind of defeats the point of what I wanted to do in the first place.

Is there another method I could use to approach this problem? I'd be grateful for any advice or answers.
 
Level 4
Joined
Aug 15, 2010
Messages
53
Did you try to set an integer for each soul and show them in the multiboard?
For example Monster = Ghoul // Soul = Red (integer = Soul [1])

Sorry, my English is not very good. I may not have understood exactly what you want to tell. I did a translation of what you wrote using Google Translate.

If you think I understand correctly, I can prepare a sample map for this.
 
Level 25
Joined
May 11, 2007
Messages
4,651
  • Create item for unit
    • Events
      • Unit - A unit enters (Entire map)
    • Conditions
      • (Point-value of (Triggering unit)) Not equal to 100
      • Or - Any (Conditions) are true
        • Conditions
          • (Level of Inventory (Hero) for (Triggering unit)) Equal to 1
          • (Level of Unit Inventory (Human) for (Triggering unit)) Equal to 1
          • (Level of Unit Inventory (Orc) for (Triggering unit)) Equal to 1
          • (Level of Unit Inventory (Undead) for (Triggering unit)) Equal to 1
          • (Level of Unit Inventory (Night Elf) for (Triggering unit)) Equal to 1
    • Actions
      • -------- 100 is the default value, so we don't check units that have that --------
      • -------- We check that the unit has an inventory, that way we also don't add items to buildings, etc --------
      • Set tempInt = (Point-value of (Triggering unit))
      • -------- Set item type --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempInt Equal to 1
        • Then - Actions
          • Set equipItem = Healing Salve
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempInt Equal to 2
        • Then - Actions
          • Set equipItem = Ankh of Reincarnation
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • tempInt Equal to 3
        • Then - Actions
          • Set equipItem = Healing Wards
        • Else - Actions
      • Hero - Create equipItem and give it to (Triggering unit)
Change the point value in the object editor of the units that you want to give an item to.
Then copy the if then else and set the correct number to give the item.

This way you can have the same item type for multiple kinds of units. IE Footmen and Ghouls both drop Healing Salves.
Map attached. It won't work for pre-placed units, but I can fix that if you want.

folfol322, practice your english because your reply doesn't have anything to do with the question.
 

Attachments

  • DzEquipItem.w3x
    18.3 KB · Views: 31
Level 2
Joined
Nov 17, 2016
Messages
9
Thank you for the solution, LordDz. Unfortunately, I am already using the point value of units for another trigger. Perhaps I could substitute it with another inconsequential unit stat, like mana initial amount?
 
Level 6
Joined
Aug 28, 2015
Messages
213
You can use now prefixes on unit names.
This is not my original idea I just saw them here at hive and think that could be the way you can go so I changed the idea to fitt your situation:
  • Initilize
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Soul_MaxTypes = 10
      • Set Soul_NamePrefixEndSymbol = >
      • Set Soul_NamePrefixStartSymbol = <
      • -------- My Units have the Prefix Like this: --------
      • -------- <S1>UnitName --------
      • -------- The prefix will be removed in the unit event trigger --------
      • -------- I placed all items in a region to sort it by picking them and use the life of the items --------
      • Item - Pick every item in Soul InitializationRegion <gen> and do (Actions)
        • Loop - Actions
          • Set Soul_ItemsTypeList[(Integer((Current life of (Picked item))))] = (Item-type of (Picked item))
          • -------- Set the max amount of your prefix to be able to check if the prefix is valide --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Integer((Current life of (Picked item)))) Greater than Soul_MaxTypes
            • Then - Actions
              • Set Soul_MaxTypes = (Integer((Current life of (Picked item))))
            • Else - Actions
          • -------- Clear the items from the game so no one can pick them up --------
          • Item - Remove (Picked item)
  • Unit Event
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Set Soul_UnitName = (Name of (Triggering unit))
      • Set Soul_TempPoint = (Position of (Triggering unit))
      • -------- Check if the unit owns a prefix --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Substring(Soul_UnitName, 1, 1)) Equal to Soul_NamePrefixStartSymbol
        • Then - Actions
          • -------- The unit has a prefix so look what position the prefix ends --------
          • -------- to get the length of the prefix and the length of the number --------
          • For each (Integer Soul_Index) from 0 to (Length of Soul_UnitName), do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Substring(Soul_UnitName, Soul_Index, Soul_Index)) Equal to Soul_NamePrefixEndSymbol
                • Then - Actions
                  • -------- The end symbol was found set length to the position --------
                  • -------- so we can calculate the number length and cut out the prefix at the end completly --------
                  • Set Soul_NamePrefixLenght = Soul_Index
                • Else - Actions
        • Else - Actions
      • -------- Set the number of the prefix --------
      • -------- you could also check for the letter in front by substring(Soul_UnitName, 2, 2) to change the type of item --------
      • Set Soul_UnitPrefixInteger = (Integer((Substring(Soul_UnitName, 3, Soul_NamePrefixLenght))))
      • -------- check if the number is valide --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Soul_UnitPrefixInteger Greater than 0
          • Soul_UnitPrefixInteger Less than or equal to Soul_MaxTypes
        • Then - Actions
          • -------- Give the unit its own item type --------
          • Item - Create Soul_ItemsTypeList[Soul_UnitPrefixInteger] at Soul_TempPoint
          • Hero - Give (Last created item) to (Triggering unit)
        • Else - Actions
      • -------- Remove the prefix so you don't see it ingame --------
      • Unit - Set Name of (Triggering unit) to (Substring(Soul_UnitName, (Soul_NamePrefixLenght + 1), (Length of Soul_UnitName)))
      • -------- Remove Leaks --------
      • Custom script: call RemoveLocation(udg_Soul_TempPoint)
      • Custom script: set udg_Soul_TempPoint = null
€: add test map for understanding
 

Attachments

  • Soul Item System.w3x
    21.5 KB · Views: 30
Last edited:
Status
Not open for further replies.
Top