• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Help with items inside building

Status
Not open for further replies.
Level 8
Joined
Jun 11, 2018
Messages
102
Hello! So I have this problem that I just can't solve. I have searched and I have tried different things but nothing works.

My goal is that every time an item of a specific type is placed withing a building, it adds 10 gold to a periodic income for the player that owns the building.

Item: Skull
Building: Altar

There are two possible way to do this:

1) There is currently a periodic timer that shows when the players receive gold. Each skull can add 10 gold to the total amount of gold received whenever the timer finishes (every 120 seconds). So if the player has 4 skulls inside his altar, he'll get an additional 40 gold each time the timer finishes. Likewise, if a skull is taken out of the altar it has to subtract 10 gold from the total income.

2) The 10 gold generated per skull inside a temple can be unrelated to the timer. Preferably each skull shows a yellow "10" over the temple for every 120 seconds the skull has been inside the altar, or all the skulls inside the altar add to a total that is shown above the altar (If 6 skulls is inside the altar, "60" is shown in yellow above). When a skull is taken out of the altar it subtracts 10 gold in either way.

I hope you can understand what I write. :)
 
Level 5
Joined
Jun 13, 2017
Messages
83
What is max skull you want the building to hold?
1-if 6, then just make a unit, change the model to building and give it inventory.

Make an integer variable(numberofskulls) that increase by 1 each time you put skull, and another integer variable(income) to calculate 10xnumberofskulls
and make the owner to get integer variable (income).
Make a floating text to show above the building with integer variable (income). set it in variable so each time you remove it before changing it to new income then add the new text to variable

When a skull is taken from the building set integer variable (Numberofskulls) =same integervariable - 1

2-if you want the max to be more than 6 then make a unit with the ability to sell, and give it the option to sell the skull item so you can buy it back from the building. set it in variable so each time you remove it before changing it to new income then add the new text to variable

same as above
Make an integer variable(numberofskulls) that increase by 1 each time you sell skull to building, and another integer variable(income) to calculate 10xnumberofskulls
and make the owner to get integer variable (income).
Make a floating text to show above the building with integer variable (income).

make a condition
if, integer variable(numberofskulls) greater than 0 (this way they cant buy skulls if the number is 0)
then, each time you buy skull from the building set integer variable (Numberofskulls) =same integervariable - 1w
 
Level 8
Joined
Jun 11, 2018
Messages
102
Alright, I still can't figure out this trigger. Yes, 6 skulls max as the altar has 6 inventory slots.

It has to identify which player the altar belongs to.
It has to identify that it is a skull and not something else that is put in.
It has to identify that it is an altar that acquires the skull.
A player can build more altars.

This trigger is way too advanced for me to figure out.
 
Last edited:
Level 5
Joined
Jun 13, 2017
Messages
83
well you can do it in the second way above make each altar increase the maximum amount by 6 and every time you sell skull it let integervariable increase by 1 so you can keep tracking the amount of skulls, and when buying them set integervariable - 1

To identify that it is a skull and if the altar has skulls. Using the method above integer only increase when the item is skull and sold to altar

Make it so max number of skulls = 6 if player tried to sell more and has only 1 altar, do nothing and return the skull. If player have to altars they can sell to maximum of 12 skull.

To identify the player just make an array and use player number for the array.
 
Level 8
Joined
Jun 11, 2018
Messages
102
I'm still stuck :(

PHP:
SkullGoldGeneration
    Events
        Map initialization
    Conditions
    Actions
        Set NumberOfSkulls = 0
        Unit Group - Pick every unit in (Units of type Altar of Storms) and do (Actions)
            Loop - Actions
                If ((Item-type of (Item carried by (Picked unit) in slot (Integer A))) Equal to Hero's Head) then do (Set NumberOfSkulls = NumberOfSkulls) else do (Do nothing)
 
Level 23
Joined
Oct 18, 2008
Messages
937
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
      • Set tempint = 0
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Item-type of (Item carried by (Picked unit) in slot (Integer A))) Equal to Tome of Experience
            • Then - Actions
              • Set tempint = (tempint + 1)
            • Else - Actions
      • Game - Display to (All players) the text: (picked unit has + ((String(tempint)) + of item))
 
Level 5
Joined
Jun 13, 2017
Messages
83
Make a variable for each playing player.
  • Player Variables
    • Events
      • Time - Elapsed game time is 2.00 seconds
    • Conditions
    • Actions
      • Set Skull_PlayerGroup = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
      • Player Group - Pick every player in Skull_PlayerGroup and do (Actions)
        • Loop - Actions
          • Set Skull_Index = (Skull_Index + 1)
          • Set Skull_Player[Skull_Index] = (Picked player)

Remove leavers from player group, you need to add all player colors to event I only added red and blue
  • Player Leave
    • Events
      • Player - Player 1 (Red) leaves the game
      • Player - Player 2 (Blue) leaves the game
    • Conditions
    • Actions
      • Player Group - Remove (Triggering player) from Skull_PlayerGroup

This is for when acquiring skull, just change the unit and item condition to your item and unit.
  • Acquires skull
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
      • (Item-type of (Item being manipulated)) Equal to
    • Actions
      • Set Skull_Count[(Player number of (Owner of (Triggering unit)))] = (Skull_Count[(Player number of (Owner of (Triggering unit)))] + 1)

This is for when loses skull, again change unit and item condition.
  • Loses Skull
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Footman
      • (Item-type of (Item being manipulated)) Equal to Tome of Experience
    • Actions
      • Set Skull_Count[(Player number of (Owner of (Triggering unit)))] = (Skull_Count[(Player number of (Owner of (Triggering unit)))] - 1)

This is for the income, change the time to whatever you want and in Skull_Income variable I set it to x10, you can change it to whatever you want.
Skull_Count is the number of skulls in all your altars
  • Income
    • Events
      • Time - Every 120.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Skull_Loop) from 1 to Skull_Index, do (Actions)
        • Loop - Actions
          • Set Skull_Income = Skull_Count[(Skull_Count[(Player number of Skull_Player[Skull_Loop])] x 10)]
          • Player - Add Skull_Income to Skull_Player[Skull_Loop] Current gold
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Skull_Player[Skull_Loop] is in Skull_PlayerGroup) Equal to False
            • Then - Actions
              • Set Skull_Player[Skull_Loop] = Skull_Player[Skull_Index]
              • Set Skull_Index = (Skull_Index - 1)
            • Else - Actions


Here is a map with the triggers, check it and tell me if anything is missing.
 

Attachments

  • Skull Income.w3x
    18.8 KB · Views: 36
Status
Not open for further replies.
Top