2007.07.25, 11:04 PM
Ummm... Whats wrong with this script? i cant be bothered to work it out. Its meant to be an AI that behaves like the sniper joefoe but looks different and shoots a different projectile.
Code:
var lastHit=0;
function leitConstruct(obj)
{
obj.model.on=true;
obj.model.name='Leit Cannon';
obj.model.lit=DIM3_MODEL_LIT_VERTEX;
obj.model.shadow.on=true;
// obj.model.suspended.on=true;
obj.setting.hitBox=true;
obj.setting.damage=true;
obj.setting.bumpUp=true;
obj.setting.ignorePickUpItems=true;
obj.setting.openDoors=false;
obj.turnSpeed.facingWalk=2.0;
obj.turnSpeed.motionWalk=1.8;
obj.turnSpeed.facingAir=1.0;
obj.turnSpeed.motionAir=0.8;
obj.forwardSpeed.walk=10;
obj.forwardSpeed.acceleration=1.5;
obj.forwardSpeed.deceleration=1.5;
obj.forwardSpeed.accelerationAir=0.5;
obj.forwardSpeed.decelerationAir=0.5;
obj.health.maximum=50;
obj.health.start=50;
obj.weapon.add('Christalli Cannon')
}
function leitSpawn(obj)
{
obj.model.animation.start('Idle')
// lastHit=0;
obj.watch.start(20000);
leitWatch(obj,subEvent);
}
function leitWatch(obj,subEvent)
{
if (subEvent==DIM3_EVENT_WATCH_OBJECT_NEAR)
{
if (obj.watch.objectId==map.object.findPlayer())
leitConfrontPlayerStart(obj);
return;
}
if (subEvent==DIM3_EVENT_WATCH_OBJECT_FAR)
{
obj.model.animation.start('Idle');
return;
}
}
function leitConfrontPlayerStart(obj)
{
obj.model.animation.startThenChange('SwitchAim','Aim');
id=map.object.nearestPlayer(obj.position.x,obj.position.z,obj.position.y,obj.angle.y,50,5000,15000);
if (id==-1){
obj.motionVector.turnToPlayer();
trackingPlayer=true;
return;
}
obj.watch.stop();
obj.event.chain(5,'leitShoot');
}
function leitShoot(obj)
{
obj.motionAngle.turnStop();
obj.model.animation.start('Fire');
obj.event.chain(20,'leitFireProj');
}
function leitFireProj(obj);
{
obj.weapon.fire('Christalli Beam',0);
obj.event.chain(4,'leitFireEnd');
}
function leitFireEnd(obj)
{
leitWatch(obj,subEvent);
}
function leitDamageStart(obj,tick)
{
var health,pauseCount;
health=obj.health.current;
if (health<=0) return;
// if (lastHit>tick) return;
// lastHit=tick+600
obj.event.clearChain();
obj.model.lit=DIM3_MODEL_LIT_VERTEX;
obj.model.animation.start('Hit');
spawn.particle
(obj.hitPosition.x,obj.hitPosition.z,obj.hitPosition.y,'Leit Blood')
obj.motionVector.stop();
obj.motionAngle.turnStop();
obj.event.chain(pauseCount,'leitDamageDone');
}
function leitDamageDone(obj,tick)
{
leitWatch(obj,subEvent);
}
function leitDie(obj)
{
obj.model.animation.start('Die');
obj.event.clearChain();
obj.event.clearWait();
obj.motionVector.stop();
obj.setting.contact=false;
obj.model.on=false
}
function event(obj,mainEvent,subEvent,id,tick)
{
switch (mainEvent)
{
case DIM3_EVENT_CONSTRUCT:
leitConstruct(obj);
return;
case DIM3_EVENT_SPAWN:
leitSpawn(obj);
return;
case DIM3_EVENT_DIE:
leitDie(obj);
return;
case DIM3_EVENT_DAMAGE:
leitDamageStart(obj,tick);
return;
case DIM3_EVENT_WATCH:
leitWatch(obj,subEvent);
return;
}
}
.