Game Development Community

Jared's Resource Manager--functionality requests?

by Stephen Zepp · in RTS Starter Kit · 11/18/2004 (8:03 pm) · 41 replies

I liked the functionality in Jared's SupplyMan resource, so I decided to adapt it to a server authoritative version, where the client was only allowed to display the data sent by the server.

I currently have the client able to:

--display the icons John created for us in a SupplyDisplay gui panel
--Accept a server command to setup the local store
--Inform the server the store is ready for inventory
--accept the server's authoritative inventory count, and update guis

And I have the server be able to:

--tell the client to setup the local store
--maintain an authoritative count of each supply
--send an inventory (supply and count) to the client
--(almost ready) accept client requests to "spend" resources

I wanted to ask everyone here what other type of functionality we would like for this updated resource.

I currently plan to implement tomorrow:
--client requesting to "spend" inventory
--server authorizing/declining a spend request
--server adjusting inventory for anything spent
--(already done) server sending authoritative inventory updates

I haven't yet decided how I'd like to adjust inventories over time. Jared's resource is very similar to Warcraft 3's tracking of food (your count doesn't go up or down over time based on individual apply events, it simply "is", based on any addSupply calls). We might want to further define individual supplies as "static"--where you don't spend the supply to do things, it's simply there as a count that allows you to do other things, and "dynamic" where you can collect more of the supply over time, and spend the supplies to do things (like lay down buildings, buy troops, etc.).

Any other things folks would like to see?
Page «Previous 1 2 3 Last »
#1
11/18/2004 (9:58 pm)
Is the system used by Starcraft a good basis, or is it to primative? You just mine mineral and poke your finger in geysers.
#2
11/19/2004 (8:17 am)
Starcraft and warcraft were pretty much identical other than names and graphics, at least as far as the resource system went. the only major difference being that one resource, the gas, couldn't ever completely run out which really isn't something that would be managed by this system anyway.
#3
11/19/2004 (8:23 am)
@Shawn--I've never actually played Starcraft, so I'm not sure...I'm basing my functionality on Warcraft 3 in many ways (gold/wood), as well as some other resource management games like Stronghold and Age of Empires.

@All: It's quiet around here!
Since I didn't get any specific functionality requests, I went ahead and implemented purchase requests on the server side of the process. When the client performs an action that sends an "Issue..." to the server (see the documentation for the RTS SK), the handling function for that issue can request purchase verification from the player's server side resource store. For example:

-Player hits the build icon, moves the RTSBuildingMarker where they want the building to be placed, and left clicks on the map
--Client sends the request to place the building, including which store to draw resources from (I'm working on multiple stores per player)
--Server accepts the PlaceBuilding command, and checks the resource store to make sure the player can afford the action
---*cost of an action is defined at this level
---resource store parses the cost of the action against current stock
----if the player can afford the action, it decreases the current inventory, and updates the client's inventory
----if the player cannot afford the action, it calculates the resources that are missing
----it can either send a PurchaseRejected string indicating the failed inventory (all of 'em!), and then tells the caller that the request is denied, or it can pass the failed inventory list back to the caller (caller configureable)
---resource manager returns ALLOW/DENY
--PlaceBuilding command interprets the authorization code, and proceeds, or rejects as necessary
--Client receives 'AcceptSupplyUpdate' command if purchase went through, or 'AcceptPurchaseRejected' string (with list of missing resources) if rejected
-Building is placed, and local inventory display updated, or building is cancelled and reason available.

I'm working on the design next for adding resources to the store(s) as they are collected (by your workers--any artists want to make us a basic worker .dts with an animation or two?)
#4
11/19/2004 (8:34 am)
These are off the top of my head. They may or may not even fall into the scope of what you're trying to do with this. It kinda looks like you're focusing more on the client-server interaction rather than the system of resources itself so I'm not sure.

Time based
so much of x is aquired over y time.
y is accessible to vary depending upon structure improvements
x is able to be based upon owning z amount of said structure

Negative to positive
Think like a morale system, but they would work so closely that why not run off the same system x event happens and y variant is augmented. up to the game to decide what to do with y

Compount resources
A resource that must be created from other resources. Ie. Bronze made from copper and tin.

Stealing
Team A can pull resource X directly from Team B's resource pool if conditions are met. Not sure if this one would need any structural changes to the client-server setup.
#5
11/19/2004 (8:46 am)
My overall goal was to get it configured to allow for authoritative control server side, as well as provide/expand functionality to give the developer as much freedom as possible.

Quote:
Time based
so much of x is aquired over y time.
y is accessible to vary depending upon structure improvements
x is able to be based upon owning z amount of said structure
I'll most likely make the "add to store" functionality the same structure as the "take from store" so far. To accomplish your functionality here is pretty easy, write a server side function that does the calculations, and use schedule to manage the iterations over time.
Note: when working with these, it's important to differentiate between the dynamic and static resources I mentioned above. For example, wood/gold in WC3 are "dynamic" resources--you collect and spend them over time. Food however is a static resource--the "over time" part is implied, since the total amount of food you have doesn't pulse based on player resource "use". It simply is the sum total of how many food generators you have.

Quote:
Negative to positive
Think like a morale system, but they would work so closely that why not run off the same system x event happens and y variant is augmented. up to the game to decide what to do with y
Definitely a neat idea, but is out of scope I think for this mini-project.
Quote:
Compount resources
A resource that must be created from other resources. Ie. Bronze made from copper and tin.
Will definitely be implemented for our project, and all the tools for the tracking (not, however, the combinations) will be part of this mini-project.
Quote:
Stealing
Team A can pull resource X directly from Team B's resource pool if conditions are met. Not sure if this one would need any structural changes to the client-server setup.
This is one of the exact reasons why I encapsulated the resourceStore a bit more than your original implementation. You seemed to be modelling the "phantom store" concept that WC3 uses--the resources don't actually "exist in game" anywhere. I'm trying to figure out the mappings to allow the client to indicate which store (of several possible) to take resources from, and have the server also allow attaching stores to game objects, like a building (shed, vault), a vehicle (cart), or even possibly player/npc objects(??).
#6
11/19/2004 (8:56 am)
@Jared: I sent you an e-mail to your public e-mail address, in case you don't normally monitor that.
#7
11/20/2004 (7:34 am)
@Stephen

Just one comment on the example in your Nov 19, 2004 11:23 EST post above.

You might want to consider having the system calculate the required resources when the build button is clicked rather than when the user clicks to place the building.

It will save them the frustration of having taken the time to decide where to place it before they know they can even build it.
#8
11/20/2004 (8:19 am)
@Jeff: I've considered checking the local store (client side, which is NON-authoritative, meaning it isn't guaranteed to be accurate, since the client can be hacked and given infinite supplies) as a pre-check prior to sending the check to the server (which IS authoritative), and it's certainly easy to do, but whenever you are thinking multiplayer game, you need to not think "hope my client gets hacked", but instead, "I KNOW my client is ALREADY hacked"--and program accordingly.

If we -only- checked client side, and the server believed the client, we're in a world of hurt when the hackers figure out your exe.

The other thing to keep in mind is the asynch "player doing something that takes a bit of time" vs "server churns away updating supplies"--what happens if you check client side, and at the time of the check your client supply store says "yep, we think we have enough" (or even the server annouces to you that you have enough), the player takes 10-20 seconds to actually select a spot and place it, but in the meantime the server has taken away some of the needed resources for whatever reason?
#9
11/20/2004 (8:26 am)
@All:

I am just about done with the entire resource manager mini-project, but ironically I can't figure out how to get the schedule statement to work properly for the example "building gives 50 gold every 5 seconds" script.

Does anyone see anything wrong with the following function, specifically the schedule line near the bottom?

function resourceStore::repeatingAddSupplies(%this, %scheduleTime, %store, %requestId, %request, %notifyClient)
{
  echo("repeatingAddSupplies()\n---%this:" SPC %this SPC "\n---Schedule:" SPC %scheduleTime SPC
       "\n---%store:" SPC %store SPC "requestId: " SPC %requestId SPC 
       "\n---request: " SPC %request SPC "Notify Client?" SPC  %notifyClient);
      
	// do the command
	resourceStore::requestAddSupplies(%this.client, %store, %requestId, %request, %notifyClient);
	// reschedule
	%this.supplyAddEventId = %this.schedule(%scheduleTime, 'resoureStore::repeatingAddSupplies', 
	               %this, "5000", 
                 "LOCAL", "ScheduledRepeatingSupplyAdd", "GOLD 50", "false");
}

it properly performs the command under the //command, and %this.supplyAddEventId is being set to the value of '1'--but the scheduled event never gets called again...

Note: I've also tried:
[code]
%this.supplyAddEventId = %this.schedule(%scheduleTime, 0,'resoureStore::repeatingAddSupplies',
%this, "5000",
"LOCAL", "ScheduledRepeatingSupplyAdd", "GOLD 50", "false");
#10
11/20/2004 (9:32 am)
Update: I've gotten a hack to "work" for having a building tell the resourceManager to schedule auto-supplies, but until I can wrap my head fully around how to properly handle cleanup of the schedule (it's probably how I'm creating it in the first place), it leaves a nasty infinite schedule when the client leaves the game (as well as when the building is destroyed).

To do this well, I need to be able to schedule the resource add directly on the object, so we can keep track of multiple scheduled adds in the resourceStore itself.

I'm plugging away, but this has been the one "I have no idea how to do this properly" part of this mini-project.

Anyone a schedule expert? :)
#11
11/20/2004 (11:28 am)
I think that I have the resource very close to release status, and am looking for some additional testers.

I would like to have folks that have a pretty good understanding of scripting and general TGE flow, as well as some skill in troubleshooting, so that I can get feedback/fixes to any issues that will go into the final resource.

If anyone is interested in helping to put the finishing touches on the resource, please let me know at the email address in my profile (or here via a post if you have an email address set in your profile)!

Thanks in advance, and I'm very happy with how the resource turned out--hopefully it will be a good benefit to everyone!
#12
11/20/2004 (11:36 am)
I'll help beta test it for you. Snowing outside, nothing better to do for a few hours. Just so you don't need to go in my profile if you want to email me, my email is Ziimac@gmail.com . I got an alright understanding of the TGE scripting.

Regards.
#13
11/20/2004 (12:23 pm)
--We need to make sure that we clean up any automated addSupply schedules as well.

File: /server/scripts/units/player.cs $$$$ Should be avatars inplace of units, for default download atleast.

--------------

I realy don't know about

First, you need to grab the gui icons kindly donated by John McGlamory.
You can find them at http://muro.ygingras.net/rts/icons32x32.zip
I suggest you create a new directory in your game/data/images/ui/ dir, called resourceDisplay
and place them there.


Other then that and a few other mistakes which I'll go back and find in a little bit, the instructions seem quite clear. Some stuff seem like it'd be a little hard to a begginer such as where the playGui.gui is. (client/ui).
#14
11/20/2004 (12:27 pm)
@Addison: good catch on the path change for avatars/player.cs, and missing from playGui.cs, thanks.

I'll work on cleaning up the instructions as well once I get additional feedback!

So---how did it work? :)
#15
11/20/2004 (12:42 pm)
N/p.

