/*function bombExplode(%this) { %this.safeDelete(); } function CopterBomb::bombExplode(%this) { %this.blowup(); %this.safeDelete(); } */ function blowup(%this) { %explosion = new t2dParticleEffect() { scenegraph = %this.scenegraph; layer = 1; }; %explosion.loadEffect("~/data/particles/shockwave_burst.eff"); %explosion.setEffectLifeMode("KILL", 1); %explosion.setPosition(%this.getPosition()); %explosion.setLayer(1); %explosion.playEffect(); %this.safeDelete(); } function blowupnocollision(%this) { alxStop($copterbombblowhandle); %explosion = new t2dParticleEffect() { scenegraph = %this.scenegraph; }; %explosion.loadEffect("~/data/particles/shockwave_burst.eff"); %explosion.setEffectLifeMode("KILL", 1); %explosion.setPosition(%this.getPosition()); %explosion.setLayer(1); %explosion.playEffect(); %this.safeDelete(); $copterbombblowhandle = alxPlay(Explosion1); } function CopterBomb::fire(%this) { // Pick the image and set its size %this.setImageMap(monkeyCopter_bomb2ImageMap); %this.setSize(6, 6); %this.setLayer(1); // Set the missile position to where the player is, plus // a small offset so that the missile lines up with missile // launcher in the player ship image if ($Player1Copter.firewing == 1) { %this.setPositionX(%this.player.getPositionX() + %this.wingoffset); %this.setPositionY(%this.player.getPositionY() + 10); %this.setLinearVelocityY(getRandom(%this.missileSpdYMin, %this.missileSpdYMax)); $Player1Copter.firewing = 0; } else { %this.setPositionX(%this.player.getPositionX() + %this.wingoffset); %this.setPositionY(%this.player.getPositionY() - 10); %this.setLinearVelocityY(-getRandom(%this.missileSpdYMin, %this.missileSpdYMax)); $Player1Copter.firewing = 1; } %this.setLinearVelocityX(getRandom(%this.missileSpdXMin, %this.missileSpdXMax)); // Use the camera view bounds as the basis for the missile's world limits %cameraViewBounds = sceneWindow2D.getCurrentCameraArea(); %this.setWorldLimit( kill, getword(%cameraViewBounds, 0) - (%this.getWidth() / 2), getword(%cameraViewBounds, 1) - (%this.getHeight() / 2), getword(%cameraViewBounds, 2) + (%this.getWidth() / 2), getword(%cameraViewBounds, 3) + (%this.getHeight() / 2) ); // Turn on collision, but turn off physics %this.setCollisionActive( true, true ); %this.setCollisionPhysics(false, false); %this.setCollisionCallback(true); //make bombs explode after certain time schedule(1500 ,0, blowupnocollision, %this); } function CopterBomb::onCollision( %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts ) { if (%dstObj.class $= "Player1") explode(%srcObj); if (%dstObj.class $= "Player2") explode(%srcObj); %srcObj.dealDamage(4, %dstObj); } function explode(%this) { blowup(%this); %this.safeDelete(); } function CopterBomb ::dealDamage(%this, %amount, %victim) { %takesDamage = %victim.getBehavior("TakesDamageAdvBehavior"); if (!isObject(%takesDamage)) return; %takesDamage.takeDamage(%amount, %this); }