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 - code to add mod to engineer?
Pages: [1] Messages 1 - 8 of 8
Posted By: J (2003-05-22 22:56:30)

if I wanted to add a unit to the engineer list of creatable units, what code do I use? Thanks
Posted By: Tully (2003-05-23 05:24:48)

If you look at your mod it adjusts the units.js file to add itself to the list of units that can be built. It adds a new function that looks something like newCreateUnit( typeString ) that will call the old function oldCreateUnitFunc( typeString ) and see if a unit was created. You can check the typeString that is passed in and if it is "Engineer" then the unit that oldCreateUnitFunc returns is the engineer that will get passed back to Pocket War. Now you just need to adjust that unit.

You can call

var transTypes = getTransportTypes( unit );

which will give you a string with all the types the engineer can carry. Then you can append your own unit to the end of that list.

transTypes = transTypes + "-MyUnitName";

Notice the "-" that is used as a seperator. That call will let the engineer carry your unit now you have to add a call to let the engineer build your unit.

var buildTypes = getBuild( unit );
buildType = buildTypes + "-MyUnitName";

And that will do it. Now when that engineer unit gets passed back to Pocket War it will be able to build your unit as well.

Posted By: J (2003-05-23 14:03:06)

Itried this by pasting your code and changing -myunitname to the correct one. However, I just get errors. Please explain more detailed of what I need to do. Thanks
Posted By: Tully (2003-05-25 11:49:15)

If you get the humvee mod in mod-humvee-unit.js you can see the line that allows transports to transport the humvee. It looks like

setTransport( unit, getStat( unit, "max transport" ), getTransportTypes( unit ) + "-Humvee" );

In your mod you would want to do the same thing but for engineers and you want to make the engineer be able to build it. The code would look like the following

if( typeString == "Engineer" )
{
setTransport( unit, getStat( unit, "max transport" ), getTransportTypes( unit ) + "-Humvee" );
getBuild( unit, getBuild() + "-Humvee" );
}

But you would want to change Humvee for your unit name. Case matters watch those lower and uppercase letters.
Posted By: J (2003-05-26 17:45:26)

AHHH I am pulling out my hair! I just keep getting errors. Where do I put the code? It keeps telling me :

SCRIPT: Santax error in call to tile 'string getBuild( tile tileWhoseListToGet)'

then

SCRIPT -- createUnit failed to create a Engineer

What is going on?
Posted By: Tully (2003-05-26 18:39:40)

zip up your mod and post hit here and I will take a look at it. That is probably the easiest way for me to figure out what is going on.
Posted By: J (2003-05-26 18:44:49)

Thanks! I ask the questions because I also wanted to learn so I could be a better scripter. Hope you don't mind. Thanks again! I look forward to seeing what you do.

ps. the one i am posting is the working one, it just need the proper code to add to the engineer
Posted By: Tully (2003-05-26 19:39:34)

Sorry there was typo in my code above. Here is a version of your float cannon that will work. Take a look at the bottom of the newCreateUnit method and you can see the codes that was needed to allow engineers to build this unit.
Pages: [1] Messages 1 - 8 of 8




Reply


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