|Posted By: TJ (2005-03-05 11:12:34) |
Hi everyone, I know in the future senarios and map editors are coming, but I've been trying to play around now...well not much success. Anyone have examples that work with PW to have a guide. And is there a good script editor? Well I'm happy to share my results if they come out decently. Thanks TJ
|Posted By: Tully (2005-03-05 12:57:53) |
All of the scripts that drive the game itself are open and most have comments. You can see them on you pc at c:/program files/metalshard/pocketwar/scripts.
|Posted By: TJ (2005-03-05 18:15:56) |
Yes, I've seen them. I guess I was wondering about turning off units loading or changing how land is distrubuted, or setting up a senario type. I know this is in the works for the future, and it sounds life good things are happening for you (congrats BTW). I've tried several variations, used the docs for examples and ideas. Not sure what program to really use to save a change, is word pad enough. I know I'm a newbie at this part, but I got an itch about trying to program it and I hoping for a little guidence in scatching it.
|Posted By: Tully (2005-03-05 19:25:15) |
For the turning on an off units parts. All units are defined in airport.js (the airport and all airplanes) shipyard.js (the shipyard an all boats) factory.js (the base an all tanks) and city.js (the city and all basic units.) Each .js file shows up as a mod that can be switched on and off using the mods menu. At the top of the file you will see...
var scriptName = "Shipyard";
var scriptType = "Mod";
var worksWithVersion = "1.5";
Those are global vars that tell pocketwar the name of the mod (as it will show up in the menu) the type of script it is (in this case a mod) and the min version of pocket war this script will work with.
Each mod script has a startScript() function and a stopScript() function. These are called when a new game starts and when a game is over to allow the script to set itself up and shut itself down. If you look at the shipyard.js file you can see that in the startScript() it tells pocketwar that this script will provide a bunch of units to the game (registerUnitType calls) and one city type (registerCityType). In the stop script it removed these types from the game. So basically if the script gets shut down then those types will be gone from the game (when you switch it off in the mod menu then start a new game this happens.)
Since the script said it knows how to build units (registerUnitType) it needs a createUnit() callback. This is called when the pocket war game engine needs to build a unit. If you look in that method you can see how each unit is defined.
Same thing with the city. Since the script said it can build cities it needs a createCity() callback so the game can get the script to build cities for it. It also needs a canPlaceCity() callback so it can tell the map generator where each type of city can be placed on the map.
If you look at the createUnit code you can see how the scripts can vary the creating of units based on who wants to build the unit (an AI or a player.) In this case the change is minimal there is a line if( getPlayerType( player ) == "computer" ) that sets the name differently if it is a player unit or a computer unit. But that could also be used to change the properties of a unit. (IE flying tanks for the computer but normal ones for the play.)
You can also do the same thing for cities. Cities have a player set on them when they are created, and if you look at the bottom of the createCity() callback you can see where the type of units a city can build are set. You could change this to check for a computer player vs a human player and vary what each city can build based on the type of player. When a city changes hands (ex a player captures a computer city) the city is destroyed an a new one it made with the same name. This allows this callback to get called again and the city properties to be altered.
|Posted By: TJ (2005-03-05 22:35:10) |
Thanks so much!!! I'll let you know how it goes. TJ
|Posted By: David (2005-04-04 20:24:14) |
I've been doing some tinkering myself but can't get past the errors and crashes. Specifically, I'm trying to get PW to allocate different unit construction capacities from player to player in order to accomodate weapons/vehicles/ships, etc., that are unique from each other.
Also, I have been trying to get the game to take a step back so only cities are created initially, and the rest (airports, factories, whatever) must be built by individual players. The AI doesn't seem too complicated to accomodate new units or factory building, but getting PW to allocate new unit x to only one player continues to cause the program to crash.
How might one direct the battle engine to rotate the first attack per turn around players 1-4, 1-3, or back and forth between 1 & 2? As it stands, player one always has a first strike advantage, but is always vulnerable to some stinking bomber that pops out and takes out a handful of tanks. The advantages and disadvantages are thus shared out proportionately.
Finally, I am wondering if the battle component can allocate a random number of damage points per attack, rather than knocking off 5, 10, 50 at a go.