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

[Trigger] Trigger half working

Status
Not open for further replies.
Level 12
Joined
Apr 18, 2007
Messages
1,130
I'm having some trouble with a build system that builds a building from items put on the ground with a "build" ability used on them. I've gotten the build itself to work and all that, but there's one last thing I need that I can't seem to get to work. I want it so that if the building does not build due to say, a wall being in the way, I want it to give the items back. RemakeUnused was there before I wanted it to return items. It was originally there so that if the recipe was incorrect and didn't match a building, it gave the items back. Here's my system.

CreateStructures
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Construct (this one)
  • Actions
    • Set BuildOK = False
    • Set tempPoint[1] = (Target point of ability being cast)
    • Trigger - Run CountItems <gen> (ignoring conditions)
    • Custom script: call RemoveLocation(udg_tempPoint[1])
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Unit-type of (Triggering unit)) Equal to Trade Prince
    • Then - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • WoodAmount Equal to 6
          • StoneAmount Equal to 4
          • SteelBarCount Equal to 4
          • ScrewsCount Equal to 2
          • SkinCount Equal to 2
          • CopperOreCount Equal to 4
          • ItemAmount Equal to 22
        • Then - Actions
          • Trigger - Run BuildingCountBefore <gen> (checking conditions)
          • Set BuildOK = True
          • Set tempPoint[0] = (Target point of ability being cast)
          • Unit - Create 1 Acolyte Dummy for (Owner of (Triggering unit)) at tempPoint[0] facing Default building facing degrees
          • Unit - Add a 61.00 second Generic expiration timer to (Last created unit)
          • Unit - Order (Last created unit) to build a Trading Post at tempPoint[0]
          • Trigger - Run BuildingCountAfter <gen> (checking conditions)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BuildingCountAfter Greater than BuildingCountBefore
            • Then - Actions
              • Trigger - Run RemakeUnused <gen> (ignoring conditions)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_tempPoint[0])
        • Else - Actions
    • Else - Actions
CountItems
  • Events
  • Conditions
  • Actions
    • Set ItemAmount = 0
    • Set RopeCount = 0 [PLEASE NOTE: I have only included these two. It does the SET functions for every item in the game, swapping Rope with the item name. Just look at the next function for all the items...]
    • Item - Pick every item in (Region centered at tempPoint[1] with size (250.00, 250.00)) and do (Actions)
    • Loop - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Rope
        • Then - Actions
          • Set RopeCount = (RopeCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Gold Bolts
        • Then - Actions
          • Set GoldBoltCount = (GoldBoltCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Silver Nuts
        • Then - Actions
          • Set SilverNutCount = (SilverNutCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Black Gunpowder
        • Then - Actions
          • Set BlackpowderCount = (BlackpowderCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Cogs
        • Then - Actions
          • Set CogsCount = (CogsCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Copper Bar
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set CopperBarCount = (CopperBarCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Copper Ore
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set CopperOreCount = (CopperOreCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Gears
        • Then - Actions
          • Set GearsCount = (GearsCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Gold Bar
        • Then - Actions
          • Set GoldBarCount = (GoldBarCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Gold Ore
        • Then - Actions
          • Set GoldOreCount = (GoldOreCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Gold Wire
        • Then - Actions
          • Set GoldWireCount = (GoldWireCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Gunpowder
        • Then - Actions
          • Set GunpowderCount = (GunpowderCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Hot Coal
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set HotCoalCount = (HotCoalCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Iron Ore
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set IronOreCount = (IronOreCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Ironwood Branch
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set IronwoodCount = (IronwoodCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Mithryl Bar
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set MithrylBarCount = (MithrylBarCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Mithryl Ore
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set MithrylOreCount = (MithrylOreCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Ashenvale Grass
        • Then - Actions
          • Set PlantAshenGrassCount = (PlantAshenGrassCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Ashenvale Shrub
        • Then - Actions
          • Set PlantAshenShrubCount = (PlantAshenShrubCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Barren Grass
        • Then - Actions
          • Set PlantBarrenGrassCount = (PlantBarrenGrassCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Barren Shrub
        • Then - Actions
          • Set PlantBarrenShurbCount = (PlantBarrenShurbCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Leaves
        • Then - Actions
          • Set PlantLeavesCount = (PlantLeavesCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Vines
        • Then - Actions
          • Set PlantVinesCount = (PlantVinesCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Violet Flower
        • Then - Actions
          • Set PlantVioletFlowerCount = (PlantVioletFlowerCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Yellow Flower
        • Then - Actions
          • Set PlantYellowFlowerCount = (PlantYellowFlowerCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Screws
        • Then - Actions
          • Set ScrewsCount = (ScrewsCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Silver Bar
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set SilverBarCount = (SilverBarCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Silver Ore
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set SilverOreCount = (SilverOreCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Skin
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set SkinCount = (SkinCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Springs
        • Then - Actions
          • Set SpringsCount = (SpringsCount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Steel Bar
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set SteelBarCount = (SteelBarCount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Stone
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set StoneAmount = (StoneAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Trinitrotuelene (TNT)
        • Then - Actions
          • Set TNTcount = (TNTcount + 1)
          • Set ItemAmount = (ItemAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Item-type of (Picked item)) Equal to Lumber
        • Then - Actions
          • Set ItemAmount = (ItemAmount + 1)
          • Set WoodAmount = (WoodAmount + 1)
          • Item - Remove (Picked item)
        • Else - Actions
RemakeUnused [Just as the trigger before, for pure simplicity I've chopped the Actions to just one item. It DOES happen for each item, however.
  • Events
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • RopeCount Greater than or equal to 1
      • Then - Actions
        • For each (Integer A) from 1 to RopeCount, do (Actions)
          • Loop - Actions
            • Item - Create Rope at tempPoint[0]
      • Else - Actions
BuildingCountBefore
  • Events
  • Conditions
  • Actions
    • Set BuildingCountBefore = 0
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked unit) is A structure) Equal to True
          • Then - Actions
            • Set BuildingCountBefore = (BuildingCountBefore + 1)
          • Else - Actions
BuildingCountAfter
  • Events
  • Conditions
  • Actions
    • Set BuildingCountAfter = 0
    • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Picked unit) is A structure) Equal to True
          • Then - Actions
            • Set BuildingCountAfter = (BuildingCountAfter + 1)
          • Else - Actions
 
Level 12
Joined
Apr 18, 2007
Messages
1,130
Wait, seriously? That makes this all a whole lot easier... Thanks.
Except that all my buildings are different sizes, so how would I do it then? I don't want to have to have a huge area to make a small building, nor a small area to make a large building. I would have to detect each separately, THEN run CountItems and it'll be a mess. Unless I can get RemakeUnused to work.

I just think it'll be easier for it to detect. Is there any other way I can make it a working detection system?
I can also just have it remake all the items manually... But that'll take forever to script.
 
Status
Not open for further replies.
Top