//General Weapon variables $p1CurrentWeapon = 0; // 0 for bare fist, 1 for mg, 2 for arrow //Machine gun variables $p1MG_Enable = 0; $p1MG_FireOK = 1; //Bow variables $p1Bow_Enable = 0; $p1Bow_FireOK = 1; //Cannon variables $p1Cannon_Enable = 0; $p1Cannon_FireOK = 1; //Grenade variables $p1Grenade_Enable = 0; $p1Grenade_ThrowOK = 1; function c1FireButton::mgEnable(%this, %scenegraph) { %this.mount(Player1Image, 1.8, -0.3, 0, 1, 1, 0, 0); } function c1FireButton::bowEnable(%this, %scenegraph) { %this.mount(Player1Image, 1.2, -1, 0, 1, 1, 0, 0); } function c1FireButton::cannonEnable(%this, %scenegraph) { %this.mount(Player1Image, 1.4, -0.6, 0, 1, 1, 0, 0); } function c1FireButton::disable(%this, %scenegraph) { %this.dismount(); %this.setPosition(193.778,-96); } function Player1BombananaAmmoConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); if(p1BombananaAmmoCount.text > 0) { //p1machinegun.disable(); p1MacG.setEnabled(0); $p1MG_Enable = 0; //p1grenade.disable(); $p1Grenade.setEnabled(0); $p1Grenade_Enable = 0; //p1cannon.disable(); p1Cannon.setEnabled(0); $p1Cannon_Enable = 0; //p1arrow.disable(); p1Bow.setEnabled(0); $p1Bow_Enable = 0; $p1CurrentWeapon = 5; //create bombanana instance if(!$BananaFiringp1)// if bananana not already firing if($BananaExplosionCountp1==6 ||$BananaExplosionCountp1==1 ||$BananaExplosionCountp1==0 ) // if all bombanana's from previous bomb have exploded { $player1tempBan.safeDelete(); $player1tempBan = new t2dAnimatedSprite() { animationName="BombananaNoAnimation"; scenegraph = %this.scenegraph; name = myBan1; class = Ban1; 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"; }; //p1bombanana enable $player1tempBan.Player1BananaEnable(); } } else //(notenough ammo) { // play soundeffect } } function Player1BombananaAmmoConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); if(p1BombananaAmmoCount.text > 0) { //p1machinegun.disable(); p1MacG.setEnabled(0); $p1MG_Enable = 0; //p1grenade.disable(); $p1Grenade.setEnabled(0); $p1Grenade_Enable = 0; //p1cannon.disable(); p1Cannon.setEnabled(0); $p1Cannon_Enable = 0; //p1arrow.disable(); p1Bow.setEnabled(0); $p1Bow_Enable = 0; $p1CurrentWeapon = 5; //create bombanana instance if(!$BananaFiringp1)// if bananana not already firing if($BananaExplosionCountp1==6 ||$BananaExplosionCountp1==1 ||$BananaExplosionCountp1==0 ) // if all bombanana's from previous bomb have exploded { $player1tempBan.safeDelete(); $player1tempBan = new t2dAnimatedSprite() { animationName="BombananaNoAnimation"; scenegraph = %this.scenegraph; name = myBan1; class = Ban1; 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"; }; //p1bombanana enable $player1tempBan.Player1BananaEnable(); $player1tempBan.setUseTouchEvents(true); } } else //(notenough ammo) { // play soundeffect } } function Player1MachinegunAmmoConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); if(p1MgAmmoCount.text > 0) { //p1bombanana.disable(); if(!$BananaFiringp1) $player1tempBan.safeDelete(); //p1grenade.disable(); $p1Grenade.setEnabled(0); $p1Grenade_Enable = 0; //p1cannon.disable(); p1Cannon.setEnabled(0); $p1Cannon_Enable = 0; //p1arrow.disable(); p1Bow.setEnabled(0); $p1Bow_Enable = 0; //p1machinegune enable p1MacG.setEnabled(1); $p1MG_Enable = 1; $p1CurrentWeapon = 1; //enable FireButton p1FireButton.mgEnable(); } else //(notenough ammo) { //play soundeffect } } function Player1MachinegunAmmoConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); if(p1MgAmmoCount.text > 0) { //p1bombanana.disable(); if(!$BananaFiringp1) $player1tempBan.safeDelete(); //p1grenade.disable(); $p1Grenade.setEnabled(0); $p1Grenade_Enable = 0; //p1cannon.disable(); p1Cannon.setEnabled(0); $p1Cannon_Enable = 0; //p1arrow.disable(); p1Bow.setEnabled(0); $p1Bow_Enable = 0; //p1machinegune enable p1MacG.setEnabled(1); $p1MG_Enable = 1; $p1CurrentWeapon = 1; //enable FireButton p1FireButton.mgEnable(); } else //(notenough ammo) { //play soundeffect } } function Player1GrenadeAmmoConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); //p1cannon.disable(); p1Cannon.setEnabled(0); $p1Cannon_Enable = 0; //p1arrow.disable(); p1Bow.setEnabled(0); $p1Bow_Enable = 0; //p1machinegune.disable(); p1MacG.setEnabled(0); $p1MG_Enable = 0; if(p1GrenadeAmmoCount.text >0 && $p1Grenade_Enable == 0) { //p1bombanana.disable(); if(!$BananaFiringp1) $player1tempBan.safeDelete(); //$p1CurrentWeapon = 1; p1grenadeInit(%this); $p1Grenade_Enable = 1; $p1CurrentWeapon = 4; //p1grenade.enable(); } else //(notenough ammo) { //play soundeffect } } function Player1GrenadeAmmoConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); //p1cannon.disable(); p1Cannon.setEnabled(0); $p1Cannon_Enable = 0; //p1arrow.disable(); p1Bow.setEnabled(0); $p1Bow_Enable = 0; //p1machinegune.disable(); p1MacG.setEnabled(0); $p1MG_Enable = 0; if(p1GrenadeAmmoCount.text >0 && $p1Grenade_Enable == 0) { //p1bombanana.disable(); if(!$BananaFiringp1) $player1tempBan.safeDelete(); //$p1CurrentWeapon = 1; p1grenadeInit(%this); $p1Grenade_Enable = 1; $p1CurrentWeapon = 4; //p1grenade.enable(); } else //(notenough ammo) { //play soundeffect } } function Player1CannonAmmoConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); // if(p1CannonAmmoCount.text > 0) // { //p1bombanana.disable(); if(!$BananaFiringp1) $player1tempBan.safeDelete(); //p1arrow.disable(); p1Bow.setEnabled(0); $p1Bow_Enable = 0; //p1machinegune.disable(); p1MacG.setEnabled(0); $p1MG_Enable = 0; //$p1CurrentWeapon = 1; //p1grenade.disable(); $p1Grenade.setEnabled(0); $p1Grenade_Enable = 0; //p1cannon.enable(); p1Cannon.setEnabled(1); $p1Cannon_Enable = 1; $p1CurrentWeapon = 3; //enable FireButton p1FireButton.cannonEnable(); // } // else //(notenough ammo) // { // play soundeffect // } } function Player1CannonAmmoConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); // if(p1CannonAmmoCount.text > 0) // { //p1bombanana.disable(); if(!$BananaFiringp1) $player1tempBan.safeDelete(); //p1arrow.disable(); p1Bow.setEnabled(0); $p1Bow_Enable = 0; //p1machinegune.disable(); p1MacG.setEnabled(0); $p1MG_Enable = 0; //$p1CurrentWeapon = 1; //p1grenade.disable(); $p1Grenade.setEnabled(0); $p1Grenade_Enable = 0; //p1cannon.enable(); p1Cannon.setEnabled(1); $p1Cannon_Enable = 1; $p1CurrentWeapon = 3; //enable FireButton p1FireButton.cannonEnable(); // } // else //(notenough ammo) // { // play soundeffect // } } function Player1ArrowConsole:: onMouseDown(%this, %modifier, %worldPosition, %clicks) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); //p1bombanana.disable(); if(!$BananaFiringp1) $player1tempBan.safeDelete(); //p1machinegune.disable(); p1MacG.setEnabled(0); $p1MG_Enable = 0; //$p1CurrentWeapon = 1; //p1grenade.disable(); $p1Grenade.setEnabled(0); $p1Grenade_Enable = 0; //p1cannon.disable(); p1Cannon.setEnabled(0); $p1Cannon_Enable = 0; //p1arrow.enable(); p1Bow.setEnabled(1); $p1Bow_Enable = 1; $p1CurrentWeapon = 2; //enable FireButton p1FireButton.bowEnable(); } function Player1ArrowConsole:: onTouchDown(%this, %event) { alxPlay(clickSound); // disable FireButton! p1FireButton.disable(); //p1bombanana.disable(); if(!$BananaFiringp1) $player1tempBan.safeDelete(); //p1machinegune.disable(); p1MacG.setEnabled(0); $p1MG_Enable = 0; //$p1CurrentWeapon = 1; //p1grenade.disable(); $p1Grenade.setEnabled(0); $p1Grenade_Enable = 0; //p1cannon.disable(); p1Cannon.setEnabled(0); $p1Cannon_Enable = 0; //p1arrow.enable(); p1Bow.setEnabled(1); $p1Bow_Enable = 1; $p1CurrentWeapon = 2; //enable FireButton p1FireButton.bowEnable(); } function c1FireButton::onMouseDown(%this, %modifier, %worldPosition, %clicks) //click on the sun image to fire { switch($p1CurrentWeapon) { case 1: if(($p1MG_Enable == 1) && ($p1MG_FireOK == 1) && (p1MgAmmoCount.text >0)) { $p1MG_FireOK = 0; p1to_shoot_MG(); alxStop($MachineGunFirep1MusicHandle); $MachineGunFirep1MusicHandle = alxPlay(MachineGunFire); p1MacG.playAnimation(machinegunImgAnimation, false, 1, false); schedule(150 ,0, p1to_shoot_MG, %this); schedule(300 ,0, p1to_shoot_MG, %this); schedule(450 ,0, p1to_shoot_MG, %this); schedule(1500 ,0, p1set_MG_fire_ok, %this); p1MgAmmoCount.subtract(4); p1MgAmmoCount.checkCount(p1MgAmmoCount.text); } if (p1MgAmmoCount.text == 0) { alxPlay(mgNoAmmo); } break; case 2: if(($p1Bow_Enable == 1) && ($p1Bow_FireOK == 1)) { $p1Bow_FireOK = 0; $p1Bow.createProjectile(); $p1Bow.playAnimation(bowImgAnimation, false, 1, false); alxStop($ArrowFirep1Handle); $ArrowFirep1Handle = alxPlay(ArrowFire); schedule(2500 ,0, p1set_Bow_fire_ok, %this); } break; case 3: if(($p1Cannon_Enable == 1) && (p1CannonAmmoCount.text >0)) { $p1fireButtonPressed = 1; $PowerUpp1Handle = alxPlay(CannonPowerUp); p1set_Cannon_fire_ok(%this); $p1Cannon.setTimerOn(100); } if (p1CannonAmmoCount.text == 0) { alxPlay(cannonNoAmmo); } default: break; } } function c1FireButton::onTouchDown(%this, %event) //click on the sun image to fire { switch($p1CurrentWeapon) { case 1: if(($p1MG_Enable == 1) && ($p1MG_FireOK == 1) && (p1MgAmmoCount.text >0)) { $p1MG_FireOK = 0; p1to_shoot_MG(); alxStop($MachineGunFirep1MusicHandle); $MachineGunFirep1MusicHandle = alxPlay(MachineGunFire); p1MacG.playAnimation(machinegunImgAnimation, false, 1, false); schedule(150 ,0, p1to_shoot_MG, %this); schedule(300 ,0, p1to_shoot_MG, %this); schedule(450 ,0, p1to_shoot_MG, %this); schedule(1500 ,0, p1set_MG_fire_ok, %this); p1MgAmmoCount.subtract(4); p1MgAmmoCount.checkCount(p1MgAmmoCount.text); } if (p1MgAmmoCount.text == 0) { alxPlay(mgNoAmmo); } break; case 2: if(($p1Bow_Enable == 1) && ($p1Bow_FireOK == 1)) { $p1Bow_FireOK = 0; $p1Bow.createProjectile(); $p1Bow.playAnimation(bowImgAnimation, false, 1, false); alxStop($ArrowFirep1Handle); $ArrowFirep1Handle = alxPlay(ArrowFire); schedule(2500 ,0, p1set_Bow_fire_ok, %this); } break; case 3: if(($p1Cannon_Enable == 1) && (p1CannonAmmoCount.text >0)) { $p1fireButtonPressed = 1; $PowerUpp1Handle = alxPlay(CannonPowerUp); p1set_Cannon_fire_ok(%this); $p1Cannon.setTimerOn(100); } if (p1CannonAmmoCount.text == 0) { alxPlay(cannonNoAmmo); } default: break; } } function c1FireButton::onMouseUp(%this, %modifier, %worldPosition, %clicks) { alxStop($PowerUpHandle); $speedmultiplier1 = $duration1; $duration1 = 0; $p1fireButtonPressed = 0; powerBar1.setSize(0,15); powerBar1.setPositionX(-155); if ($p1CurrentWeapon == 3) { $p1Cannon.setTimerOff(); if (p1FireButton.getPosition() == %this.getPosition()) { if(($p1Cannon_Enable == 1) && ($p1Cannon_FireOK == 1) && $speedmultiplier1 >= 20) { $p1Cannon_FireOK = 0; $p1Cannon.createProjectile(); $CannonFirep1Handle = alxPlay(CannonFire); p1CannonAmmoCount.subtract(1); p1CannonAmmoCount.checkCount(p1CannonAmmoCount.text); } } } } function c1FireButton::onTouchUp(%this, %event) { alxStop($PowerUpHandle); $speedmultiplier1 = $duration1; $duration1 = 0; $p1fireButtonPressed = 0; powerBar1.setSize(0,15); powerBar1.setPositionX(-155); if ($p1CurrentWeapon == 3) { $p1Cannon.setTimerOff(); if (p1FireButton.getPosition() == %this.getPosition()) { if(($p1Cannon_Enable == 1) && ($p1Cannon_FireOK == 1) && $speedmultiplier1 >= 20) { $p1Cannon_FireOK = 0; $p1Cannon.createProjectile(); $CannonFirep1Handle = alxPlay(CannonFire); p1CannonAmmoCount.subtract(1); p1CannonAmmoCount.checkCount(p1CannonAmmoCount.text); } } } } function c1Grenade::onMouseDown(%this, %modifier, %worldPosition, %clicks) { if(($p1Grenade_Enable == 1) && $p1grenadeLoaded) { p1set_Grenade_throw_ok(%this); $p1Grenade.setTimerOn(100); $p1grenadeClicked = 1; %this.setSize(%this.getSize()*1.3); } } function c1Grenade::onTouchDown(%this, %event) { if(($p1Grenade_Enable == 1) && $p1grenadeLoaded) { p1set_Grenade_throw_ok(%this); $p1Grenade.setTimerOn(100); $p1grenadeClicked = 1; %this.setSize(%this.getSize()*1.3); } } function c1Grenade::onMouseUp(%this, %modifier, %worldPosition, %clicks) { alxStop($PowerUpHandle); $speedmultiplier1 = $duration1; $duration1 = 0; powerBar1.setSize(0,15); powerBar1.setPosition(powerBarHolder1.getPosition()); $p1grenadeClicked = 0; %this.setSize(35,35); $p1Grenade.setTimerOff(); if(($p1Grenade_Enable == 1) && ($p1Grenade_ThrowOK == 1) && $speedmultiplier1 >= 20) { $p1Grenade_ThrowOK = 0; $p1Grenade.throwGrenade(); $GrenadeFirep1Handle = alxPlay(grenadeThrow); p1GrenadeAmmoCount.subtract(1); p1GrenadeAmmoCount.checkCount(p1GrenadeAmmoCount.text); if (p1GrenadeAmmoCount.text > 0) p1grenadeInit(%this); } } function c1Grenade::onTouchUp(%this, %modifier, %worldPosition, %clicks) { alxStop($PowerUpHandle); $speedmultiplier1 = $duration1; $duration1 = 0; powerBar1.setSize(0,15); powerBar1.setPosition(powerBarHolder1.getPosition()); $p1grenadeClicked = 0; %this.setSize(35,35); $p1Grenade.setTimerOff(); if(($p1Grenade_Enable == 1) && ($p1Grenade_ThrowOK == 1) && $speedmultiplier1 >= 20) { $p1Grenade_ThrowOK = 0; $p1Grenade.throwGrenade(); $GrenadeFirep1Handle = alxPlay(grenadeThrow); p1GrenadeAmmoCount.subtract(1); p1GrenadeAmmoCount.checkCount(p1GrenadeAmmoCount.text); if (p1GrenadeAmmoCount.text > 0) p1grenadeInit(%this); } } function p1set_MG_fire_ok(%this) { $p1MG_FireOK = 1; } function p1to_shoot_MG(%this) { $p1MacG.createProjectile(); } function p1set_Bow_fire_ok(%this) { $p1Bow_FireOK = 1; $p1Bow.playAnimation(bowImgLoadedNoAnimation, false, 1, false); } function p1set_Cannon_fire_ok(%this) { $p1Cannon_FireOK = 1; } function p1set_Grenade_throw_ok(%this) { $p1Grenade_ThrowOK = 1; } function c1Cannon::OnTimer(%this) { if ($duration1 <= 35) $duration1 += 4; if ($duration1 <= 35) { powerBar1.setSize(($duration1/35*15),4); %rotationRad = ($temprotation1 / 180) * 3.142; powerBar1.setPositionX(powerBarHolder1.getPositionX()+ ((($duration1/70*15) - 10) * mCos(%rotationRad))); powerBar1.setPositionY(powerBarHolder1.getPositionY()+ ((($duration1/70*15) - 10) * mSin(%rotationRad))); } } function c1Grenade::OnTimer(%this) { if ($duration1 <= 35) $duration1 += 4; if ($duration1 <= 35) { powerBar1.setSize(($duration1/35*15),4); %rotationRad = ($temprotation1 / 180) * 3.142; powerBar1.setPositionX(powerBarHolder1.getPositionX()+ ((($duration1/70*15) - 10) * mCos(%rotationRad))); powerBar1.setPositionY(powerBarHolder1.getPositionY()+ ((($duration1/70*15) - 10) * mSin(%rotationRad))); } } function p1grenadeInit(%this) { if (p1GrenadeAmmoCount.text > 0) { $p1Grenade = new t2dAnimatedSprite() { animationName="grenadeImgNoAnimation"; scenegraph = %this.scenegraph; name = p1Grenade; class = c1Grenade; 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"; }; $p1Grenade.mount(Player1Image, 0.5, 0.6, 0, 1, 1, 0, 0); $p1Grenade.setEnabled(1); $p1grenadeLoaded = 1; $p1grenade.setUseTouchEvents(true); } }