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

Members Online

»
0 Active | 9 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty
Category: CoDUO Mapping
CoD United Offensive mapping and level design.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: [TUTE] Destroyable Crates with physics and sound system for UO
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoDUO Mapping
Posted: Tuesday, Feb. 13, 2007 10:35 am
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
Share |
supersword
General Member
Since: Jul 28, 2004
Posts: 1989
Last: Nov 22, 2011
[view latest posts]
Level 8
Forum Moderator
Im a fan of MODSonair
Category: CoDUO Mapping
Posted: Tuesday, Feb. 13, 2007 10:47 am
Cool.. a new tutorial! Would it be ok that we add this tutorial into our tutorial section?

If so I will flag it up with foyleman (I can't add images to tutorials) and hopefully he can get it up.

Cheers.
Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoDUO Mapping
Posted: Tuesday, Feb. 13, 2007 11:27 am
For sure mate, better there than slowly dropping down the thread ladder on the forum. [thumbs_up]

Grassy
Share |
foyleman
Preferred PLUS Member
Since: Nov 7, 2001
Posts: 95762
Last: Apr 13, 2021
[view latest posts]
Level 10
Admin
Forum Moderator
Im a fan of MODSonair
Im a HOST of MODSonair
Category: CoDUO Mapping
Posted: Tuesday, Feb. 13, 2007 01:14 pm
It's posted. Thanks.
Go ahead... You Play I Mod : Support Modsonline by becoming a PREFERRED MEMBER today!
Have you heard the MODSonair Podcast?:
MODSonair is a weekly podcast bringing you the news from a modders perspective.
Tune in every Sunday at 12pm EST to listen LIVE.
Quake 4 Mods for Dummies - Half-Life 2 Mods for Dummies
Share |
UnclePhil
Preferred PLUS Member
Since: Aug 22, 2006
Posts: 171
Last: Jan 2, 2011
[view latest posts]
Level 4
Category: CoDUO Mapping
Posted: Tuesday, Feb. 13, 2007 06:40 pm
LOL great stuff! . . . .just hope the crates are not beer supplies Grassy[wink], well done and good job as per usual

Phil.
Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoDUO Mapping
Posted: Wednesday, Feb. 14, 2007 01:24 am
LOL Thanks guys. I got the idea after drinking all the beer and was wondering what to do with the empty crates. [drink]
Grassy
Share |
mercilessrangeradam
General Member
Since: Aug 18, 2006
Posts: 82
Last: Mar 7, 2008
[view latest posts]
Level 3
Category: CoDUO Mapping
Posted: Wednesday, Feb. 14, 2007 04:34 am
awsome tut, works a treat in my factory map :)
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoDUO Mapping
Posted: Wednesday, Feb. 21, 2007 11:14 am
lol, cod with physics!

hmm... how bout players being able to push stuff around... [crazy]
Share |
.KiLL3R.
General Member
Since: Oct 26, 2006
Posts: 1437
Last: Jul 3, 2017
[view latest posts]
Level 8
Category: CoDUO Mapping
Posted: Wednesday, Feb. 21, 2007 12:19 pm
soz double post, be cool if thay stayed and you could keep shotin and bashin them around
[crazy]
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty : CoDUO Mapping

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

»