function c1Bow::onLevelLoaded(%this, %scenegraph) { $p1Bow = %this; //mount the machine gun onto player p1Bow.mount(Player1Image, 1.4, 0.5, 0, 1, 1, 0, 0); p1Bow.setEnabled(0); // for keyboard testing // moveMap.bindCmd(keyboard, "o", "$pBow.createProjectile();", ""); } function c1Bow::createProjectile(%this) { %this.Player1Arrow = new t2dStaticSprite() { scenegraph = %this.scenegraph; class = Player1Arrow; //CollisionPolyList = "0.071 -0.3140 0.204 0.363 -0.039 0.363" //Layer = "3" //bulletSpeedX = %this.BulSpeed; //bulletSpeedY = %this.BulSpeed; player = %this; }; %this.Player1Arrow.shootProjectile(); } function Player1Arrow::shootProjectile(%this) { // Pick the image and set its size %this.setImageMap(arrowImageMap); %this.setSize(50, 50); %facing_angle_deg = $p1Bow.getRotation(); %this.setRotation(%facing_angle_deg); %this.setLayer(3); // Turn on collision, but turn off physics %this.setCollisionActive( true, true ); %this.setCollisionPhysics(false, false); %this.setCollisionCallback(true); %this.setCollisionPolyCustom(3, "0.071 -0.3140", "0.204 0.363","-0.039 0.363"); %this.setPositionX(%this.player.getPositionX()); %this.setPositionY(%this.player.getPositionY()); %facing_angle_deg = $p1Bow.getRotation() - 92; %facing_angle_rad = (%facing_angle_deg / 180) * 3.142; %this.setLinearVelocityX(240 * mCos(%facing_angle_rad)); %this.setLinearVelocityY(240 * mSin(%facing_angle_rad)); %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) ); } function Player1Arrow::onCollision( %srcObj, %dstObj, %srcRef, %dstRef, %time, %normal, %contactCount, %contacts ) { if (%dstObj.class $= "Player1") { //%srcObj.dealDamage(3, %dstObj); //%srcObj.safeDelete(); //explode(%srcObj); } if(%dstObj.class $= "trees") { alxStop(ArrowImpact); $ArrowImpactHandle = alxPlay(ArrowImpact); %srcObj.safeDelete(); } if (%dstObj.class $= "Player2") { alxStop(ArrowImpact); $ArrowImpactHandle = alxPlay(ArrowImpact); %srcObj.dealDamage(4, %dstObj); %srcObj.safeDelete(); //explode(%srcObj); } } function Player1Arrow ::dealDamage(%this, %amount, %victim) { %takesDamage = %victim.getBehavior("TakesDamageAdvBehavior"); if (!isObject(%takesDamage)) return; %takesDamage.takeDamage(%amount, %this); }