dim3 Forum

Full Version: Airplane script
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
thx that helps but there isn't any sound called audi horn? and how could if I can change the horn sound to a weapon firing.
Ok the plane still drives like the audi and doesn't take off. more recent pictures. (still messing with the camer.)

[Image: picture9jx8.th.png]
[Image: picture10mz0.th.png]
This is how it looks now

Code:
var lastCrashTick;

var lastAngleY;

var smokeCount;

var damageLevel;

var lastDamageTick;



function airplaneConstruct(obj)

{

    obj.model.on=true;

    obj.model.name='airplane';

    obj.model.lit=DIM3_MODEL_LIT_VERTEX;



    obj.model.shadow.on=true;

    obj.model.shadow.alwaysInAir=true;        // force shadow to always be under plane



    obj.setting.damage=true;
    obj.setting.fly=true

    obj.setting.invincible=false;

    obj.setting.turnOnlyWhenMoving=true;

    obj.setting.restrictPlayerTurning=true;

    obj.setting.quickReverse=false;

    obj.setting.sideStep=false;

    obj.setting.jump=false;

    obj.setting.duck=false;

    obj.setting.singleSpeed=true;

    obj.setting.bumpUp=true;



    obj.size.x=2800;

    obj.size.z=5600;

    obj.size.y=1900;

    obj.size.weight=0;

    

    obj.rigidBody.on=true;



    obj.vehicle.on=true;

    

    obj.turnSpeed.facingWalk=1.5;

    obj.turnSpeed.motionWalk=0.6;

    obj.turnSpeed.facingAir=3;

    obj.turnSpeed.motionAir=3;

    

    obj.forwardSpeed.walk=250;

    obj.forwardSpeed.acceleration=0.5;

    obj.forwardSpeed.deceleration=1.75;

    obj.forwardSpeed.accelerationAir=0.4;

    obj.forwardSpeed.decelerationAir=0.6;

    

    obj.objectSpeed.bounceFactor=1.3;        // this makes the audi bounce off when hitting things

    obj.objectSpeed.bumpHeight=500;

    

    obj.look.upAngle=5;

    obj.look.downAngle=10;

    obj.health.maximum=200;
    obj.health.start=200;

    

        // headlight

        

    obj.model.light.on=true;

    obj.model.light.type=DIM3_LIGHT_TYPE_NORMAL;

    obj.model.light.intensity=16000;

    

    obj.model.lightColor.red=1;

    obj.model.lightColor.green=1;

    obj.model.lightColor.blue=0.8;



        // the car engine ambient

            

    obj.setting.setAmbient('Car Engine',1);

    

    lastCrashTick=0;

    lastAngleY=0;

    smokeCount=0;

    damageLevel=0;

    lastDamageTick=0;

}



//

// car animations

//



function airplaneAnimation(obj,subEvent)

{

    var            model;

    

    model=obj.model;

    

    switch (subEvent) {

    

        case DIM3_EVENT_ANIMATION_OBJECT_STOP:

            model.animation.change('Idle');

            return;



        case DIM3_EVENT_ANIMATION_OBJECT_WALK:

            model.animation.change('fly');

            return;

            

        case DIM3_EVENT_ANIMATION_OBJECT_WALK_BACK:

            model.animation.change('fly');

            return;



    }

}

//
// car in liquids
//

function airplaneLiquid(obj)

{

    sound.play("Splash",obj.position.x,obj.position.z,obj.position.y,1);

}



//

// car timer

//



function airplaneTimer(obj)

{

    var        speed,pitch,smoke,pnt;

    

        // engine sound

    

    speed=obj.status.speed;

    pitch=1.0;

    

    if (speed<20) {

        pitch=1.0;

    }

    else {

        if (speed>=150) {

            pitch=1.5;

        }

        else {

            pitch=1+(0.5*((speed-20)/130));

        }

    }

    

    obj.setting.changeAmbientPitch(pitch);

    

        // time to start smoking?

      

    if (speed!=0) {

        if (utility.angle.dif(obj.angle.y,lastAngleY)>12) smokeCount=5;

    }

    if ((speed>0) && (speed<100)) smokeCount=10;

    

    lastAngleY=obj.angle.y;

    

        // smoke

        

    if (smokeCount!=0) {

        smokeCount--;

        

        pnt=obj.model.bone.findPosition(null,'BOdy');

        spawn.particle(pnt.x,pnt.z,pnt.y,'Car Smoke');

        pnt=obj.model.bone.findPosition(null,'BOdy');

        spawn.particle(pnt.x,pnt.z,pnt.y,'Car Smoke');

    }

}



