main() { //------------------ //EFECTS DEFINITIONS //------------------ qBarrels = false; precacheItem( "barrel_mp" ); barrels = getentarray ("explodable_barrel","targetname"); if ( (isdefined(barrels)) && (barrels.size > 0) ) qBarrels = true; barrels = getentarray ("explodable_barrel","script_noteworthy"); if ( (isdefined(barrels)) && (barrels.size > 0) ) qBarrels = true; if (qBarrels) { level.breakables_fx["barrel"]["explode"] = loadfx ("props/barrelExp"); level.breakables_fx["barrel"]["burn_start"] = loadfx ("props/barrel_ignite"); level.breakables_fx["barrel"]["burn"] = loadfx ("props/barrel_fire_top"); } oilspill = getentarray ("oil_spill","targetname"); if(isdefined(oilspill) && oilspill.size > 0) { level.breakables_fx["oilspill"]["burn"] = loadfx ("props/barrel_fire"); level.breakables_fx["oilspill"]["spark"] = loadfx("impacts/small_metalhit_1"); } //------------------ //------------------ //----------------- //SOUND DEFINITIONS //----------------- level.barrelExpSound = "explo_metal_rand"; //----------------- //----------------- level.barrelHealth = 150; maxBrokenPieces = 25; //------------- //------------- level.precachemodeltype = []; level.barrelExplodingThisFrame = false; level.breakables_clip = []; temp = getentarray ("breakable clip","targetname"); for (i=0;i= dist) continue; dist = newdist; ent = array[i]; } return ent; } oil_spill_burn_after() { while(1) { self.barrel waittill("damage", amount ,attacker, direction_vec, P, type); if(type == "MOD_MELEE" || type == "MOD_IMPACT") continue; break; } self.damageOwner = attacker; // do not pass damage owner if they have disconnected before the barrels explode if ( !isdefined( self.damageOwner ) ) self radiusdamage (self.origin, 4, 10, 10 ); else self radiusdamage (self.origin, 4, 10, 10, self.damageOwner); } oil_spill_burn(P, dest) { forward = vectornormalize(dest - P); dist = distance(p, dest); range = 8; interval = common_scripts\utility::vector_multiply(forward, range); angle = vectortoangles(forward); right = anglestoright(angle); barrels = getentarray ("explodable_barrel","targetname"); distsqr = 22 * 22; test = spawn("script_origin", P); test hide(); num = 0; while(1) { dist -= range; if(dist < range *.1) break; p += (interval + common_scripts\utility::vector_multiply(right, randomfloatrange(-6, 6))); thread oil_spill_burn_section(P); num++; if(num == 4) { num = 0; } test.origin = P; remove = []; barrels = common_scripts\utility::array_removeUndefined(barrels); for(i=0; i 20) count = 0; playfx (level.breakables_fx["barrel"]["burn"], self.origin + offset2); if (count == 0) { self.damageTaken += (10 + randomfloat(10)); } count++; wait 0.05; } } self thread explodable_barrel_explode(); } explodable_barrel_explode() { self notify ("exploding"); self notify ("death"); up = anglestoup(self.angles); worldup = anglestoup((0,90,0)); dot = vectordot(up, worldup); offset = (0,0,0); if(dot < .5) { start = (self.origin + common_scripts\utility::vector_multiply(up, 22)); end = physicstrace(start, (start + (0,0,-64))); offset = end - self.origin; } offset += (0,0,4); self playsound (level.barrelExpSound); //level thread play_sound_in_space(level.barrelExpSound, self.origin); playfx (level.breakables_fx["barrel"]["explode"], self.origin + offset); level.barrelExplodingThisFrame = true; if (isdefined (self.remove)) { self.remove delete(); } phyExpMagnitude = 2; minDamage = 1; maxDamage = 250; blastRadius = 250; 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 + (0,0,30), blastRadius, maxDamage, minDamage, undefined, "MOD_EXPLOSIVE", "barrel_mp"); else self radiusDamage(self.origin + (0,0,30), blastRadius, maxDamage, minDamage, self.damageOwner, "MOD_EXPLOSIVE", "barrel_mp" ); physicsExplosionSphere( self.origin + (0,0,30), blastRadius, blastRadius/2, phyExpMagnitude ); self maps\mp\gametypes\_shellshock::barrel_earthQuake(); if (randomint(2) == 0) self setModel("com_barrel_piece"); else self setModel("com_barrel_piece2"); self setCanDamage( false ); if(dot < .5) { start = (self.origin + common_scripts\utility::vector_multiply(up, 22)); pos = physicstrace(start, (start + (0,0,-64))); self.origin = pos; self.angles += (0,0,90); } wait 0.05; level.barrelExplodingThisFrame = false; } getstruct(name, type) { if(!isdefined(level.struct_class_names)) return undefined; array = level.struct_class_names[type][name]; if(!isdefined(array)) return undefined; if(array.size > 1) { assertMsg ("getstruct used for more than one struct of type " + type + " called " + name +"."); return undefined; } return array[0]; } breakable_clip() { //targeted brushmodels take priority over proximity based breakables - nate if (isdefined(self.target)) { targ = getent(self.target,"targetname"); if(targ.classname == "script_brushmodel") { self.remove = targ; return; } } //setup it's removable clip part if ((isdefined (level.breakables_clip)) && (level.breakables_clip.size > 0)) self.remove = getClosestEnt( self.origin , level.breakables_clip ); if (isdefined (self.remove)) level.breakables_clip = common_scripts\utility::array_remove ( level.breakables_clip , self.remove ); }