dim3 Forum

Full Version: Gatsi No Shoot :(
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Why doesn't it shoot?

Code:
var lastCrashTick;

var lastAngleY;

var smokeCount;

var damageLevel;

var lastDamageTick;



function Construct(obj)

{

    obj.model.on=true;

    obj.model.name='Gatsi';

    obj.model.lit=DIM3_MODEL_LIT_VERTEX;



    obj.model.shadow.on=true;
    obj.model.shadow.alwaysInAir=true;        



    obj.setting.damage=true;

    obj.setting.invincible=false;

    obj.setting.turnOnlyWhenMoving=false;

    obj.setting.restrictPlayerTurning=true;

    obj.setting.quickReverse=false;

    obj.setting.sideStep=false;

    obj.setting.singleSpeed=true;

    obj.setting.bumpUp=true;
    obj.setting.ignorePickUpItems=true;
    obj.setting.find=false;    



    obj.size.x=2800;

    obj.size.z=5600;

    obj.size.y=1900;

    obj.size.weight=2000;

    

    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=0.5;

    obj.objectSpeed.bumpHeight=500;

    

    obj.look.upAngle=5;

    obj.look.downAngle=45;

    

    lastCrashTick=0;

    lastAngleY=0;

    smokeCount=0;

    damageLevel=0;

    lastDamageTick=0;

    obj.look.effectWeapons=true;

    obj.health.start=500;
    obj.health.maximum=500;
    obj.weapon.add('Gatsi Push Power');

}



function Animation(obj,subEvent)

{    

    switch (subEvent) {

    

        case DIM3_EVENT_ANIMATION_OBJECT_STOP:

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

            return;



        case DIM3_EVENT_ANIMATION_OBJECT_WALK:

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

            return;

            

        case DIM3_EVENT_ANIMATION_OBJECT_WALK_BACK:

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

            return;



    }

}



function Enter(obj)

{    
    obj.setting.find=true;

    camera.state.save();

    obj.model.animation.startThenChange('SwitchOn','On');

    obj.setting.fly=true;    

        

    camera.setting.type=DIM3_CAMERA_TYPE_CHASE;
    

    camera.chase.distance=10500;

    camera.chase.trackSpeed=0.1;

    

    camera.chaseAngle.x=0;

    camera.chaseAngle.y=0;

    camera.chaseAngle.z=0;

        

    camera.chaseSlop.y=25;

}


function Exit(obj)

{        
    obj.setting.find=false;

    camera.state.restore();

        

    obj.model.animation.startThenChange('SwitchOff','Off');

}



function EnterOrExit(obj,subEvent)

{        

    switch (subEvent) {

    

        case DIM3_EVENT_VEHICLE_ENTER:

            Enter(obj);

            break;

            

        case DIM3_EVENT_VEHICLE_EXIT:

            Exit(obj);

            break;

            

    }

}



function Collide(obj,tick)

{

    if (!obj.status.moving) return;



    if (tick>lastCrashTick) {

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

        lastCrashTick=tick+800;

    }
}



function Damage(obj,tick)

{
    var health;


    health=obj.health.current;

    if (health<=0) return;

}

function Die(obj)
{
    obj.setting.find=false;
    obj.setting.contact=false;
    obj.model.on=false;

    camera.state.restore();    

    obj.model.animation.start('Die');
}



function Fire(obj,subEvent)

{    

    if ((subEvent!=DIM3_EVENT_WEAPON_FIRE_DOWN) && (subEvent!=DIM3_EVENT_WEAPON_FIRE_REPEAT)) {

        weap.fire.cancel();

        return;

    }

    weap.model.animation.startThenChange('Fire','On');
    obj.weapon.fire('Gatsi Push Power',0);

}



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

{

    switch (mainEvent) {

    

        case DIM3_EVENT_CONSTRUCT:

            Construct(obj);

            return;

    

        case DIM3_EVENT_SPAWN:

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

            return;

            

        case DIM3_EVENT_COLLIDE:

            Collide(obj,tick);

            Damage(obj,tick);

            return;

        case DIM3_EVENT_DAMAGE:

            Damage(obj,tick);

            return;

        case DIM3_EVENT_DIE:

            Die(obj);

            return;



        case DIM3_EVENT_TOUCH:

            Collide(obj,tick);

            return;

            

        case DIM3_EVENT_ANIMATION_OBJECT:

            Animation(obj,subEvent);

            return;



        case DIM3_EVENT_VEHICLE:

            EnterOrExit(obj,subEvent);

            return;

            

        case DIM3_EVENT_WEAPON_FIRE:

            Fire(obj,subEvent);

            return;

    }

}

Sad ?
Chainfist Wrote:
Code:
    if ((subEvent!=DIM3_EVENT_WEAPON_FIRE_DOWN) && (subEvent!=DIM3_EVENT_WEAPON_FIRE_REPEAT)) {
Generally that only appears in player scripts... er...
....Wait... this is a vehicle? You should have mentioned that.
I'm not really sure... for one thing, is the weap.fire.cancel(); in the fire subevent really necessary? I think return will get the effect. Though that wouldn't affect it not shooting.
When you get in this vehicle its in 3rd person right? So this bit:
Code:
weap.model.animation.startThenChange('Fire','On');
Won't do anything, you'll need to put the weapon as a mesh of the vehicle, and call an obj.model animation. Though still, that shouldn't keep it from actually firing the weapon. I don't know.
What is this, a vehicle of some sort? And, the most IMPORTANT thing which people seem to forget Smile, is there any ERRORS in the console when you start the map (and the object gets loaded) or when you FIRE?

When developing your game, always have the console set to open on errors (in your setup.xml, in your documents folder.) Without this any number of non-fatal script errors will never be caught.

For instance, this:

Code:
weap.model.animation.startThenChange('Fire','On');

Is obviously a syntax error, it's talking about the variable "weap" which is not defined in this script. That's some code which should go in the weapon script.

[>] Brian
tis' a vehicle and there are no errors in the console window.
There should be! Make sure it's turned on, maybe you can somehow open it when errors are turned off.... Try opening the console app.
Chainfist Wrote:tis' a vehicle and there are no errors in the console window.

Weird, maybe it got broke, I'll have to check it. That's definitely a syntax error, though. Does removing that line make it shoot?

[>] Brian
Reference URL's