cFireSun.setUseTouchEvents(true); cSelectWeapon.setUseTouchEvents(true); //General Weapon variables $CurrentWeapon = 0; // 0 for bare fist, 1 for mg, 2 for arrow //Machine gun variables $MG_Enable = 0; $MG_FireOK = 1; //Bow variables $Bow_Enable = 0; $Bow_FireOK = 1; function cFireSun::onMouseDown(%this, %modifier, %worldPosition, %clicks) //click on the sun image to fire { switch($CurrentWeapon) { case 1: if(($MG_Enable == 1) && ($MG_FireOK == 1)) { $MG_FireOK = 0; to_shoot_MG(); alxStop($MachineGunFireMusicHandle); $MachineGunFireMusicHandle = alxPlay(MachineGunFire); schedule(150 ,0, to_shoot_MG, %this); schedule(300 ,0, to_shoot_MG, %this); schedule(450 ,0, to_shoot_MG, %this); schedule(500 ,0, set_MG_fire_ok, %this); } case 2: if(($Bow_Enable == 1) && ($Bow_FireOK == 1)) { $Bow_FireOK = 0; $pBow.createProjectile(); alxStop($ArrowFireHandle); $ArrowFireHandle = alxPlay(ArrowFire); schedule(1000 ,0, set_Bow_fire_ok, %this); } break; default: break; } function cFireSun::onTouchDown(%this, %event) //click on the sun image to fire { switch($CurrentWeapon) { case 1: if(($MG_Enable == 1) && ($MG_FireOK == 1)) { $MG_FireOK = 0; to_shoot_MG(); alxStop($MachineGunFireMusicHandle); $MachineGunFireMusicHandle = alxPlay(MachineGunFire); schedule(150 ,0, to_shoot_MG, %this); schedule(300 ,0, to_shoot_MG, %this); schedule(450 ,0, to_shoot_MG, %this); schedule(500 ,0, set_MG_fire_ok, %this); } case 2: if(($Bow_Enable == 1) && ($Bow_FireOK == 1)) { $Bow_FireOK = 0; $pBow.createProjectile(); alxStop($ArrowFireHandle); $ArrowFireHandle = alxPlay(ArrowFire); schedule(1000 ,0, set_Bow_fire_ok, %this); } break; default: break; } } function set_MG_fire_ok(%this) { $MG_FireOK = 1; } function to_shoot_MG(%this) { $pMacG.createProjectile(); } function set_Bow_fire_ok(%this) { $Bow_FireOK = 1; } function cSelectWeapon::onMouseDown(%this, %modifier, %worldPosition, %clicks) //alternates enable and disable MG when click on white circle { /* if($MG_Enable == 0) { pMacG.setEnabled(1); $MG_Enable = 1; } else($MG_Enable == 1) { pMacG.setEnabled(0); $MG_Enable = 0; } */ switch($CurrentWeapon) { case 0: pMacG.setEnabled(1); $MG_Enable = 1; $CurrentWeapon = 1; break; case 1: pMacG.setEnabled(0); pBow.setEnabled(1); $MG_Enable = 0; $Bow_Enable = 1; $CurrentWeapon = 2; break; case 2: pBow.setEnabled(0); $Bow_Enable = 0; $CurrentWeapon = 0; break; default: break; } } function cSelectWeapon::onTouchDown(%this, %event) //alternates enable and disable MG when click on white circle { /* if($MG_Enable == 0) { pMacG.setEnabled(1); $MG_Enable = 1; } else($MG_Enable == 1) { pMacG.setEnabled(0); $MG_Enable = 0; } */ switch($CurrentWeapon) { case 0: pMacG.setEnabled(1); $MG_Enable = 1; $CurrentWeapon = 1; break; case 1: pMacG.setEnabled(0); pBow.setEnabled(1); $MG_Enable = 0; $Bow_Enable = 1; $CurrentWeapon = 2; break; case 2: pBow.setEnabled(0); $Bow_Enable = 0; $CurrentWeapon = 0; break; default: break; } }