Alright.
So this morning I was working on a gib script inside JS. Let me show it to you. (FYI it's a two part script.) EDIT: It's a three part script!
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>// ***********************************************************
//
// OBJECT: Drum
//
// A simple script to setup a cliche drum. When taking damage,
// the drum changes it's animation to bend, then eventually
// explodes like all good FPP drums do.
//
// ***********************************************************
// variables
function stateBase()
{
this.bendLevel=0;
}
var state=new stateBase();
function drumConstruct(obj)
{
obj.model.on=true;
obj.model.name="Drum";
obj.model.shadow.on=true;
obj.setting.damage=true;
obj.setting.invincible=true;
obj.weapon.add('Gib');
// script will do all damage calculations
obj.setting.pushable=true;
obj.setting.ignorePickUpItems=true;
obj.size.x=1200;
obj.size.z=1200;
obj.size.y=2000;
obj.size.weight=250;
state.bendLevel=0;
}
function bendDrum(obj)
{
var x,z,y;
x=obj.hitPosition.x;
z=obj.hitPosition.z;
y=obj.hitPosition.y;
// particle and sound damage
spawn.particle(x,z,y,'');
spawn.particle(x,z,y,'');
sound.play("Crash",x,z,y,(0.8-(state.bendLevel*0.15)));
// bending animation
obj.model.animation.start('Bend '+state.bendLevel);
}
function destroyDrum(obj)
{
var x,z,y;
// remove object
obj.setting.hidden=true;
obj.setting.contact=false;
obj.setting.damage=false;
x=obj.position.x;
z=obj.position.z;
y=obj.position.y-(obj.size.y/2);
// sounds and effects
sound.play("Explosion",x,z,y,1);
spawn.flash(x,z,y,1,0,0,150,250,250);
spawn.shake(x,z,y,30000,30,600);
obj.weapon.fire('Gib');
// the push
spawn.push(x,z,y,5000,20,100);
// the drum pieces
spawn.particle(x,z,y,'');
spawn.particle(x,z,y,'');
// particles
}
function damageDrum(obj)
{
state.bendLevel++;
if (state.bendLevel==4) {
destroyDrum(obj);
return;
}
bendDrum(obj);
}
//
// events
//
function event(obj,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
drumConstruct(obj);
return;
case DIM3_EVENT_DAMAGE:
damageDrum(obj);
return;
}
}
</div>
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>// ***********************************************************
//
// WEAPON: Gib
//
// ***********************************************************
//
// Gib weapon construction
//
function gibWeaponConstruct(weap)
{
// projectile setup
weap.projectile.objectFireBoneTag='Mid'; //name of your "blood bone"
weap.projectile.objectFirePoseName='Bent 3'; //the death animation
// the projectile
weap.projectile.add('gib');
weap.projectile.add('gib1'); //the name of your gib projectile
}
//
// gib spawn
//
function gibWeaponFire(weap,subEvent,tick)
{
// spawn projectiles
// This functions spawns three gib projectiles at a -90° x angle and at random Y and Z angles.
// Depending on the effect you want to create, one image could be enough. You will also have to use different
// angle values, depending on your animation.
weap.projectile.spawnFromObjectBoneOffsetAngle('gib',-90,utility.random.getInteger(-20,20),utility.random.getInteger(-20,20));
weap.projectile.spawnFromObjectBoneOffsetAngle('gib1',-90,utility.random.getInteger(-20,20),utility.random.getInteger(-20,20));
weap.projectile.spawnFromObjectBoneOffsetAngle('gib',-90,utility.random.getInteger(-20,20),utility.random.getInteger(-20,20));
}
//
// events
//
function event(weap,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
gibWeaponConstruct(weap);
return;
case DIM3_EVENT_WEAPON_FIRE:
gibWeaponFire(weap,subEvent,tick);
return;
}
}</div>
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>// ***********************************************************
//
// PROJECTILE: Gib
//
// ***********************************************************
//
// gib construction
//
function gibConstruct(proj)
{
// hit scan type projectile
proj.setting.hitScan=true;
// speed
proj.speed.maxHitScanDistance=150000;
proj.action.damage=0; //no damage
proj.action.collision=true;
// model
proj.model.on=true;
proj.model.name="DrumDebris";
proj.setting.resetAngle=true;
}
//
// gib hit
//
function gibHit(proj)
{
}
//
// events
//
function event(proj,mainEvent,subEvent,eventId,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
gibConstruct(proj);
return;
case DIM3_EVENT_HIT:
gibHit(proj);
return;
}
}</div>
Someone tell me what went wrong?
So this morning I was working on a gib script inside JS. Let me show it to you. (FYI it's a two part script.) EDIT: It's a three part script!
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>// ***********************************************************
//
// OBJECT: Drum
//
// A simple script to setup a cliche drum. When taking damage,
// the drum changes it's animation to bend, then eventually
// explodes like all good FPP drums do.
//
// ***********************************************************
// variables
function stateBase()
{
this.bendLevel=0;
}
var state=new stateBase();
function drumConstruct(obj)
{
obj.model.on=true;
obj.model.name="Drum";
obj.model.shadow.on=true;
obj.setting.damage=true;
obj.setting.invincible=true;
obj.weapon.add('Gib');
// script will do all damage calculations
obj.setting.pushable=true;
obj.setting.ignorePickUpItems=true;
obj.size.x=1200;
obj.size.z=1200;
obj.size.y=2000;
obj.size.weight=250;
state.bendLevel=0;
}
function bendDrum(obj)
{
var x,z,y;
x=obj.hitPosition.x;
z=obj.hitPosition.z;
y=obj.hitPosition.y;
// particle and sound damage
spawn.particle(x,z,y,'');
spawn.particle(x,z,y,'');
sound.play("Crash",x,z,y,(0.8-(state.bendLevel*0.15)));
// bending animation
obj.model.animation.start('Bend '+state.bendLevel);
}
function destroyDrum(obj)
{
var x,z,y;
// remove object
obj.setting.hidden=true;
obj.setting.contact=false;
obj.setting.damage=false;
x=obj.position.x;
z=obj.position.z;
y=obj.position.y-(obj.size.y/2);
// sounds and effects
sound.play("Explosion",x,z,y,1);
spawn.flash(x,z,y,1,0,0,150,250,250);
spawn.shake(x,z,y,30000,30,600);
obj.weapon.fire('Gib');
// the push
spawn.push(x,z,y,5000,20,100);
// the drum pieces
spawn.particle(x,z,y,'');
spawn.particle(x,z,y,'');
// particles
}
function damageDrum(obj)
{
state.bendLevel++;
if (state.bendLevel==4) {
destroyDrum(obj);
return;
}
bendDrum(obj);
}
//
// events
//
function event(obj,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
drumConstruct(obj);
return;
case DIM3_EVENT_DAMAGE:
damageDrum(obj);
return;
}
}
</div>
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>// ***********************************************************
//
// WEAPON: Gib
//
// ***********************************************************
//
// Gib weapon construction
//
function gibWeaponConstruct(weap)
{
// projectile setup
weap.projectile.objectFireBoneTag='Mid'; //name of your "blood bone"
weap.projectile.objectFirePoseName='Bent 3'; //the death animation
// the projectile
weap.projectile.add('gib');
weap.projectile.add('gib1'); //the name of your gib projectile
}
//
// gib spawn
//
function gibWeaponFire(weap,subEvent,tick)
{
// spawn projectiles
// This functions spawns three gib projectiles at a -90° x angle and at random Y and Z angles.
// Depending on the effect you want to create, one image could be enough. You will also have to use different
// angle values, depending on your animation.
weap.projectile.spawnFromObjectBoneOffsetAngle('gib',-90,utility.random.getInteger(-20,20),utility.random.getInteger(-20,20));
weap.projectile.spawnFromObjectBoneOffsetAngle('gib1',-90,utility.random.getInteger(-20,20),utility.random.getInteger(-20,20));
weap.projectile.spawnFromObjectBoneOffsetAngle('gib',-90,utility.random.getInteger(-20,20),utility.random.getInteger(-20,20));
}
//
// events
//
function event(weap,mainEvent,subEvent,id,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
gibWeaponConstruct(weap);
return;
case DIM3_EVENT_WEAPON_FIRE:
gibWeaponFire(weap,subEvent,tick);
return;
}
}</div>
<div class='codetop'>CODE</div><div class='codemain' style='height:200px;white-spacere;overflow:auto'>// ***********************************************************
//
// PROJECTILE: Gib
//
// ***********************************************************
//
// gib construction
//
function gibConstruct(proj)
{
// hit scan type projectile
proj.setting.hitScan=true;
// speed
proj.speed.maxHitScanDistance=150000;
proj.action.damage=0; //no damage
proj.action.collision=true;
// model
proj.model.on=true;
proj.model.name="DrumDebris";
proj.setting.resetAngle=true;
}
//
// gib hit
//
function gibHit(proj)
{
}
//
// events
//
function event(proj,mainEvent,subEvent,eventId,tick)
{
switch (mainEvent) {
case DIM3_EVENT_CONSTRUCT:
gibConstruct(proj);
return;
case DIM3_EVENT_HIT:
gibHit(proj);
return;
}
}</div>
Someone tell me what went wrong?