1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  4. The Secrets of Warcraft 3 have revealed interesting works. The RESULTS for Abelhawk's Mini-Mapping Contest #15 have come out!
    Dismiss Notice
  5. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  6. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  7. Night Rider gained several songs for his journey. The poll for the 12th Music Contest has started. Check it out!
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    Dismiss Notice
  9. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  10. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Request] Unique trade system

Discussion in 'Requests' started by Hjorleif, Aug 3, 2019.

  1. Hjorleif

    Hjorleif

    Joined:
    Aug 13, 2009
    Messages:
    321
    Resources:
    0
    Resources:
    0
    Hello,

    I'll start by saying, I'm not sure if this is possible or not but if it is, it could really help me out.

    I'm wondering if someone can make a trade system similar to Age of Empires, where you purchase a "trade cart" and right-click on a town center (in this case, a teammate's town center), it'll automatically walk to and from the town center with resources. However, on top of this, I was wondering if it were possible to set it to where the player who is sending the "trade cart" (a turtle caravan in this case) would use his own resources for the trade instead of generating brand new resources:

    Player trains caravan
    Player sends caravan to teammate's town center
    Caravan touches town center, caravan's Player loses 100 gold and 50 lumber (resource numbers are just for example) from personal resources
    Caravan returns back to Player's town center, teammate gains 100 gold and 50 lumber

    The only real must is that it needs to just be in-game editor triggers, if it's not possible to do it with in-game triggers then I'll have to scrap the idea.

    Thanks for any help provided, it's greatly appreciated.

    Hjorleif
     
  2. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    This is possible for sure, and not very hard either though it may be quite tedious.
    Can be done using 100% GUI triggers.


    A few things that will help build the system:

    1) If you want caravans to be able to be selected, but not controllable, we'll need 1 dummy player per player
    Example: Player 1 = Actual Player // Player 13 = Fake P1 (with triggers, set P13 name and color to P1, and make them both allied)

    2) Make 2 (or however many you like) versions of the "Charge Gold and Lumber" ability (neutral hostile / units) and make sure to give them different order ID's (any other, they just can't be identical)
    One which charges lets say 100 gold and the other 50 lumber (rename them and stuff too so it looks good in-game)
    We'll use those abilities to "load up" the caravan with currency, allowing players to load however much they want

    3) A unit target ability (I recommend using Channel as base) and set it so that it can only target friendly Town Halls, give it a range of
    something like 50-100 so that it has to be close to proc the "trade"

    4) a\. If you use an indexing system for your units (which I recommend - Bribe made a great one but you can make your own) you can create 2 Integer Array variables
    Example: Loaded_Gold // Loaded_Lumber
    You can just take the UnitIndexer from Bribe's engine here (no need for the whole system):
    Damage Engine 5.4.2.3

    -------

    The chain of events:

    1) Player trains Caravan.

    2) Caravan Starts the Effect of an Ability (Load Gold lets say), then set the integer array variable we made before as such:
    set Loaded_Gold[X] = Loaded_Gold[X] + 100
    Where X is the unit's custom value, every unit will have a different custom value if you use an idexer (and you shouldn't usually change their custom values either unless it's for a very specific reason)

    3) Player tells Caravan to use the Channel based ability to target a Town Hall, then Change ownership of Caravan to the dummy player of that player (each should have their own)

    5) Issue order for Caravan to use the Channel ability on that same Town Hall (if the order was broken from change of ownership)

    6) Make new Trigger with event Caravan Starts the Effect of an Ability (the Channel ability)
    When that trigger is fired, add Loaded_Gold[X] to target of ability being cast, do the same for lumber

    7) You can remove the Caravan at that point, or order it to come back :)

    Bam! :)
     
  3. Hjorleif

    Hjorleif

    Joined:
    Aug 13, 2009
    Messages:
    321
    Resources:
    0
    Resources:
    0
    As I am very new to triggers, I don't understand most of what you said without being able to see it. Any chance you can use the trigger tag on here to show what it's supposed to look like so I can see how it's done and study it?

    Thanks,

    Hjorleif
     
  4. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    I'll make a quick test map for you with it a little bit later, but if you do not know how to trigger, you should ask directly for someone to make it for you, not to explain ^^... I don't know if they are still around but there are some spell workshops where you can put in requests.
     
  5. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Here we go my friend, let me know if this suits your needs or if you need help implementing it into your map :)
    I added a LOT of documentation inside to help, inside each trigger.

    I am posting the triggers as well for others interested in taking a look at it.
    The system uses Bribe's unit indexer (no reason to make your own when this exists lol...).

    PS: The download for test map is at the bottom

    • TPTS Load Gold
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Load Gold - (Caravan)
      • Actions
        • -------- Here we are making Integer_ID = the units custom value --------
        • -------- they all have a different one when using an indexer --------
        • -------- it's basically a way of attaching info to units, such as extra stats --------
        • Set TPTS_Integer_ID = (Custom value of (Triggering unit))
        • -------- --- --------
        • -------- Here I am saving the name of the unit for later use --------
        • -------- I am going to rename the unit to show how much resources it is carrying! :) --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TPTS_Caravan_Loaded_Gold[TPTS_Integer_ID] Equal to 0
            • TPTS_Caravan_Loaded_Lumber[TPTS_Integer_ID] Equal to 0
          • Then - Actions
            • Set TPTS_Caravan_NameBeforeFix[TPTS_Integer_ID] = (Name of (Triggering unit))
            • -------- Since it makes no sense to send resources when the Caravan has none --------
            • -------- We add the ability to send resources only once it has loaded something --------
            • Unit - Add Send Resources - (Caravan) to (Triggering unit)
          • Else - Actions
        • -------- --- --------
        • -------- Here we are updating the amount of resources it is carrying --------
        • Set TPTS_Caravan_Loaded_Gold[TPTS_Integer_ID] = (TPTS_Caravan_Loaded_Gold[TPTS_Integer_ID] + 100)
        • -------- --- --------
        • -------- Now I run another trigger to fix the name --------
        • -------- The reason I do not add this code below and run another trigger instead --------
        • -------- is because we will run this trigger from the Load Lumber trigger as well --------
        • Trigger - Run TPTS Caravan Fix Name <gen> (checking conditions)


    • TPTS Load Lumber
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Load Lumber - (Caravan)
      • Actions
        • Set TPTS_Integer_ID = (Custom value of (Triggering unit))
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TPTS_Caravan_Loaded_Gold[TPTS_Integer_ID] Equal to 0
            • TPTS_Caravan_Loaded_Lumber[TPTS_Integer_ID] Equal to 0
          • Then - Actions
            • Set TPTS_Caravan_NameBeforeFix[TPTS_Integer_ID] = (Name of (Triggering unit))
            • Unit - Add Send Resources - (Caravan) to (Triggering unit)
          • Else - Actions
        • Set TPTS_Caravan_Loaded_Lumber[TPTS_Integer_ID] = (TPTS_Caravan_Loaded_Lumber[TPTS_Integer_ID] + 50)
        • Trigger - Run TPTS Caravan Fix Name <gen> (checking conditions)


    • TPTS Caravan Fix Name
      • Events
      • Conditions
      • Actions
        • -------- Here we just are formatting how it will look in game --------
        • -------- Feel free to change stuff here or even delete it all together, this isn't needed --------
        • Set TPTS_String = TPTS_Caravan_NameBeforeFix[TPTS_Integer_ID]
        • Set TPTS_String = (TPTS_String + |n)
        • Set TPTS_String = (TPTS_String + |cffffcc00Gold:|r )
        • Set TPTS_String = (TPTS_String + (String(TPTS_Caravan_Loaded_Gold[TPTS_Integer_ID])))
        • Set TPTS_String = (TPTS_String + - )
        • Set TPTS_String = (TPTS_String + |cffffcc00Lumber:|r )
        • Set TPTS_String = (TPTS_String + (String(TPTS_Caravan_Loaded_Lumber[TPTS_Integer_ID])))
        • Unit - Set Name of (Triggering unit) to TPTS_String


    • TPTS Train Caravan
      • Events
        • Unit - A unit Finishes training a unit
      • Conditions
        • (Unit-type of (Trained unit)) Equal to Caravan
      • Actions
        • Set TPTS_Integer_ID = (Custom value of (Trained unit))
        • -------- Here we clean all the possible old stats (dead units recycle their ID) --------
        • Set TPTS_Caravan_Loaded_Gold[TPTS_Integer_ID] = 0
        • Set TPTS_Caravan_Loaded_Lumber[TPTS_Integer_ID] = 0


    • TPTS Valid Targets
      • Events
        • Unit - A unit Is issued an order targeting an object
      • Conditions
        • (Unit-type of (Triggering unit)) Equal to Caravan
        • (String((Issued order))) Equal to channel
      • Actions
        • -------- Above in the conditions, we check if the issued order --------
        • -------- is equal to the Ability: Send Resources --------
        • -------- This is checked before the Caravan actually uses the spell, but rather when it is ordered to use it --------
        • -------- We are going to use this to filter out the valid targets --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • ((Target unit of issued order) is A town-hall-type unit) Equal to True
            • ((Target unit of issued order) belongs to an ally of (Owner of (Triggering unit))) Equal to True
            • (Owner of (Triggering unit)) Not equal to (Owner of (Target unit of issued order))
          • Then - Actions
            • Game - Display to (All players) the text: PASS
            • -------- If every condition passes, the unit is allowed to go on with the order --------
            • Do nothing
          • Else - Actions
            • Game - Display to (All players) the text: STOP
            • -------- If any condition is not true, then we block the unit from following the order --------
            • -------- The typical problem here is that we cannot override an order at the same moment another order is given --------
            • -------- So we add the unit to a group that will force all units in that group to "Stop" --------
            • -------- with a timer that will execute 0 seconds from now (one computer "moment") --------
            • Unit Group - Add (Triggering unit) to TPTS_StopGroup
            • Countdown Timer - Start TPTS_StopTimer as a One-shot timer that will expire in 0.00 seconds


    • TPTS Stop Order
      • Events
        • Time - TPTS_StopTimer expires
      • Conditions
      • Actions
        • -------- In this trigger we simply order all units that were added to this group to "Stop" --------
        • -------- Then we remove them from the group --------
        • Unit Group - Pick every unit in TPTS_StopGroup and do (Actions)
          • Loop - Actions
            • Unit - Order (Picked unit) to Stop
            • Unit Group - Remove (Picked unit) from TPTS_StopGroup


    • TPTS Give Resources
      • Events
        • Unit - A unit Starts the effect of an ability
      • Conditions
        • (Ability being cast) Equal to Send Resources - (Caravan)
      • Actions
        • Set TPTS_Integer_ID = (Custom value of (Triggering unit))
        • -------- Once the caravan has reached its destination, it gives the resources --------
        • Player - Add TPTS_Caravan_Loaded_Gold[TPTS_Integer_ID] to (Owner of (Target unit of ability being cast)) Current gold
        • Player - Add TPTS_Caravan_Loaded_Lumber[TPTS_Integer_ID] to (Owner of (Target unit of ability being cast)) Current lumber
        • -------- Now we set the carried resources back to 0 since it already gave it --------
        • Set TPTS_Caravan_Loaded_Gold[TPTS_Integer_ID] = 0
        • Set TPTS_Caravan_Loaded_Lumber[TPTS_Integer_ID] = 0
        • -------- Since it doesn't have any resources left, it shouldn't have the ability to send any either --------
        • -------- So lets remove it --------
        • Unit - Remove Send Resources - (Caravan) from (Triggering unit)
     

    Attached Files:

    Last edited: Aug 8, 2019
  6. Hjorleif

    Hjorleif

    Joined:
    Aug 13, 2009
    Messages:
    321
    Resources:
    0
    Resources:
    0
    Hello,

    Thanks for helping out so far, I'm wondering if there's a way to show when the gold and lumber are added to the player, such as when you pick up a "Bundle of Lumber" for example, it shows +100 Lumber (+100 Gold in yellow text for gold) in green text over the hero, anyway to get that to show over the allied Town Hall? (I believe there is also a sound queue? If that could be added too that would be awesome)

    Also, I liked your idea of when using the "Send Resources" ability that it changes the Caravan to an unused Computer that we can no longer control so that it 'only' runs to the Town Hall and doesn't stop or anything even if attacked. Is this possible to add in as well? And if that's possible, can we also just have the Caravan removed from the game after it delivers the resources - preferably it would run to the allied Town Hall as a Computer controlled (no ai) player, deliver the resources, run straight back to it's own Town Hall and then disappear. If this is possible it would be the way I'd prefer, if not then just the former (delivers resources and gets removed from game there instead of running back first)

    I don't know how to create triggers myself, I have tried learning in the past but I just can't get the hang of it, but I do know how to copy either from a test map or from trigger tags, generally pretty solidly. So I appreciate you doing both.

    Thanks,

    Hjorleif
     
  7. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Yes that definitely can be done with floating texts

    ---

    That is no problem, I will do that. However there is 3 ways of doing it (pick one):

    1) The caravan becomes a Neutral Passive (yellow circle to everybody) but retains its color (so that enemies still know which ones to attack). This technique allows you to keep all 24 players for users.

    2) Create a dummy player for each player, this allows for each dummy player to have their own alliance settings, but cuts amount of users by 1/2.

    3) Create a dummy player per alliance, this allows for more use slots than 2) and more control over alliances than 1), but cannot be used in maps where you can change alliances in game or in FFA.

    ---

    Either way is fine, but what is the reason for running back to their own Town Hall? Are they bringing back extra resources with them? If you like I can make it so when it returns it generates some resources (out of thin air) based on the resources it was able to deliver.
    Example 1: Generates 20%, so if it was able to deliver 100g, it brings back 20g
    Example 2: Generates 150%, so if it was able to deliver 100g, it brings back 150g
    Basically, whats the point of it returning, there should be one (and I'll help implement it).

    ---

    That's no problem :) the triggers I made here should give you a better understanding of the structure of simple triggers though, it's always good to learn a little.
     
  8. Hjorleif

    Hjorleif

    Joined:
    Aug 13, 2009
    Messages:
    321
    Resources:
    0
    Resources:
    0
    The floating text would be awesome for sure.

    2) would definitely work best for me.

    I hadn't thought of a reason other than being realistic, but I do like the idea of having it return 20% as like a "congrats on surviving the trip back" reward. If it's not too much work that is.

    Yeah, I like to learn what I can from triggers, I can some really basic things because of people like you who help out.

    Thanks,

    Hjorleif
     
  9. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    All right! Gonna do this now it shouldn't take long.
    I forgot to ask though, do you want all players to see the floating text? or only the player giving and the player receiving?
     
  10. Hjorleif

    Hjorleif

    Joined:
    Aug 13, 2009
    Messages:
    321
    Resources:
    0
    Resources:
    0
    I suppose all is fine? Hadn't thought about that either haha. I think all should be fine.
     
  11. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Another question, if the original Town Hall is dead, should it look for another Town Hall owned by that player?

    EDIT: Or should it just go back to the closest Town Hall regardless of which one sent it? Also do I just remove them if there is no Town Hall at all?
     
  12. Hjorleif

    Hjorleif

    Joined:
    Aug 13, 2009
    Messages:
    321
    Resources:
    0
    Resources:
    0
    Maybe if the Town Hall it was on route to is destroyed during the route, they go back to the Town Hall they came from and get removed without any resources being given? If that's possible, if not then look for another owned by that player.
     
  13. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Lastly, do you want them do give part of the carried resources if killed by an enemy? I'm almost done btw
     
  14. Hjorleif

    Hjorleif

    Joined:
    Aug 13, 2009
    Messages:
    321
    Resources:
    0
    Resources:
    0
    Yeah that would actually be pretty cool. Maybe half?

    I really do appreciate the help. This will also help many other people, I'm sure. Which is awesome.
     
  15. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    No problem, I needed to code something lighter than what I was doing and I thought this system would indeed be a good one that people could use, and since I didn't see anyone answering I thought I'd take it on ^^. I'm making minor tweaks here and there to make the system smoother and checking for leaks atm, it's probably ready in 10-15 min
     
  16. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Ok I believe this is good, sorry for taking longer than expected hehe.
    Let me know if I forgot something, I will check over the code for errors again a little later as well :)...

    There are a lot more triggers now so I won't post them all, here is the trigger where you want to set stuff:
    • Actions
      • Set TPTS_Unit_Caravan = Caravan
      • -------- --- --------
      • Set TPTS_Ability_LoadGold = Load Gold - (Caravan)
      • Set TPTS_Ability_LoadGold_Amount = 100
      • -------- --- --------
      • Set TPTS_Ability_LoadLumber = Load Lumber - (Caravan)
      • Set TPTS_Ability_LoadLumber_Amount = 50
      • -------- --- --------
      • Set TPTS_Ability_SendResources = Send Resources - (Caravan)
      • -------- The return bonus is a percentage of loaded resources --------
      • -------- Here it is at 20% --------
      • Set TPTS_Ability_ReturnBonus = 20
      • -------- This is also a percentage of loaded resources --------
      • -------- Here it is at 50% --------
      • Set TPTS_Ability_KilledRatio = 50
     

    Attached Files:

  17. Hjorleif

    Hjorleif

    Joined:
    Aug 13, 2009
    Messages:
    321
    Resources:
    0
    Resources:
    0
    That is fantastic. Great job! I'm very pleased with it as I'm sure many others will be!

    Also, no need to apologize, I requested the help so you were on no time frame.

    I really, really appreciate the help, this works like a charm!
     
  18. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Glad you like it! It's a nice system I think, a funner/more realistic way of trading.

    EDIT: Btw I forgot to add, this will only work with trained Caravans, if you add caravans on your map at start since it will not have a return Town Hall it won't work right.
     
  19. Hjorleif

    Hjorleif

    Joined:
    Aug 13, 2009
    Messages:
    321
    Resources:
    0
    Resources:
    0
    I couldn't agree more. It's well made and so far works perfectly. I will definitely report any bugs to you if you want so you can potentially fix it for myself, yourself and anyone else who uses it.
     
  20. ThisPOT

    ThisPOT

    Joined:
    Feb 23, 2009
    Messages:
    561
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Yes please let me know if you find any bugs, I'll also check the code again for errors before posting it to the spell section (where it will be checked for errors again by a mod)

    EDIT: Another thing I forgot to mention, the dummy players have to be set to Computer or they wont work
     
    Last edited: Aug 9, 2019