dim3 Forum

Full Version: Why do these not work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
First, here is a cruise rocket, similar to the long range homing missles in EV Override. On launch it is supposed to play the "Launch" animation and then goes into the "IdleAni" animation. It should be homing on "Bot" types.

The rocket spawns and flys and all, there are no error messages. But 1) the "Launch" animation is maybe not played. That animation is in the Cruise Rocket model, it's 1,5 sec long and produces red particles. Same particle works for ship engines, so that's not the problem. Later it does not go into the "IdleAni" which produces a grey trail particle. That one again works on other particles.
2) It does not home on "Bot" types. In my test map there is a Rocket Turret which is a Bot, which works. Don't know why it does not home in on it. If I make the Cruise Rocket home on "Objects" I can hurt myself, maybe that's a sign that it works in general.

Code:
// ***********************************************************
//
// Projectile: Cruise Rocket
//
// ***********************************************************

function Construct(proj)
{
        // models
        
    proj.model.on=true;    
    proj.model.name="CruiseRocket";
    proj.model.rotate.z=10;
    
        // hit scan type projectile
        
    proj.setting.hitScan=false;    
    
        // light
        
    proj.model.light.on=true;
    proj.model.light.intensity=2800;
    
    proj.model.lightColor.red=1;
    proj.model.lightColor.green=0.2;
    proj.model.lightColor.blue=0;
    
        // speed
        
    proj.speed.maxHitScanDistance=200000;
    proj.speed.speed=180;
    proj.speed.deceleration=0;
    proj.speed.decelerationWait=0;
    
    proj.size.weight=0;
    
    proj.size.x=143; // 83; // ;
    proj.size.z=485; // 1032; // 153; // ;
    proj.size.y=143; // 143; // ;
    
        // the damage
        
    proj.action.damage=300;
    proj.action.autoHitTick=24000;
    proj.action.collision=true;
    
    proj.melee.strikeBoneTag='cent';
    proj.melee.strikePoseName='Idle';
    proj.melee.radius=2500;
    proj.melee.damage=15;
    proj.melee.force=40;
    proj.melee.lifeTick=500;

        // no decal
}

function Hit(proj)
{
//    spawn.particle(proj.position.x,proj.position.z,proj.position.y,'Yellow Cannon Hit');
    proj.melee.spawnFromProjectileBone();
    proj.model.animation.start('Explosion');    
    proj.action.destroy();
}

//
// projectile spawn
//

function Timer(proj,tick)
{
        // is it locked on?
        
    if (lockId!=-1) {
        proj.action.seek(lockId,10,15);
        return;
    }
    
        // find something to lock on
        
    if (!map.setting.multiplayer) {
        lockId=map.object.nearest(proj.position.x,proj.position.z,proj.position.y,null,'Bot',null,null,0,20000);
    }
    else {
        lockId=map.object.nearestRemotePlayer(proj.position.x,proj.position.z,proj.position.y,null,null,null,0,20000);
    }
}

function Spawn(proj)
{
    proj.model.animation.startThenChange('Launch','IdleAni');
//    proj.model.animation.start('IdleAni');
    spawn.particle(proj.origin.x,proj.origin.z,proj.origin.y,'Small Dark Smoke Ring');
//    sound.play('Alien1_Cannon',proj.position.x,proj.position.z,proj.position.y,1.25);
}

//
// events
//

function event(proj,mainEvent,subEvent,eventId,tick)
{
    switch (mainEvent) {
    
        case DIM3_EVENT_CONSTRUCT:
            Construct(proj);
            return;
            
        case DIM3_EVENT_TIMER:
            missileTimer(proj,tick);
            return;
            
        case DIM3_EVENT_HIT:
            Hit(proj);
            return;
            
        case DIM3_EVENT_SPAWN:
            Spawn(proj);
            return;
    }
}
This one does also not work, it is a turret from the "I need a turrent" thread.

There are no error messages, the object is a "Bot", it does plain nothing.

Code:
//  -----------------
//
//  Rocket Turret
//

var fire=false;

function Construct(obj)
{        
    obj.model.on=true;
    obj.model.name='Human Rocket Sat';
    obj.model.truform=true;
    obj.model.shadow.on=true;

    obj.setting.suspend=true;
    
    obj.size.x=1974;
    obj.size.z=1356;
    obj.size.y=528;
    obj.size.weight=250;
        
    obj.weapon.add('Cruise Rocket L');
}

function Spawn(obj)
{
Change(obj);
}

function Change(obj,subEvent,id)
{
    if ((subEvent==DIM3_EVENT_MESSAGE_FROM_SCRIPT) && (id==2)) {
        fire=true;
        obj.event.startTimer(3,6);
    }
        
    if ((subEvent==DIM3_EVENT_MESSAGE_FROM_SCRIPT) && (id==1)) {
        fire=false;
    }
}
    
function Fire(obj)
{
    if (fire==true) {
        obj.weapon.fire('Cruise Rocket L',0);
    }
    
    if (fire==false) {
        obj.event.clearTimer();
    }
}

function event(obj,mainEvent,subEvent,id,tick)
{
    switch (mainEvent) {

        case DIM3_EVENT_CONSTRUCT:
            Construct(obj);
            return;
    
        case DIM3_EVENT_SPAWN:
            Spawn(obj);
            return;
            
        case DIM3_EVENT_MESSAGE:
            Change(obj,subEvent,id);
            return;

        case DIM3_EVENT_TIMER:
            Fire(obj);
    }
}
It might be easier for me to debug this if I had a copy of your project -- is that possible for me to get?

[>] Brian
Hm OK I will write you an e-mail.
Reference URL's