Welcome New User Home | Forums | Register | Login | Larger Font
Main-Menu
Home
Login
Register
Add Download
Add News
Forums

Advertise
Affiliate Store US *
Affiliate Store UK *
Affiliate Store CA *
Angry Letter Generator
Avatar Upload
Calendar of Games
Contact
Downloads
FAQs
Forums
Member List
Member Projects
News
News Grabber *
Policy
Polls
Private Messages
Reviews
Screenshot Gallery
Search
Servers - Game
Store - Shirts *
Subscribe
Topics
Tutorials
Weblinks
Tutorials
CoD Mapping
CoDUO Mapping
CoD2 Mapping
CoD4 Mapping
CoD FAQs
HL2 Mapping
HL2 FAQs
SOF1 Mapping
Crysis Mapping
Q4 Mapping
Doom 3 Mapping
Doom 3 FAQs
UT2K3 Mapping
SOF2 Mapping
SOF2 FAQs

Lightray Modeling
General Modeling
General Modding
Adobe Photoshop
Common Mapping Errors

Readme.txt Generator
Members-Online
foxteamfr [Searc]
xisko [Forum]
DeekCiti [Forum]
LPRay [Forum]
anoosMonkey [Today]
nielsini [Forum]
NovemberDo... [Forum]
Lieutenant... [Tutor]
Decepter [Downl]
KilLjoY [Forum]
F-Plus [Downl]

11 Members and 21 Guests
Chat MODSonline
0 People Now Chatting
MODSOnline TeamSpeak

download TeamSpeak

In-The-News
Friday, May. 16th
Video games 'do not' encourage violence
Friday, May. 16th
Site update
Friday, May. 16th
MODSonair Episode 127
Tuesday, May. 13th
Web hosting, you need?
Sunday, May. 11th
MODSonair 127 Live
Latest Poll
Would you subscribe for a maps/projects backup utility and service?
I'd pay just about anything for that. 2.06%
If it was cheap enough I would. 4.12%
Only if it came with my MODSonline subscription. 6.19%
I can backup my own files. 82.47%
Why would I backup my files? 5.15%
Read More...
8 comments

Newsletter
Name:
Email:
Newsletter Archives
Your Membership
User Name:
Password:
Register.
In The Forums
lm_0000
SoFII Editing, G.. Posts: (1) Views: (1) by nielsini
Anyone up for a new project?
CoD 4 Level Desi.. Posts: (1) Views: (12) by xisko
Kill3r's K3 MOD is DANGEROUS TO YOU AND YOUR S...
CoD4 General Gam.. Posts: (18) Views: (258) by NovemberDobby
just another question
DOOM III Level D.. Posts: (1) Views: (7) by the_mercenary
Treyarch SPLITREASON.COM - Gear for Geeks and GamersBuy geek and gamer themed T-Shirts and Hats @ SplitReason.com!
Tutorials: CoDUO Mapping
Mapping and modding for Call of Duty United Offensive.

Rating:
Aweful Rating Poor Rating Average Rating Good Rating Excellent Rating
Adding destroyable crates in SP or MP maps
2007-02-13 08:14:01
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....
maps\mp\_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

All logos and trademarks and information in this site are property of MODSonline LLC © 2008.
The comments are property of their posters.
RSS news feeds for MODSonline.com can be found News.php.
MODSonline Subscriptions
Partners
The Firing Box
Half-Life 2 Mods for Dummies
mp_carpark
Battle for Europe COD2
Call of Duty Headquarters
Quake 4 Mods for Dummies
Frag Universe
modbase.be
Ask About
Advertising
Friends
The Clan Database
Canada Kicks Ass Clan
SOF2 Files and Downloads
Ask About
Advertising
Link to Us
MODSonair
View in iTunes
Please help us to raise in the ranks of podcasting and subscribe to our itunes feed using the link above.
MODSonair Releases
MODSonair Episode 127
MODSonair Episode 126
MODSonair Episode 125
MODSonair Episode 124
MODSonair Episode 123
Copyright © 2008 MODSonline
Tresware Content Management System Copyright © 2008 Tresware
Website Designed and Hosted   Tresware