//

// entering and exiting auti

//



function airplaneEnter(obj)

{

        // backup the original camera

        

    camera.state.save();

        

        // change camera for airplane

        

    camera.setting.type=DIM3_CAMERA_TYPE_CHASE;

    

    camera.chase.distance=10500;

    camera.chase.trackSpeed=0.1;

    

    camera.chaseAngle.x=-50;

    camera.chaseAngle.y=45;

    camera.chaseAngle.z=50;

        

    camera.chaseSlop.y=25;

    

        // start a timer for engine noise

        

    obj.event.startTimer(1,0);

}



function airplaneExit(obj)

{

        // turn off the engine noise timer

        

    obj.event.clearTimer();

    

        // restore camera

        

    camera.state.restore();

    

        // make sure animation is idling

        

    obj.model.animation.change('Running');

}



function airplaneEnterOrExit(obj,subEvent)

{

        // door sound

        

//    sound.play("Car Door",obj.position.x,obj.position.z,obj.position.y,1);



        // start or stop changes

        

    switch (subEvent) {

    

        case DIM3_EVENT_VEHICLE_ENTER:

            airplaneEnter(obj);

            break;

            

        case DIM3_EVENT_VEHICLE_EXIT:

            airplaneExit(obj);

            break;

            

    }

}



//

// car colliding with map or object

//



function airplaneCollide(obj,tick)

{

        // if car isn't moving, then no collide effects



    if (!obj.status.moving) return;



        // car hit sound



    if (tick>lastCrashTick) {

        sound.play("Crash",obj.position.x,obj.position.z,obj.position.y,0.7);

        lastCrashTick=tick+800;

    }



        // turn on the smoke

        

    smokeCount=20;

}



//

// car taking damage when colliding with wall

//



function airplaneDamage(obj,tick)

{



        // max damage level is 2



    if (damageLevel==2) return;



        // only take damage at certain rates



    if (tick<lastDamageTick) return;



    lastDamageTick=tick+2000;



        // change for damage



    damageLevel++;



    switch (damageLevel) {



        case 1:        // break window

            obj.model.fill.change(1,1);

            break;

        case 2:        // damage body

            obj.model.fill.change(0,1);

            break;



    }

}



//

// car horn

//



function airplaneCarHorn(obj,subEvent)

{

        // if no weapon selected, then all fire messages come directly to object

        // only check for fire message

    

    if (subEvent==DIM3_EVENT_WEAPON_FIRE_DOWN) sound.play("Car Horn",obj.position.x,obj.position.z,obj.position.y,1);

}



//

// events

//



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

{

    switch (mainEvent) {

    

        case DIM3_EVENT_CONSTRUCT:

            airplaneConstruct(obj);

            return;

    

        case DIM3_EVENT_SPAWN:

            obj.model.animation.start("Idle");

            return;

            

        case DIM3_EVENT_COLLIDE:

            airplaneCollide(obj,tick);

            airplaneDamage(obj,tick);

            return;



        case DIM3_EVENT_TOUCH:

            airplaneCollide(obj,tick);

            return;

            

        case DIM3_EVENT_ANIMATION_OBJECT:

            airplaneAnimation(obj,subEvent);

            return;
            

        case DIM3_EVENT_LIQUID:

            airplaneLiquid(obj);

            return;



        case DIM3_EVENT_VEHICLE:

            airplaneEnterOrExit(obj,subEvent);

            return;

            

        case DIM3_EVENT_WEAPON_FIRE:

            airplaneCarHorn(obj,subEvent);

            return;

            

        case DIM3_EVENT_TIMER:

            airplaneTimer(obj);

            return;



    }

}
I think I know why it doesn't work. Do i have to add some sort of air speed?
Oh, I think I know. Try using the up and down keys (set them in the options menu) to move up and down instead of the mouse.
The inputs probably on the wrong mode. Smile
Just a little note: Please put the scripts in a download file, my fingers are tired from scrolling.
Ok well I'm done with the project so it's all good. And even if I do put it in a download file you will still have to scroll.
shooks: He meant he was tired of scrolling through the whole script just to see the post after it. Wink
DON'T do that though.
Get a free web page, do this
link
then you don't have to download it, but you don't have to scroll through it if you don't want to see it.
Or he can use http://dim3.pastebin.com eh?
Pages: 1 2 3
Reference URL's