if (_root.shootstart eq "yes") { timer = eval(cowgun+"_rate"); time += 1; if (time>=timer) { time = 0; // duplicating clipcount += 1; duplicateMovieClip ("_root.bullet_orig", "bullet"+clipcount, clipcount); name = "bullet"+clipcount; muzzle_x = parseInt(_root.maincow._x+eval(cowgun+"_x")); muzzle_y = parseInt(_root.maincow._y+eval(cowgun+"_y")); setProperty ("_root."+name, _x, parseInt(muzzle_x)); setProperty ("_root."+name, _y, parseInt(muzzle_y)); // variables gunX = parseInt(muzzle_x); gunY = parseInt(muzzle_y); xdistance = 0-(gunX-_root._xmouse); ydistance = 0-(gunY-_root._ymouse); speed = 10; // // rotating bullets accordingly // bulletx = eval("_root."+name+"._x"); bullety = eval("_root."+name+"._y"); adjside = Math.abs(eval("_root."+name+"._x")-Number(_root._xmouse)); oppside = Math.abs(eval("_root."+name+"._y")-Number(_root._ymouse)); angle = Math.atan2(oppside, adjside)/Math.PI*180; if (_root._xmouse eq Number(bulletx) and _root._ymouseNumber(bulletx)) { // 90 degrees rotation = 90; } else if (_root._xmouse eq Number(bulletx) and _root._ymouse>Number(bullety)) { // 180 degrees rotation = 180; } else if (_root._ymouse eq Number(bullety) and _root._xmouseNumber(bulletx) and _root._ymouseNumber(bulletx) and _root._ymouse>Number(bullety)) { // 91-179 degrees rotation = 90+Number(angle); } else if (_root._xmouseNumber(bullety)) { // 181-269 degrees rotation = 270-Number(angle); } else if (_root._xmouse0) { // 90 degrees xmove = 1*speed; ymove = 0; } else if (ydistance == 0 and xdistance<0) { // 270 degrees xmove = -1*speed; ymove = 0; } else if (ydistance>0 and xdistance == 0) { // 180 degrees xmove = 0; ymove = -1*speed; } else if (ydistance<0 and xdistance == 0) { // 0 degrees xmove = 0; ymove = 1*speed; } else if (xdistance>0 and ydistance<0 and Math.abs(ydistance)>Math.abs(xdistance)) { // upper right 45 degrees ymove = -1*speed; xmove = Math.abs((xdistance/ydistance)*speed); } else if (xdistance>0 and ydistance<0 and Math.abs(ydistance)0 and ydistance>0 and Math.abs(ydistance)0 and ydistance>0 and Math.abs(ydistance)>Math.abs(xdistance)) { // bottom lower right 45 degrees ymove = 1*speed; xmove = Math.abs((xdistance/ydistance)*speed); } else if (xdistance<0 and ydistance<0 and Math.abs(ydistance)>Math.abs(xdistance)) { // upper left 45 degrees ymove = -1*speed; xmove = -1*(xdistance/ydistance)*speed; } else if (xdistance<0 and ydistance<0 and Math.abs(ydistance)0 and Math.abs(ydistance)0 and Math.abs(ydistance)>Math.abs(xdistance)) { // bottom lower left 45 degrees ymove = 1*speed; xmove = (xdistance/ydistance)*speed; } else { ymove = 0; xmove = 0; } set ("_root."+name+".xmove", xmove); set ("_root."+name+".ymove", ymove);