2007.08.26, 02:21 AM
The title explains it all.
I am having lots of trouble - its 15 past 4 right now and i have been trying since 1:00.
i'm using Soldier as a basis, and i have put node walking from joefoe in there as well.
it says put unique model code or somthing similar, but whaere does it say the unique code? i saw CW as in civil war in some places, so i used that instead of JF.
While you are helping me
could you tell me how you give the soldier as much "hitpoints" as the player? i cant see it anywhere in the script.
I am having lots of trouble - its 15 past 4 right now and i have been trying since 1:00.
i'm using Soldier as a basis, and i have put node walking from joefoe in there as well.
it says put unique model code or somthing similar, but whaere does it say the unique code? i saw CW as in civil war in some places, so i used that instead of JF.
While you are helping me
could you tell me how you give the soldier as much "hitpoints" as the player? i cant see it anywhere in the script.Code:
// ******************************************************************************** ************
// ******************************************************************************** ************
// *************** BOT **********************
// *************** ------- **********************
// *************** SOLDIER **********************
// ******************************************************************************** ************
// ******************************************************************************** ************
// constants
const CW_TIMER_ID_DISOLVE=1;
const CW_WAIT_ID_FIRE_START=2;
const CW_WAIT_ID_MELEE_START=3;
const CW_WALK_TO_DEST01=4;
const CW_WALK_TO_DEST02=5;
const CW_TURN=0;
// variables
var otherTeam='';
var turnSpeed=0;
var turnDir=0;
var turnToAngle=0;
// =======================================================
//
// Initial Construction
//
// =======================================================
function soldierConstruct(obj)
{
// setup model
obj.model.on=true;
obj.model.name='Soldier';
obj.model.lit=DIM3_MODEL_LIT_FLAT;
obj.model.truform=true;
obj.model.shadow.on=true;
// setup soldier settings
obj.setting.damage=true;
obj.setting.ignorePickUpItems=false; //pickup the weapons/ammo
obj.size.x=1100;
obj.size.z=1100;
obj.size.y=2300;
obj.size.weight=250;
obj.health.maximum=1;
obj.health.start=1;
// setup weapon
obj.weapon.add('Hammer');
}
// =======================================================
//
// Node walking (i hope)
//
// =======================================================
function SoldierStartNodeWalk(obj)
{
var nodeId,nodeName;
// find node nearest to Soldier
nodeId=map.node.nearest(obj.position.x,obj.position.z,obj.position.y,null,null,null,0,3000);
if (nodeId==-1) return; // can't start walking, no node nearby
nodeName=map.node.getName(nodeId);
// start joefoe seeking from nearest node to far node of map
obj.forwardSpeed.walk=35;
obj.model.animation.start('Walking');
obj.motionVector.walkToNode(nodeName,'Dest01',CW_WALK_TO_DEST01);
// start a timer for waiting to fire
obj.event.startWaitRandom(50,90,CW_WAIT_ID_FIRE_START);
// set a flag so damage knows what we are seeking
seekingPlayer=false;
}
function joeFoeResumeNodeWalk(obj)
{
// resume walking nodes from last node
obj.forwardSpeed.walk=45;
obj.model.animation.start('Walking');
obj.motionVector.walkToNodeResume();
// start a timer for waiting to fire
obj.event.startWaitRandom(50,90,CW_WAIT_ID_FIRE_START);
// set a flag so damage knows what we are seeking
seekingPlayer=false;
}
function SoldierFinishNodeWalk(obj,subEvent,id)
{
// is this a event telling us that our last node walk has finished?
if (subEvent!=DIM3_EVENT_PATH_DONE) return;
// yes, so use the id to tell where we walked, and walk to the opposite node
if (id==CW_WALK_TO_DEST01) {
obj.motionVector.walkToNode('Dest01','Dest02',CW_WALK_TO_DEST02);
}
else {
obj.motionVector.walkToNode('Dest02','Dest01',CW_WALK_TO_DEST01);
}
}
// =======================================================
//
// Spawning
//
// =======================================================
function soldierSpawn(obj)
{
var uniformFill,speed;
// what side is bot on?
if (obj.setting.getParameter(0)=='North') {
obj.setting.team='North';
otherTeam='South';
uniformFill=0;
}
else {
obj.setting.team='South';
otherTeam='North';
uniformFill=1;
}
// choose uniform
obj.model.fill.change(0,uniformFill);
obj.model.fill.change(1,uniformFill);
// random turn speed and direction
turnSpeed=utility.random.getFloat(0.5,0.75);
turnDir=utility.random.getPosOrNeg();
// start by going to attention
obj.model.animation.start('Attention');
// turning
obj.event.chain(30,'soldierStart');
}
// =======================================================
//
// Turning
//
// =======================================================
function soldierSetupTurn(obj)
{
turnToAngle=utility.angle.add(obj.angle.y,90);
obj.motionAngle.turnToAngle(turnToAngle,turnDir);
}
function soldierStart(obj)
{
obj.model.animation.start('Attention');
obj.turnSpeed.facingWalk=obj.turnSpeed.motionWalk=turnSpeed;
soldierSetupTurn(obj);
obj.event.startTimer(5,CW_TURN);
}
function soldierTurn(obj)
{
var x,z,y,ang,id,wait;
x=obj.position.x;
z=obj.position.z;
y=obj.position.y;
ang=obj.angle.y;
// need to keep turning?
if (ang==turnToAngle) soldierSetupTurn(obj);
// anybody in sight?
id=map.object.nearestTeam(x,z,y,otherTeam,ang,3,0,100000);
if (id==-1) return;
// somebody in sight, stop turning
obj.event.clearTimer();
obj.motionAngle.turnStop();
// random waiting time
wait=utility.random.getInteger(10,70);
obj.event.chain(wait,'soldierFireStart');
}
// =======================================================
//
// Shooting
//
// =======================================================
function soldierFireStart(obj)
{
var wait;
obj.model.animation.start('Shoot');
wait=utility.random.getInteger(15,25);
obj.event.chain(15,'soldierFireEnd');
}
function soldierFireEnd(obj)
{
var wait;
obj.weapon.fire('Musket',0);
wait=utility.random.getInteger(5,8);
obj.event.chain(wait,'soldierReload');
}
function soldierReload(obj)
{
var wait;
obj.model.animation.start('Reload');
wait=utility.random.getInteger(30,35);
obj.event.chain(wait,'soldierPresent');
}
function soldierPresent(obj)
{
var wait;
obj.model.animation.startThenChange('PresentArms','PresentArmsEnd');
// turn a little slower next time to be more accurate
turnSpeed-=0.025;
if (turnSpeed<0.5) turnSpeed=0.5;
// start bot over
wait=utility.random.getInteger(10,20);
obj.event.chain(wait,'soldierStart');
}
// =======================================================
//
// Dying
//
// =======================================================
function soldierDie(obj)
{
var id,north,south;
obj.event.clearTimer();
obj.event.clearChain();
obj.motionAngle.turnStop();
obj.setting.find=false; // no longer be found in nearest searches
obj.setting.contact=false;
obj.model.animation.start('Die');
// change score card
north=data.get('north');
south=data.get('south');
if (obj.setting.team=='North') {
north--;
}
else {
south--;
}
data.set('north',north);
data.set('south',south);
iface.text.setText('North Score',north);
iface.text.setText('South Score',south);
}
// =======================================================
//
// Events
//
// =======================================================
function event(obj,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
soldierConstruct(obj);
return;
case DIM3_EVENT_SPAWN:
soldierSpawn(obj);
return;
case DIM3_EVENT_DIE:
soldierDie(obj);
return;
case DIM3_EVENT_TIMER:
soldierTurn(obj);
return;
}
}