//General Weapon variables $p2CurrentWeapon = 0; // 0 for bare fist, 1 for mg, 2 for arrow //Machine gun variables $p2MG_Enable = 0; $p2MG_FireOK = 1; //Bow variables $p2Bow_Enable = 0; $p2Bow_FireOK = 1; //Cannon variables $p2Cannon_Enable = 0; $p2Cannon_FireOK = 1; //Grenade variables $p2Grenade_Enable = 0; $p2Grenade_ThrowOK = 1; function c2FireButton::mgEnable(%this, %scenegraph) { %this.mount(Player2Image, 1.8, -0.3, 0, 1, 1, 0, 0); } function c2FireButton::bowEnable(%this, %scenegraph) { %this.mount(Player2Image, 1.2, -1, 0, 1, 1, 0, 0); } function c2FireButton::cannonEnable(%this, %scenegraph) { %this.mount(Player2Image, 1.4, -0.6, 0, 1, 1, 0, 0); } function c2FireButton::disable(%this, %scenegraph) { %this.dismount(); %this.setPosition(193.778,-96); } function Player2BombananaAmmoConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); if(p2BombananaAmmoCount.text > 0) { //p2machinegun.disable(); p2MacG.setEnabled(0); $p2MG_Enable = 0; //p2grenade.disable(); $p2Grenade.setEnabled(0); $p2Grenade_Enable = 0; //p2cannon.disable(); p2Cannon.setEnabled(0); $p2Cannon_Enable = 0; //p2arrow.disable(); p2Bow.setEnabled(0); $p2Bow_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); $p2CurrentWeapon = 5; //create bombanana instance if(!$BananaFiringp2)// if bananana not already firing if($BananaExplosionCountp2==6 ||$BananaExplosionCountp2==1 || $BananaExplosionCountp2==0 ) // if all bombanana's from previous bomb have exploded { $player2tempBan.safeDelete(); $player2tempBan = new t2dAnimatedSprite() { animationName="BombananaNoAnimation"; scenegraph = %this.scenegraph; name = myBan; class = Ban; UseMouseEvents = 1; layer=3; CollisionActiveReceive = "1"; CollisionActiveSend = "1"; CollisionCallback = "1"; CollisionPhysicsReceive = "0"; CollisionPhysicsSend = "0"; CollisionPolyList = "-0.128 -0.128 0.113 -1.28 0.118 0.113 -0.128 0.113"; LinkPoints = "0 0"; size = "20 20"; }; //p2bombanana enable $player2tempBan.Player2BananaEnable(); } } else //(notenough ammo) { // play soundeffect } } function Player2BombananaAmmoConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); if(p2BombananaAmmoCount.text > 0) { //p2machinegun.disable(); p2MacG.setEnabled(0); $p2MG_Enable = 0; //p2grenade.disable(); $p2Grenade.setEnabled(0); $p2Grenade_Enable = 0; //p2cannon.disable(); p2Cannon.setEnabled(0); $p2Cannon_Enable = 0; //p2arrow.disable(); p2Bow.setEnabled(0); $p2Bow_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); $p2CurrentWeapon = 5; //create bombanana instance if(!$BananaFiringp2)// if bananana not already firing if($BananaExplosionCountp2==6 ||$BananaExplosionCountp2==0 ) // if all bombanana's from previous bomb have exploded { $player2tempBan.safeDelete(); $player2tempBan = new t2dAnimatedSprite() { animationName="BombananaNoAnimation"; scenegraph = %this.scenegraph; name = myBan; class = Ban; UseMouseEvents = 1; layer=3; CollisionActiveReceive = "1"; CollisionActiveSend = "0"; CollisionCallback = "1"; CollisionPhysicsReceive = "0"; CollisionPhysicsSend = "0"; CollisionPolyList = "-0.128 -0.128 0.113 -1.28 0.118 0.113 -0.128 0.113"; LinkPoints = "0 0"; size = "20 20"; }; //p2bombanana enable $player2tempBan.Player2BananaEnable(); $player2tempBan.setUseTouchEvents(true); } } else //(notenough ammo) { // play soundeffect } } function Player2MachinegunAmmoConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); if(p2MgAmmoCount.text > 0) { //p2bombanana.disable(); if(!$BananaFiringp2) $player2tempBan.safeDelete(); //p2grenade.disable(); $p2Grenade.setEnabled(0); $p2Grenade_Enable = 0; //p2cannon.disable(); p2Cannon.setEnabled(0); $p2Cannon_Enable = 0; //p2arrow.disable(); p2Bow.setEnabled(0); $p2Bow_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); //p2machinegune enable p2MacG.setEnabled(1); $p2MG_Enable = 1; $p2CurrentWeapon = 1; //enable FireButton p2FireButton.mgEnable(); } else //(notenough ammo) { //play soundeffect } } function Player2MachinegunAmmoConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); if(p2MgAmmoCount.text > 0) { //p2bombanana.disable(); if(!$BananaFiringp2) $player2tempBan.safeDelete(); //p2grenade.disable(); $p2Grenade.setEnabled(0); $p2Grenade_Enable = 0; //p2cannon.disable(); p2Cannon.setEnabled(0); $p2Cannon_Enable = 0; //p2arrow.disable(); p2Bow.setEnabled(0); $p2Bow_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); //p2machinegune enable p2MacG.setEnabled(1); $p2MG_Enable = 1; $p2CurrentWeapon = 1; //enable FireButton p2FireButton.mgEnable(); } else //(notenough ammo) { //play soundeffect } } function Player2GrenadeAmmoConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); //p2cannon.disable(); p2Cannon.setEnabled(0); $p2Cannon_Enable = 0; //p2arrow.disable(); p2Bow.setEnabled(0); $p2Bow_Enable = 0; //p2machinegune.disable(); p2MacG.setEnabled(0); $p2MG_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); if(p2GrenadeAmmoCount.text >0 && $p2Grenade_Enable == 0) { //p2bombanana.disable(); if(!$BananaFiringp2) $player2tempBan.safeDelete(); //$p2CurrentWeapon = 1; p2grenadeInit(%this); $p2Grenade_Enable = 1; $p2CurrentWeapon = 4; //p2grenade.enable(); } else //(notenough ammo) { //play soundeffect } } function Player2GrenadeAmmoConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); //p2cannon.disable(); p2Cannon.setEnabled(0); $p2Cannon_Enable = 0; //p2arrow.disable(); p2Bow.setEnabled(0); $p2Bow_Enable = 0; //p2machinegune.disable(); p2MacG.setEnabled(0); $p2MG_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); if(p2GrenadeAmmoCount.text >0 && $p2Grenade_Enable == 0) { //p2bombanana.disable(); if(!$BananaFiringp2) $player2tempBan.safeDelete(); //$p2CurrentWeapon = 1; p2grenadeInit(%this); $p2Grenade_Enable = 1; $p2CurrentWeapon = 4; //p2grenade.enable(); } else //(notenough ammo) { //play soundeffect } } function Player2CannonAmmoConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); // if(p2CannonAmmoCount.text > 0) // { //p2bombanana.disable(); if(!$BananaFiringp2) $player2tempBan.safeDelete(); //p2arrow.disable(); p2Bow.setEnabled(0); $p2Bow_Enable = 0; //p2machinegune.disable(); p2MacG.setEnabled(0); $p2MG_Enable = 0; //$p2CurrentWeapon = 1; //p2grenade.disable(); $p2Grenade.setEnabled(0); $p2Grenade_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); //p2cannon.enable(); p2Cannon.setEnabled(1); $p2Cannon_Enable = 1; $p2CurrentWeapon = 3; //enable FireButton p2FireButton.cannonEnable(); // } // else //(notenough ammo) // { // play soundeffect // } } function Player2CannonAmmoConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); //p2bombanana.disable(); if(!$BananaFiringp2) $player2tempBan.safeDelete(); //p2arrow.disable(); p2Bow.setEnabled(0); $p2Bow_Enable = 0; //p2machinegune.disable(); p2MacG.setEnabled(0); $p2MG_Enable = 0; //$p2CurrentWeapon = 1; //p2grenade.disable(); $p2Grenade.setEnabled(0); $p2Grenade_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); //p2cannon.enable(); p2Cannon.setEnabled(1); $p2Cannon_Enable = 1; $p2CurrentWeapon = 3; //enable FireButton p2FireButton.cannonEnable(); // } // else //(notenough ammo) // { // play soundeffect // } } function Player2ArrowConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); //p2bombanana.disable(); if(!$BananaFiringp2) $player2tempBan.safeDelete(); //p2machinegune.disable(); p2MacG.setEnabled(0); $p2MG_Enable = 0; //$p2CurrentWeapon = 1; //p2grenade.disable(); $p2Grenade.setEnabled(0); $p2Grenade_Enable = 0; //p2cannon.disable(); p2Cannon.setEnabled(0); $p2Cannon_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); //p2arrow.enable(); p2Bow.setEnabled(1); $p2Bow_Enable = 1; $p2CurrentWeapon = 2; //enable FireButton p2FireButton.bowEnable(); } function Player2ArrowConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p2FireButton.disable(); //p2bombanana.disable(); if(!$BananaFiringp2) $player2tempBan.safeDelete(); //p2machinegune.disable(); p2MacG.setEnabled(0); $p2MG_Enable = 0; //$p2CurrentWeapon = 1; //p2grenade.disable(); $p2Grenade.setEnabled(0); $p2Grenade_Enable = 0; //p2cannon.disable(); p2Cannon.setEnabled(0); $p2Cannon_Enable = 0; //disable powerBar $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); //p2arrow.enable(); p2Bow.setEnabled(1); $p2Bow_Enable = 1; $p2CurrentWeapon = 2; //enable FireButton p2FireButton.bowEnable(); } function c2FireButton::onMouseDown(%this, %modifier, %worldPosition, %clicks) //click on the sun image to fire { switch($p2CurrentWeapon) { case 1: if(($p2MG_Enable == 1) && ($p2MG_FireOK == 1) && (p2MgAmmoCount.text >0)) { $p2MG_FireOK = 0; p2to_shoot_MG(); alxStop($MachineGunFirep2MusicHandle); $MachineGunFirep2MusicHandle = alxPlay(MachineGunFire); p2MacG.playAnimation(machinegunImgAnimation, false, 1, false); schedule(150 ,0, p2to_shoot_MG, %this); schedule(300 ,0, p2to_shoot_MG, %this); schedule(450 ,0, p2to_shoot_MG, %this); schedule(1500 ,0, p2set_MG_fire_ok, %this); p2MgAmmoCount.subtract(4); p2MgAmmoCount.checkCount(p2MgAmmoCount.text); } if (p2MgAmmoCount.text == 0) { alxPlay(mgNoAmmo); } break; case 2: if(($p2Bow_Enable == 1) && ($p2Bow_FireOK == 1)) { $p2Bow_FireOK = 0; $p2Bow.createProjectile(); $p2Bow.playAnimation(bowImgAnimation, false, 1, false); alxStop($ArrowFirep2Handle); $ArrowFirep2Handle = alxPlay(ArrowFire); schedule(2500 ,0, p2set_Bow_fire_ok, %this); } break; case 3: if(($p2Cannon_Enable == 1) && (p2CannonAmmoCount.text >0)) { $p2fireButtonPressed = 1; $PowerUpp2Handle = alxPlay(CannonPowerUp); p2set_Cannon_fire_ok(%this); $p2Cannon.setTimerOn(100); } if (p2CannonAmmoCount.text == 0) { alxPlay(cannonNoAmmo); } default: break; } } function c2FireButton::onTouchDown(%this, %event) //click on the sun image to fire { switch($p2CurrentWeapon) { case 1: if(($p2MG_Enable == 1) && ($p2MG_FireOK == 1) && (p2MgAmmoCount.text >0)) { $p2MG_FireOK = 0; p2to_shoot_MG(); alxStop($MachineGunFirep2MusicHandle); $MachineGunFirep2MusicHandle = alxPlay(MachineGunFire); p2MacG.playAnimation(machinegunImgAnimation, true, 1, false); schedule(150 ,0, p2to_shoot_MG, %this); schedule(300 ,0, p2to_shoot_MG, %this); schedule(450 ,0, p2to_shoot_MG, %this); schedule(1500 ,0, p2set_MG_fire_ok, %this); p2MgAmmoCount.subtract(4); p2MgAmmoCount.checkCount(p2MgAmmoCount.text); } if (p2MgAmmoCount.text == 0) { alxPlay(mgNoAmmo); } break; case 2: if(($p2Bow_Enable == 1) && ($p2Bow_FireOK == 1)) { $p2Bow_FireOK = 0; $p2Bow.createProjectile(); $p2Bow.playAnimation(bowImgAnimation, false, 1, false); alxStop($ArrowFirep2Handle); $ArrowFirep2Handle = alxPlay(ArrowFire); schedule(2500 ,0, p2set_Bow_fire_ok, %this); } break; case 3: if(($p2Cannon_Enable == 1) && (p2CannonAmmoCount.text >0)) { $p2fireButtonPressed = 1; $PowerUpp2Handle = alxPlay(CannonPowerUp); p2set_Cannon_fire_ok(%this); $p2Cannon.setTimerOn(100); } if (p2CannonAmmoCount.text == 0) { alxPlay(cannonNoAmmo); } default: break; } } function c2FireButton::onMouseUp(%this, %modifier, %worldPosition, %clicks) { alxStop($PowerUpHandle); $speedmultiplier2 = $duration2; $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); if ($p2CurrentWeapon == 3) { $p2Cannon.setTimerOff(); if (p2FireButton.getPosition() == %this.getPosition()) { if(($p2Cannon_Enable == 1) && ($p2Cannon_FireOK == 1) && $speedmultiplier2 >= 12) { $p2Cannon_FireOK = 0; $p2Cannon.createProjectile(); $CannonFirep2Handle = alxPlay(CannonFire); p2CannonAmmoCount.subtract(1); p2CannonAmmoCount.checkCount(p2CannonAmmoCount.text); } } } } function c2FireButton::onTouchUp(%this, %event) { alxStop($PowerUpHandle); $speedmultiplier2 = $duration2; $duration2 = 0; $p2fireButtonPressed = 0; powerBar2.setSize(0,15); powerBar2.setPositionX(-155); if ($p2CurrentWeapon == 3) { $p2Cannon.setTimerOff(); if (p2FireButton.getPosition() == %this.getPosition()) { if(($p2Cannon_Enable == 1) && ($p2Cannon_FireOK == 1) && $speedmultiplier2 >= 12) { $p2Cannon_FireOK = 0; $p2Cannon.createProjectile(); $CannonFirep2Handle = alxPlay(CannonFire); p2CannonAmmoCount.subtract(1); p2CannonAmmoCount.checkCount(p2CannonAmmoCount.text); } } } } function c2Grenade::onMouseDown(%this, %modifier, %worldPosition, %clicks) { if(($p2Grenade_Enable == 1) && $p2grenadeLoaded) { %this.setSize(%this.getSize()*1.3); p2set_Grenade_throw_ok(%this); $p2Grenade.setTimerOn(100); $p2grenadeClicked = 1; } } function c2Grenade::onTouchDown(%this, %event) { if(($p2Grenade_Enable == 1) && $p2grenadeLoaded) { %this.setSize(%this.getSize()*1.3); p2set_Grenade_throw_ok(%this); $p2Grenade.setTimerOn(100); $p2grenadeClicked = 1; } } function c2Grenade::onMouseUp(%this, %modifier, %worldPosition, %clicks) { alxStop($PowerUpHandle); $speedmultiplier2 = $duration2; $duration2 = 0; powerBar2.setSize(0,4); powerBar2.setPosition(powerBarHolder2.getPosition()); $p2grenadeClicked = 0; %this.setSize(35,35); $p2Grenade.setTimerOff(); if(($p2Grenade_Enable == 1) && ($p2Grenade_ThrowOK == 1) && $speedmultiplier2 >= 12) { $p2Grenade_ThrowOK = 0; $p2Grenade.throwGrenade(); $GrenadeFirep2Handle = alxPlay(grenadeThrow); p2GrenadeAmmoCount.subtract(1); p2GrenadeAmmoCount.checkCount(p2GrenadeAmmoCount.text); if (p2GrenadeAmmoCount.text > 0) p2grenadeInit(%this); } } function c2Grenade::onTouchUp(%this, %modifier, %worldPosition, %clicks) { alxStop($PowerUpHandle); $speedmultiplier2 = $duration2; $duration2 = 0; powerBar2.setSize(0,4); powerBar2.setPosition(powerBarHolder2.getPosition()); $p2grenadeClicked = 0; %this.setSize(35,35); $p2Grenade.setTimerOff(); if(($p2Grenade_Enable == 1) && ($p2Grenade_ThrowOK == 1) && $speedmultiplier2 >= 12) { $p2Grenade_ThrowOK = 0; $p2Grenade.throwGrenade(); $GrenadeFirep2Handle = alxPlay(grenadeThrow); p2GrenadeAmmoCount.subtract(1); p2GrenadeAmmoCount.checkCount(p2GrenadeAmmoCount.text); if (p2GrenadeAmmoCount.text > 0) p2grenadeInit(%this); } } function p2set_MG_fire_ok(%this) { $p2MG_FireOK = 1; } function p2to_shoot_MG(%this) { $p2MacG.createProjectile(); } function p2set_Bow_fire_ok(%this) { $p2Bow_FireOK = 1; $p2Bow.playAnimation(bowImgLoadedNoAnimation, false, 1, false); } function p2set_Cannon_fire_ok(%this) { $p2Cannon_FireOK = 1; } function p2set_Grenade_throw_ok(%this) { $p2Grenade_ThrowOK = 1; } function c2Cannon::OnTimer(%this) { if ($duration2 <= 35) $duration2 += 4; if ($duration2 <= 35) { powerBar2.setSize(($duration2/35*15),4); %rotationRad = ($temprotation2 / 180) * 3.142; powerBar2.setPositionX(powerBarHolder2.getPositionX()+ ((($duration2/70*15) - 10) * mCos(%rotationRad))); powerBar2.setPositionY(powerBarHolder2.getPositionY()+ ((($duration2/70*15) - 10) * mSin(%rotationRad))); } } function c2Grenade::OnTimer(%this) { if ($duration2 <= 35) $duration2 += 4; if ($duration2 <= 35) { powerBar2.setSize(($duration2/35*15),4); %rotationRad = ($temprotation2 / 180) * 3.142; powerBar2.setPositionX(powerBarHolder2.getPositionX()+ ((($duration2/70*15) - 10) * mCos(%rotationRad))); powerBar2.setPositionY(powerBarHolder2.getPositionY()+ ((($duration2/70*15) - 10) * mSin(%rotationRad))); } } function p2grenadeInit(%this) { if (p2GrenadeAmmoCount.text > 0) { $p2Grenade = new t2dAnimatedSprite() { animationName="grenadeImgNoAnimation"; scenegraph = %this.scenegraph; name = p2Grenade; class = c2Grenade; UseMouseEvents = 1; layer=3; CollisionActiveReceive = "0"; CollisionActiveSend = "0"; CollisionCallback = "1"; CollisionPhysicsReceive = "0"; CollisionPhysicsSend = "0"; CollisionPolyList = "-0.128 -0.128 0.113 -1.28 0.118 0.113 -0.128 0.113"; size = "35 35"; Rotation = "90"; }; $p2Grenade.mount(Player2Image, 0.5, 0.6, 0, 1, 1, 0, 0); $p2Grenade.setEnabled(1); $p2grenadeLoaded = 1; $p2grenade.setUseTouchEvents(true); } }