Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 10 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Tutorials

»
CoDUO Mapping
ratings:
Awful Rating
Poor Rating
Average Rating
Good Rating
Excellent Rating
Adding destroyable crates in SP or MP maps
Versions: You must be logged in to view history.
Hot of the keyboard tonight is a neat system of adding destroyable crates in SP or MP maps.

Howdy folks,

Hot of the keyboard tonight is a neat system of adding destroyable crates in SP or MP maps.

The script can handle any number of crates from 1 upwards, it will do two anims, one with physics (flying crates!) and one with no flight, both still have a satisfying smash with lots of debris and a beefy wood splintering sound. :-)

Here are a few screen shots to wet your whistles.

xmodel crates; before.


After.


Brushmodel crates (best because they are solid)





Ok now the how to:
Pretty much all the info you need is at the top of the script (please dont chop this info out if you use the script in your maps, others might need the info at some stage)

Here is the main script:
Call this script from main in your maps gsc like so....
mapsmp\_grassycrates::main();


Code:

//_grassycrates.gsc
//------------------------------------------------------------------------------
//----------------------- Destroyable Crates for Cod-Uo -------------------------
//-----------------------                 by                      -------------------------
//-----------------------              Grassy                   -------------------------
//------------------------------------------------------------------------------
//
// Requirements:
// This script needs the custom crate smash fx file, by Grassy.
// You also need to add two sound aliases in your csv.
//
// TRIGGERS:
// Triggers are trigger_damage (one for each crate) Don't forget you need a small
// brush textured with origin as part of the complete trigger!
// ALL triggers must have a targetname of "crate_trig" and the trigger must target
// the crate model.
//
// CRATES:
// You can use normal xmodel crates and make them script_models but they will not
// have a player clip.
// If players are likely to jump on them, then use normal brushes and make them
// script_brushmodels. Don't forget you need a small brush textured with origin
// as part of the complete brushmodel!
// You MUST target the crate from the trigger.
//
// PHYSICS:
// If you want a crate to fly a small distance using physics before it smashes
// then you need to place a script_origin aproximatly 300 units above the crate
// and it can be off to any side of the crate for a sideways arc flight.
// You MUST target the origin from the crate model.
//
// If you just want the crate to smash (no physics flight) then dont place a script_origin
// for that particular crate.
//
// ORDER OF TARGETING:
// With physics:
// [TRIGGER]------------->[CRATE]--------------->[ORIGIN]
//
// No physics, just smash:
// [TRIGGER]------------->[CRATE]
//

main()
{
  //-----------------------
  // Load the custom crate smash efx file
  //-----------------------
  level._effect["crate_exp"] = loadfx ("maps/mp/grassy_smashcrate.efx");
  thread crates_init();
}


crates_init()
{
    trig = getentarray("crate_trig", "targetname");
    if(isDefined(trig))
    {
      if(trig.size > 1)
      {
        for(a = 0 ; a < trig.size ; a++)
        {
          trig[a] thread Smash_Da_Crates();
        }
    }
    if(trig.size == 1)
      trig[0] thread Smash_Da_Crates();
  }
}


Smash_Da_Crates()
{

//-----------------------self = crate_trig
//-----------------------crate = crate model targeted from the trigger
//-----------------------ent = script_origin targeted from the crate model

    crate = getent (self.target,"targetname");
    if (!isdefined (crate))  //no crate? then delete the trigger & exit
    {
    self delete();
    return;
  }

     self waittill("trigger");
 
    ent = getent (crate.target,"targetname");
    if (!isdefined (ent))  //no script_origin? then just play the effect and delete the crate & trigger
    {
        self delete();
      playfx(level._effect["crate_exp"], crate.origin);       
      crate delete();
        return;
    }
   
    org = ent.origin;
    temp_vec = ( org - crate.origin );
    x = (temp_vec[0]);
  y = (temp_vec[1]);
  z = (temp_vec[2]);

  rv = randomfloat(1);
  rot = (90 + randomint(90));
    dir = randomint(6);
 
  switch (dir)
    {
    case 0:    crate rotatePitch(rot,rv) ;  break;
    case 1:    crate rotateRoll(rot,rv) ; break;
    case 2:  crate rotateYaw(rot,rv) ; break;
    case 3:    crate rotatePitch((0-rot),rv) ;  break;
    case 4:    crate rotateRoll((0-rot),rv) ; break;
    default: crate rotateYaw((0-rot),rv) ; break;
    }
   
    delay = randomfloat(1);
    crate moveGravity ((x, y, z), delay);

    wait(delay);
    crate_org = crate getorigin();
    playfx(level._effect["crate_exp"], crate_org);
    crate delete();
    self delete();
    ent delete();
}



You also need to place this custom efx script in maps/mp (same place as your map bsp) name the file "grassy_smashcrate.efx"

Code:

Particle
{
    flags                usePhysics useAlpha
    spawnFlags            orgOnCylinder axisFromSphere
    count                7 15
    life                1000 1500
    cullrange            1000
    bounce                1
    height                15
    rotation            -360 360
    rotationDelta        -92 -32
    velocity            400 44 44 465 -44 -44
    gravity                -600 -300
    rgb
    {
        end                1 0.9843 0.9412
        flags            random linear
    }
    alpha
    {
        end                0
        flags            linear
    }
    size
    {
        start            19 33
        end                33
        flags            linear
    }
    length
    {
        flags            linear
    }
    shaders
    [
        gfx/impact/wood_splinter1
        gfx/impact/wood_splinter2
    ]
}

Sound
{
    sounds
    [
      smash_crate
    ]
}


And finally, you need to add these three lines in your map.csv in
soundaliases directory.
Dont forget the edit the yourmapname at the end of each line to match the name of your map! :)

Code:

#Smashed Crates,,,,,,,,,,,,,,
smash_crate,1,vehicles/crashes/wood_crash01.wav,.8,1.2,0.9,1.05,2500,3600,auto,,,,,yourmapname
smash_crate,2,vehicles/crashes/wood_crash02.wav,.8,1.2,0.9,1.05,2500,3600,auto,,,,,yourmapname



Well that's it, once you do a few crates it's very easy to add more.
I hope you enjoy it, let me know of any improvements you might think of to make it even better.

Regards Grassy

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»