Arrow system rewrite:
Systems NPC:
//NPC made by Downsider
if (playerenters) {
toweapons Arrow System;
setarray this.arrowx,50;
setarray this.arrowy,50;
setarray this.arrowdir,50;
setarray this.arrowismine,50;
timeout = 0.05;
}
if (actionprojectile) {
if (strequals(#p(2),newarrow)) {
for (i=0;i<50;i++) {
if (this.arrowx[i] <= 0) {
this.arrowx[i] = strtofloat(#p(3));
this.arrowy[i] = strtofloat(#p(4));
this.arrowdir[i] = strtofloat(#p(5));
if (strequals(#a,#p(6))) {
this.arrowismine[i] = 1;
} else {
this.arrowismine[i] = 0;
}
break;
}
}
}
if (strequals(#p(2),removearrow)) {
this.arrowx[strtofloat(#p(3))] = -10;
}
}
if (timeout) {
timeout = 0.05;
if (!isweapon) {
return;
}
prepare();
moveArrows();
drawArrows();
checkHurt();
reflectArrows();
}
function prepare() {
if (!strequals(#s(this.olevel),#L)) {
setarray this.arrowx,50;
setarray this.arrowy,50;
setarray this.arrowdir,50;
setarray this.arrowismine,50;
for (i=0;i<50;i++) {
this.arrowx[i] = 0;
this.arrowy[i] = 0;
this.arrowdir[i] = 0;
this.arrowismine[i] = 0;
}
}
setstring this.olevel,#L;
}
function removeArrow() {
setshootparams removearrow,#v(this.target);
shoot -10,-10,0.05,0.05,0.05,0.05,0.05,0.05,0.05,;
}
function shootArrow() {
setshootparams newarrow,#v(this.sx),#v(this.sy),#v(this.sd),#a;
shoot -10,-10,0.05,0.05,0.05,0.05,0.05,0.05,0.05,;
}
function reflectArrows() {
for (i=0;i<50;i++) {
if (this.arrowx[i] > 0) {
if (this.arrowx[i] in |playerx,playerx+2| && this.arrowy[i] in |playery+1,playery+3|) {
if (vecx(this.arrowdir[i]) + vecx(playerdir) == 0 && vecy(this.arrowdir[i]) + vecy(playerdir) == 0 && strequals(#m,idle)) {
if (this.arrowismine[i] == 0) {
this.target = i;
removeArrow();
this.sx = playerx+1+vecx(playerdir);
this.sy = playery+1.5+vecy(playerdir);
this.sd = playerdir;
shootArrow();
putleaps 4,this.sx,this.sy;
return;
}
}
}
}
}
}
function checkHurt() {
for (i=0;i<50;i++) {
if (this.arrowx[i] > 0) {
if (this.arrowx[i] in |playerx,playerx+2| && this.arrowy[i] in |playery+1,playery+3|) {
if (vecx(this.arrowdir[i]) + vecx(playerdir) == 0 && vecy(this.arrowdir[i]) + vecy(playerdir) == 0 && strequals(#m,idle)) {
} else {
if (this.arrowismine[i] == 0) {
this.target = i;
removeArrow();
hurt 1;
return;
}
}
}
}
}
}
function drawArrows() {
for (i=0;i<50;i++) {
hideimg 300+i;
if (this.arrowx[i] > 0) {
showimg 300+i,sprites.png,this.arrowx[i],this.arrowy[i];
changeimgvis 300+i,1;
if (this.arrowdir[i] == 0) {
changeimgpart 300+i,11,422,9,30;
}
if (this.arrowdir[i] == 1) {
changeimgpart 300+i,0,412,30,9;
}
if (this.arrowdir[i] == 2) {
changeimgpart 300+i,1,426,9,30;
}
if (this.arrowdir[i] == 3) {
changeimgpart 300+i,0,402,30,9;
}
}
}
}
function moveArrows() {
for (i=0;i<50;i++) {
if (this.arrowx[i] > 0) {
this.arrowx[i] += vecx(this.arrowdir[i]);
this.arrowy[i] += vecy(this.arrowdir[i]);
if (this.arrowx[i] < 0 || this.arrowx[i] > 64) {
this.arrowx[i] = -1;
this.arrowy[i] = -1;
}
if (this.arrowy[i] < 0 || this.arrowy[i] > 64) {
this.arrowx[i] = -1;
this.arrowy[i] = -1;
}
}
}
}
How to shoot an arrow via script:
//NPC made by Downsider
if (playertouchsme) {
toweapons New Bow;
}
if (weaponfired) {
setani shoot,;
freezeplayer 0.5;
this.sx = playerx+1+vecx(playerdir);
this.sy = playery+1.5+vecy(playerdir);
this.sd = playerdir;
shootArrow();
}
function shootArrow() {
setshootparams newarrow,#v(this.sx),#v(this.sy),#v(this.sd),#a;
shoot -10,-10,0.05,0.05,0.05,0.05,0.05,0.05,0.05,;
}
Haven’t tested it online because Beholder hasn’t been responding to me :’(
Should work, though. Arrows reflect in this script 