I have 10 values of arrays in x,y form. level.fishx and level.fishy. What i want to do, is when the player is near a level.fishx,level.fishy i want it to trigger another command, but this is difficult w/arrays. Can it be done?
Ill post the code.
NPC Code:
// NPC made by War Lord Mpg2
if (playerenters) {toweapons Spear Fisher; this.on=0;
}
if (playertouchsme) {
}
if (weaponfired) {sleep .3;
this.on=1; timeout = .05; disabledefmovement; playersprite = 35; this.move=1; client.spearing=0;
}
if (timeout) {
if (this.on=1) {
showspear(); controltest(); testfish(); showspear(); timeout = .05;
}
if (this.on=0) {hideimg 9999; enabledefmovement;
}
}
// FUNCTIONS
function showspear() {
if (playerdir=0) {showimg 9999,la-spear_u.gif,playerx,playery-2;
}
if (playerdir=1) {showimg 9999,la-spear_l.gif,playerx-2,playery+.5;
}
if (playerdir=2) {showimg 9999,la-spear_d.gif,playerx+2,playery;
}
if (playerdir=3) {showimg 9999,la-spear_r.gif,playerx+1,playery+.5;
}playersprite = 35;
return;
}
function testfish() {
if (client.spearing=1) {
if (playerdir=0) {showimg 9999,la-spear_u.gif,playerx,playery-8;
if (level.fishx in |playerx-10,playerx+10| && level.fishy in |0,64|) {client.hasfish=1;
}
}
if (playerdir=1) {
}
if (playerdir=2) {
}
if (playerdir=3) {
}
sleep .5; client.spearing=0;
}
}
function controltest() {
if (keydown(4)) {this.on=0; enabledefmovement; hideimg 9999; sleep .3;
}
if (keydown(0)) {playerdir=0;
}
if (keydown(1)) {playerdir=1;
}
if (keydown(2)) {playerdir=2;
}
if (keydown(3)) {playerdir=3;
}
if (keydown(5)) {
if (playerdir=0 && !onwall(playerx,playery-this.move)) {playery-=this.move;
}
if (playerdir=2 && !onwall(playerx,playery+this.move)) {playery+=this.move;
}
if (playerdir=3 && !onwall(playerx+2+this.move,playery)) {playerx+=this.move;
}
if (playerdir=1 && !onwall(playerx-this.move,playery)) {playerx-=this.move;
}
}
if (keydown(6)) {client.spearing=1;
}
}
That is the weapon part, that detects.
This (below) is the array part, that does the images.
NPC Code:
/ NPC made by War Lord Mpg2
if (playerenters) {enabledefmovement; this.on=1; timeout = .1; this.go=1;
}
if (this.on=1) {
setarray level.maxfish,10; setarray level.fishx,10;
setarray level.fishy,10;
for (q=0; q<10; q++;) {
level.fishx[q]=int(random(3,61));
level.fishy[q]=int(random(3,61));
}
this.on=0;
}
if (timeout) {
for (b=0; b<10; b++;) {
if (level.fishx[q]>-1) {
if (this.go=1) {
level.fishx[b]=int(random(3,61));
level.fishy[b]=int(random(3,61));
level.maxfish[b]+=1;
this.go=0;
}
}
level.randmovex=int(random(-1,2)); level.randmovey=int(random(-1,2));
if (level.randmovex<0) {setstring level.fish,spearfish2.gif;}
if (level.randmovex>0) {setstring level.fish,spearfish1.gif;}
level.fishx[b]+=level.randmovex; level.fishy[b]+=level.randmovey;
showimg b,#s(level.fish),level.fishx[b],level.fishy[b];
}
timeout = 1;
}
Lot of code, lol. Anyways, im trying to get it to where it sets client.hasfish=1 when client.spearing=1 if the player is close to a fish.
Can you help me?
(Ive got it to set client.spearing=1, lol.)