Call of Duty 5: Destroyable Barricades

From COD Modding & Mapping Wiki
Revision as of 02:48, 9 March 2011 by Zeroy (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Target: Allow mappers to create dynamic destroyable barricades on their maps

Video Example:

<videoflash>Hxu8gbG7woE</videoflash>

Prior version (gravity was minor, but it's useful as a sample):

<videoflash>Y7XgfY1_xHg</videoflash>

Preperation

  • Download Files HERE
  • Download all attached files and copy them onto your raw directory, following this structure:
raw/xmodel/zweimann_sandbag
raw/physic/zweiphys
raw/maps/mp/_dynamic_barricades.gsc
  • Adding Dynamic Barricades Files to your zone_source/<yourmapname>.csv file
  • Open your zone source file and add these lines:
// Zweimann Dynamic Barricades
xmodel,zweimann_sandbag
physpreset,zweiphys
rawfile,maps/mp/_dynamic_barricades.gsc
fx,temp_effects/fx_tmp_bullet_impact_dirt_generic


Mapping

  • Open your map in Radiant. Create your one-by-one sandbag ( MISC > MODEL ) barricade using zweimann_sandbag xmodel (previously copied to raw/xmodels). No clipping or make collidable is needed.
  • Before duplicating your sandbag, press N and enter the following data:
classname: script_model
targetname: erm_des_sb

Leave angles and origin untouched.



  • Threading Dynamic Barricades
  • Open your raw/maps/mp/<yourmapname>.gsc file, and before the closing "}", add this line:
maps\mp\_dynamic_barricades::init();

As on this example:

main()
{

    maps\mp\_load::main();
    setExpFog(300, 1400, 0.9, 0.9, 0.7, 0.0);


  maps\mp\_dynamic_barricades::init();

}


Step 5: Compile and enjoy

If you're interested on how easily this was made, take a look at the code here:

// Zweimann's Dynamic and Destroyable Barricades
// Enjoy this simple code
// Contact: zweimann @ helipollos . es
// http://www.helipollos.es
// http://www.mappersunited.com
init()
{
    // Preload FX
    level.zsbsfx =  loadfx("temp_effects/fx_tmp_bullet_impact_dirt_generic");
    // Get Sandbags entities array
    level.sbs = getEntArray( "erm_des_sb", "targetname" );

    // Init collision array
    level.col = [];

    // Thread every found entity
    for ( i = 0; i < level.sbs.size; i++ )
    {
        // Spawn Collision for every sandbag
        level.col[i] = spawncollision( "collision_geo_32x32x10",  "collider", level.sbs[i].origin, level.sbs[i].angles );

        // Thread Damage Detection
        level.sbs[i] thread dyn_env_threads( level.col[i] );
    }

}

dyn_env_threads( collider )
{
    level endon("game_ended");
    self endon("destroyed");

    // Sandbag is damageable now
    self setcandamage(true);

    while ( isDefined( self ) )
    {
        self waittill("damage", damage, attacker, direction_vec,  point, mod);
        damage = damage / 1000;

        // Filter damage MOD to avoid bullet damaging, melee and  impacts
        if ( mod != "MOD_RIFLE_BULLET"
            && mod != "MOD_PISTOL_BULLET"
            && mod != "MOD_MELEE"
            && mod != "MOD_IMPACT" )
        {
            // Fake Damage for upper sandbags
            RadiusDamage( self.origin, 1, 30, 30);

            // Strenght of the physics movement
              velocity = ( damage , damage  , damage  ) ;

              // Random contact point
              y = randomIntRange( 1, 10 );
              if ( y > 5 )
                contactPoint = point + ( randomfloatrange( 0, 30 ),  randomfloatrange( 0, 30 ), 0 );
              else
                contactPoint = point - ( randomfloatrange( 0, 30 ),  randomfloatrange( 0, 30 ), 0 );

            contactPoint = direction_vec;
              // Launch physically modified xmodel
              CreateDynEntAndLaunch( "zweimann_sandbag", self.origin,  contactPoint, point, velocity, level.zsbsfx  );

            // Delete collision fake model
            collider delete();

            // Delete script_model
              self delete();

        }
    }
}


Enjoy!


By Zweimann