// modified from explo barrels code. // Script version V1.0 // add in your "zone_source" file (sample): /* xmodel,vehicle_small_hatch_blue_destructible_mp xmodel,vehicle_small_hatch_blue_destroyed fx,explosions/large_vehicle_explosion rawfile,maps/mp/test_destructables_car.gsc fx,props/barrel_ignite fx,props/barrel_fire_top */ // Add to your "\raw\maps\mp\mp_yourmapname.gsc /* maps\mp\test_destructables_car::main(); */ /* Add a script model to your level ( samples prefabs in the install folder): sample: // entity 26 { "angles" "0 270 0" "origin" "304.0 416.0 0.0" "targetname" "test_destructables_car" <<<<<<<<<---------- Needed "model" "vehicle_small_hatch_blue_destructible_mp" <<<---------- Needed "classname" "script_model" <<<<<<<<<<---------- Needed "script_noteworthy" "vehicle_small_hatch_blue_destroyed" <<----if empty then key model + "_destroyed" is used ( you need the burned model with this name ). << this key is needed here because models names dont match ( you can put any! model XD ). << the police car , match names, so the prefab dont need this key :) } The model need a bone "tag_hood", if not, edit explodable_car_burn(). */ main() { //------------------ //EFECTS DEFINITIONS //------------------ qExplo = false; eplo = getentarray ("test_destructables_car","targetname"); if ( (isdefined(eplo)) && (eplo.size > 0) ) qExplo = true; if (qExplo) { level.breakables_fx[ "large_vehicle_explosion" ] = loadfx( "explosions/large_vehicle_explosion" ); level.breakables_fx["barrel"]["burn_start"] = loadfx ("props/barrel_ignite"); level.breakables_fx["barrel"]["burn"] = loadfx ("props/barrel_fire_top"); } //----------------- //SOUND DEFINITIONS //----------------- level.barrelExpSound = "explo_metal_rand"; //----------------- //----------------- level.barrelHealth = 250; maxBrokenPieces = 1; //------------- //------------- level.precachemodeltype = []; level.barrelExplodingThisFrame = false; // level.breakables_clip = []; level._breakable_utility_modelarray = []; level._breakable_utility_modelindex = 0; level._breakable_utility_maxnum = maxBrokenPieces; array_thread(getentarray ("test_destructables_car","targetname"), ::explodable_car_think); } getClosestEnt(org, array) { if (array.size < 1) return; dist = 256; ent = undefined; for (i=0;i= dist) continue; dist = newdist; ent = array[i]; } return ent; } explodable_car_think() { if (self.classname != "script_model") return; if (!isdefined(self.model)) return; if(self.model == "") return; if(!isdefined(level.precachemodeltype[self.model] ) ) { level.precachemodeltype[self.model] = true; // level.precachemodeltype["vehicle_small_hatch_blue_destructible_mp"] = true; // precacheModel("vehicle_small_hatch_blue_destroyed"); if (isdefined(self.script_noteworthy)) { if(self.script_noteworthy == "") precacheModel(self.model + "_destroyed"); else precacheModel ( self.script_noteworthy); } else precacheModel(self.model + "_destroyed"); } self endon ("exploding"); self.damageTaken = 0; self setcandamage(true); accumulate = 200; threshold = 0; dmg = 0; for (;;) { self waittill("damage", amount ,attacker, direction_vec, P, type); if(type == "MOD_MELEE" || type == "MOD_IMPACT") continue; if( amount < threshold ) continue; dmg += amount; /# iprintln( "dmg amount: " + dmg ); #/ if(dmg < accumulate) continue; self.damagetype = type; self.damageOwner = attacker; if (level.barrelExplodingThisFrame) wait randomfloat(1); self.damageTaken += amount; if (self.damageTaken == amount) self thread explodable_car_burn(direction_vec, P); } } explodable_car_burn(direction_vec, P) { count = 0; startedfx = false; if( self.damagetype != "MOD_GRENADE_SPLASH" && self.damagetype != "MOD_GRENADE" ) { while (self.damageTaken < level.barrelHealth) { if (!startedfx) { // playfx (level.breakables_fx["barrel"]["burn_start"], self.origin ); // playfx (level.breakables_fx["barrel"]["burn_start"], P, direction_vec); playfxontag( level.breakables_fx["barrel"]["burn_start"], self, "tag_hood" ); startedfx = true; } if (count > 20) count = 0; // playfx (level.breakables_fx["barrel"]["burn"], self.origin); // playfx (level.breakables_fx["barrel"]["burn"], P, direction_vec); playfxontag( level.breakables_fx["barrel"]["burn"], self, "tag_hood" ); if (count == 0) { self.damageTaken += (10 + randomfloat(10)); } count++; wait 0.05; } } self thread explodable_car_explode(); } explodable_car_explode() { self notify ("exploding"); self notify ("death"); self playsound (level.barrelExpSound); playfx (level.breakables_fx["large_vehicle_explosion"], self.origin); level.barrelExplodingThisFrame = true; if (isdefined (self.remove)) { self.remove delete(); } phyExpMagnitude = 4; minDamage = 1; maxDamage = 350; blastRadius = 350; if (isdefined(self.radius)) blastRadius = self.radius; // do not pass damage owner if they have disconnected before the barrels explode if ( !isdefined( self.damageOwner ) ) self radiusDamage(self.origin, blastRadius, maxDamage, minDamage); else self radiusDamage(self.origin, blastRadius, maxDamage, minDamage, self.damageOwner); physicsExplosionSphere( self.origin, blastRadius, blastRadius/2, phyExpMagnitude ); self maps\mp\gametypes\_shellshock::barrel_earthQuake(); // self setModel("vehicle_small_hatch_blue_destroyed"); if (isdefined(self.script_noteworthy)) { if(self.script_noteworthy == "") self setModel(self.model + "_destroyed"); else self setModel ( self.script_noteworthy); } else self setModel(self.model + "_destroyed"); self thread explodeAnim(); wait 0.05; level.barrelExplodingThisFrame = false; } array_thread( entities, process, var, exclusions ) { if ( !isDefined( exclusions ) ) exclusions = []; for ( index = 0; index < entities.size; index++ ) { exclude = false; for ( exIndex = 0; exIndex < exclusions.size; exIndex++ ) { if ( entities[index] != exclusions[exIndex] ) exclude = true; } if ( exclude ) continue; if ( isDefined( var ) ) entities[index] thread [[process]]( var ); else entities[index] thread [[process]](); } } explodeAnim() { self moveZ( 16, 0.3, 0, 0.2 ); self rotatePitch( 10, 0.3, 0, 0.2 ); wait ( 0.3 ); self moveZ( -16, 0.3, 0.15, 0 ); self rotatePitch( -10, 0.3, 0.15, 0 ); }