Well the not enough resource/can't build function is definatly working. I went to go test it and couldn't build the building. Atleast it's working. :), I take it the price for the building is in building.cs right? I'm going to go check that out real quick. And is the gui change only when clicking on the building because it isn't showing up on the main screen. I'll check that out in a minute too.

Regards.
#16
11/20/2004 (12:44 pm)
N/p.

Well the not enough resource/can't build function is definatly working. I went to go test it and couldn't build the building. Atleast it's working. :), I take it the price for the building is in building.cs right? I'm going to go check that out real quick. And is the gui change only when clicking on the building because it isn't showing up on the main screen. I'll check that out in a minute too.

Regards.
#17
11/20/2004 (12:45 pm)
Oh, problem found for that, or atleast pretty sure, haven't tested yet, but the directory isn't correct for the dts. Well, I got to go for a smoke, when I come back I'll test it.
#18
11/20/2004 (12:52 pm)
@Addison: Assuming everything in playGui.gui was set up properly, you should see your 4 icons as soon as you enter the game, populated with the initial resource counts (1000 gold, 500 wood, 20 food, 150 stone, in that order). If you aren't seeing that right off the bat, I'm guessing that you missed one of the steps (or I didn't put it in) in loadup...possibly the commandToClient(%this, 'AcceptSetupStores', "LOCAL"); in gameConnection.cs.


The way the "demo" is set up, you can use the (already present) BUILD icon to start dropping buildings. Each building you place should cost you 100 gold and 50 wood, and you should see the numbers go down.

Each building you build however generates 50 gold for you every 5 seconds, so the gold value will also be going up. I think you have enough wood to build 10 buildings, and then won't be able to build any more.
#19
11/20/2004 (12:56 pm)
Quote:
Oh, problem found for that, or atleast pretty sure, haven't tested yet, but the directory isn't correct for the dts. Well, I got to go for a smoke, when I come back I'll test it.

Good catch. I'll change it to the "stock" as well.
#20
11/20/2004 (1:09 pm)
Yep,

clientCmdAcceptSetupStores--setting up resource store
----MOVE THIS TO APPROPRIATE PLACE IN CLIENT STARTUP

was in there.

I didn't get an error when placing the building, I just didn't see it there. It was probaly just because the directory was wrong, I'll check that and the playGUI in one second.
Page «Previous 1 2 3 Last »