Game Development Community

Resource Generation

by Anthony Rosenbaum · in RTS Starter Kit · 11/25/2004 (4:58 am) · 5 replies

This isn't full blow at all. Infact this is just to show you how to spawn things randomly in the mission area. Once some pathfinding is added I will expand to get the villager to go to the resources, collect them, and return. But for now we will generate random trees.

HERE is the template I am using to spawn random static shapes later to be actual resources.

If you want it to be automatic, SEE BELOW


Note this is happening on the server, so if you need to reseed you can use my server cmd function found in the file to do it directly from any client.

A quick thanks to Phil C. who has a great function for getting terrian height which I lifted from RW.

One other side note when you click on a tree it renders a huge selection circle. . .I will work on geting it to it's proper size.

#1
11/25/2004 (5:58 am)
I haven't had a chance to take a look at the script itself yet, but you get a couple of console methods you might be able to use:

isServerObject()
isClientObject()

there are also ways to check if a conn is a serverConnection or a client (local?)Connection, not sure if that use helps or not.

Might want to do a search in files/grep for isServer across either your script dirs, or your engine dir, or both to see what's available.
#2
11/25/2004 (6:50 am)
Hurrah I got it

do this

in server/scrips/core/game.cs
in on mission loaded
add :
if(!isObject(ResourceSet)){
   new SimSet(ResourceSet);
   seedResource(Tree3,50);
   }
before the startGame call

this creates simset to hold the resouces. SIDE NOTE resourceGenerationhas been changed and updated essentially I added a call to add the resource to the Resource set like this ResourceSet.add(%resource) and also remove all the client scoping.

TO cover our track we need to besure to remove this set later so in
common/server/server.cs
in destroyserver() add:
if (isObject(ResourceSet))
      ResourceSet.delete();
undernieght the missioncleanup section

finally to scope the ResourceSet to each client in
server/scrips/core/game.cs
in RTSConnection::onClientEnterGame(%this) add:
if(isObject(ResourceSet)){
      for(%d = 0; %d < ResourceSet.getCount(); %d++){
      %tr = ResourceSet.getObject(%d);
      %tr.scopeToClient(%this);
     }
   }
before the createPlayer loop.

There you have it, now all one has to do is give each Resource a meaning =) and make the bots go there.
#3
11/25/2004 (7:06 am)
Nice man! Was next on my todo list, great to have something to work with!
#4
07/31/2005 (2:00 am)
Link?
#5
08/30/2005 (6:27 am)
This has been added to Stephen Zepps main mod set