• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Mobile Resource drop off point

Status
Not open for further replies.
Level 2
Joined
Aug 14, 2017
Messages
12
I have this ambition of creating a mobile resource drop off point. However, this drop off point needs to return to a town hall or other resource drop off point for the resources to actually enter a player's property. Workers that harvest resources and drop off at this point are effectively just transferring their collected resources onto the drop off point's collected resources.

I realize that this post might be a bit optimistic as I believe it's some pretty hard-coded systems I'm dabbling in. But I think it would be a pretty neat mechanic to add on to my campaign.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
Have you tried making a Town Hall with Movement? If you can get one to function properly while also being able to move around then you're halfway there. Then you just need a system for detecting resources delivered to this mobile Town Hall, subtracting the gained gold or lumber, storing that amount in a variable attached to mobile Town Hall, and using a custom system for returning these "fake" resources to an actual Town Hall. That could be done with a custom "Return Resources" ability that can only target your own Town Halls.
 
Level 2
Joined
Aug 14, 2017
Messages
12
It sounds rather reasonable, however, I don't have any experience in working with Jass, and I don't think the GUI has any inherent way of detecting resource drop off. I suppose I could go by detecting the player's property increase, but then I don't have a source on where the income came from. Meaning, selling items, or regular harvesting at a Town Hall would get caught up in that detection as well. I have figured out a scripted ability that orders the mobile Town Hall return to the nearest player owned town hall.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
It sounds rather reasonable, however, I don't have any experience in working with Jass, and I don't think the GUI has any inherent way of detecting resource drop off. I suppose I could go by detecting the player's property increase, but then I don't have a source on where the income came from. Meaning, selling items, or regular harvesting at a Town Hall would get caught up in that detection as well. I have figured out a scripted ability that orders the mobile Town Hall return to the nearest player owned town hall.
There is nothing (or a very few amount of things) in Jass that you can't do in GUI since Custom Script gives you access to Jass code. But you're correct that there's no easy way of detecting the drop off. A system would need to be in place that watches and tracks the behavior of workers. Possibly one that syncs the delivery of a resource to the Mobile town hall, which would be handled using a property increase Event, along with the issued Order event (assuming an Order is issued at the time of dropoff). These two in conjunction could get you the delivering unit, target unit of delivery, and the amount of resources that was delivered. From there you would use a Hashtable or Unit Indexer to track the amount of resources that have been dropped off at the Mobile town hall.

Edit: Something like this seems to work. Just know that it doesn't account for changes in gold/lumber from spending/trading:
  • Harvest Delivery
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(harvest))
    • Actions
      • Set VariableSet Harvest_Player = (Owner of (Triggering unit))
      • Set VariableSet Harvest_PID = (Player number of Harvest_Player)
      • Set VariableSet Harvest_UID = (Custom value of (Target unit of issued order))
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Harvest_Was_Gold Equal to True
        • Then - Actions
          • Set VariableSet Harvest_Amount = ((Harvest_Player Current gold) - Harvest_Player_Prev_Gold[Harvest_PID])
          • -------- --------
          • -------- Increase the tracked gold that the town hall has accumulated: --------
          • Set VariableSet Harvest_Tracked_Gold[Harvest_UID] = (Harvest_Tracked_Gold[Harvest_UID] + Harvest_Amount)
          • Game - Display to (All players) for 30.00 seconds the text: (Town Hall accumulated gold: + (String(Harvest_Tracked_Gold[Harvest_UID])))
          • -------- --------
          • Player - Add (Harvest_Amount x -1) to Harvest_Player.Current gold
          • Set VariableSet Harvest_Player_Prev_Gold[Harvest_PID] = (Harvest_Player Current gold)
        • Else - Actions
          • Set VariableSet Harvest_Amount = ((Harvest_Player Current lumber) - Harvest_Player_Prev_Lumber[Harvest_PID])
          • -------- --------
          • -------- Increase the tracked lumber that the town hall has accumulated: --------
          • Set VariableSet Harvest_Tracked_Lumber[Harvest_UID] = (Harvest_Tracked_Lumber[Harvest_UID] + Harvest_Amount)
          • Game - Display to (All players) for 30.00 seconds the text: (Town Hall accumulated lumber: + (String(Harvest_Tracked_Lumber[Harvest_UID])))
          • -------- --------
          • Player - Add (Harvest_Amount x -1) to Harvest_Player.Current lumber
          • Set VariableSet Harvest_Player_Prev_Lumber[Harvest_PID] = (Harvest_Player Current lumber)
  • Harvest Gold Change
    • Events
      • Player - Player 1 (Red)'s Current gold becomes Greater than or equal to 0.00
    • Conditions
    • Actions
      • -------- This occurs before Harvest Delivery. --------
      • Set VariableSet Harvest_Was_Gold = True
  • Harvest Lumber Change
    • Events
      • Player - Player 1 (Red)'s Current lumber becomes Greater than or equal to 0.00
    • Conditions
    • Actions
      • -------- This occurs before Harvest Delivery. --------
      • Set VariableSet Harvest_Was_Gold = False
Then from there you would have a custom system for making the mobile town hall deliver these resources to a real town hall. A custom targeted ability could work just fine. A unit Starts the effect of an ability -> Ability equal to Custom Delivery -> Reference Harvest_Tracked_Gold/Lumber and Set these values back to 0.

Some floating text could display how much this town hall has gathered so far. Or maybe adjust it's Unit name.
 

Attachments

  • Harvest Example 1.w3m
    24.7 KB · Views: 5
Last edited:
Level 2
Joined
Aug 14, 2017
Messages
12
There is nothing (or a very few amount of things) in Jass that you can't do in GUI since Custom Script gives you access to Jass code. But you're correct that there's no easy way of detecting the drop off. A system would need to be in place that watches and tracks the behavior of workers. Possibly one that syncs the delivery of a resource to the Mobile town hall, which would be handled using a property increase Event, along with the issued Order event (assuming an Order is issued at the time of dropoff). These two in conjunction could get you the delivering unit, target unit of delivery, and the amount of resources that was delivered. From there you would use a Hashtable or Unit Indexer to track the amount of resources that have been dropped off so far to the Mobile town hall.
I am trying to implement this approach.
I managed to get the resumeharvesting order to give me the mobile town hall, it's a first effort as it will only handle automatic gathering and not manual drop off. And I also have a counter/deductor that removes a variable from the player's property, and adds it to the hashtable. Your suggestion regarding synchronizing these eludes me though, how would I go about synchronizing these separate trigger events? After all, it does take a while for workers to return the resources.
I realize the order might be too simplistic as to what you were suggesting with the worker tracking. If it's possible for you to expand upon these systems I would appreciate it a lot.
 
Status
Not open for further replies.
Top