Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home3/tedson/public_html/metalshard/header.php on line 14

Warning: Cannot modify header information - headers already sent by (output started at /home3/tedson/public_html/metalshard/header.php:14) in /home3/tedson/public_html/metalshard/header.php on line 23

Warning: Cannot modify header information - headers already sent by (output started at /home3/tedson/public_html/metalshard/header.php:14) in /home3/tedson/public_html/metalshard/header.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /home3/tedson/public_html/metalshard/header.php:14) in /home3/tedson/public_html/metalshard/header.php on line 25

Warning: Cannot modify header information - headers already sent by (output started at /home3/tedson/public_html/metalshard/header.php:14) in /home3/tedson/public_html/metalshard/header.php on line 26
Pocket PC Forum page 1 topic 531 at MetalShard
MetalShard, inc.
Pocket PC and Windows Games and Software

Pocket War (Game) Forum

This is a message in the Pocket War (Game) forum. If you would like to reply to this subject then fill in your reply in the box at the bottom of the page and click the Reply button. To get back to the main page for this forum click the Topics button.

Subject - Example Scripts
Pages: [1] Messages 1 - 6 of 6
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 an editor I use homesite. That is just because I already owned it and all it really gives me is syntax hilighting for the javascript. Any editor that understands javascript will work for you. For a free solution you can try this combined with eclipse. Also wordpad will work fine.

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.
Pages: [1] Messages 1 - 6 of 6


Attach File (zip and pwg files only)

you must be logged in to post
Copyright 2003-2010 MetalShard, inc. Games for Windows and Pocket PCs pocket war forums, automation software freegames