Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-28-2001, 08:29 PM
oscarjf1 oscarjf1 is offline
Registered User
Join Date: Aug 2001
Location: I live in the US
Posts: 107
oscarjf1 is on a distinguished road
Send a message via AIM to oscarjf1
Arrays....

Hello, Im working on a script that uses arrays. This script puts images randomly across the board. That part is fine, but....its the script that goes with it. Ive tried everything....from in to arraylen(which i found out really wasnt worth trying lol). I need to know how to detect if there is an image in front of the player. It wont detect anything, because its an array, and it's value is always 10 because of setarray blach,10; I did however, use level. vars...so the other NPC CAN detect the images, but all of the commands ive tried wont work. Can anyone help me? If you need the coding...i guess i could post it, though I thought this was sufficient.
__________________
I speek on behalf of my staff.
~laterz

Lagoonia Staff
-Tiki God Of Power
Reply With Quote
  #2  
Old 08-28-2001, 08:51 PM
oscarjf1 oscarjf1 is offline
Registered User
Join Date: Aug 2001
Location: I live in the US
Posts: 107
oscarjf1 is on a distinguished road
Send a message via AIM to oscarjf1
umm

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.)
__________________
I speek on behalf of my staff.
~laterz

Lagoonia Staff
-Tiki God Of Power
Reply With Quote
  #3  
Old 08-28-2001, 09:02 PM
Merlin Merlin is offline
Banned
Merlin's Avatar
Join Date: Jul 2001
Location: Merlin - U S A Malak - United Kingdom
Posts: 2,543
Merlin is on a distinguished road
Send a message via ICQ to Merlin Send a message via AIM to Merlin
couldnt you use strings?
like
if (Action) {setstring image,random(1,6);
set random;
}
while (random) {
showimg #s(image),30,30;
}

or something if you're just showing random images?
Reply With Quote
  #4  
Old 08-28-2001, 09:14 PM
oscarjf1 oscarjf1 is offline
Registered User
Join Date: Aug 2001
Location: I live in the US
Posts: 107
oscarjf1 is on a distinguished road
Send a message via AIM to oscarjf1
Unhappy i guess...

i guess i could. But that takes all the fun outta it . I wouldnt have to use strings...i could do what im doing, except not use arrays. level. controls vars for the whole level, which is great for this script. I guess there is no way to do it with arrays . I like using arrays, because they are new to me. I just learned them a few weeks ago. They are great for weather scripts and stuff. I guess i have a small enough amount of images to do each one individually, but....it would also make my weapon script longer. Id have to detect each Image differently because they would all have different values instead of the arrays where they are all level.fishx,level.fishy. there would be level.fishx1,level.fishx2,level.fishx3 ect. Ill work something out since noone has a clue either. This is gonna be a great script once its finished :-).
__________________
I speek on behalf of my staff.
~laterz

Lagoonia Staff
-Tiki God Of Power
Reply With Quote
  #5  
Old 08-28-2001, 11:23 PM
oscarjf1 oscarjf1 is offline
Registered User
Join Date: Aug 2001
Location: I live in the US
Posts: 107
oscarjf1 is on a distinguished road
Send a message via AIM to oscarjf1
yes

yes, thats what i want.....
How do i do it?
__________________
I speek on behalf of my staff.
~laterz

Lagoonia Staff
-Tiki God Of Power
Reply With Quote
  #6  
Old 08-29-2001, 12:05 AM
oscarjf1 oscarjf1 is offline
Registered User
Join Date: Aug 2001
Location: I live in the US
Posts: 107
oscarjf1 is on a distinguished road
Send a message via AIM to oscarjf1
umm

yeah, i know how to do it without using arrays. But i want lots of fish. So, what do you suggest?
__________________
I speek on behalf of my staff.
~laterz

Lagoonia Staff
-Tiki God Of Power
Reply With Quote
  #7  
Old 08-29-2001, 01:00 AM
oscarjf1 oscarjf1 is offline
Registered User
Join Date: Aug 2001
Location: I live in the US
Posts: 107
oscarjf1 is on a distinguished road
Send a message via AIM to oscarjf1
okay, so that would tell me the distance.... from the player to the fish.

so i would put
if (distance<=5) {client.hasfish=1;
}

??

And that script would make it so it would have the distance of every fish that appears?
__________________
I speek on behalf of my staff.
~laterz

Lagoonia Staff
-Tiki God Of Power
Reply With Quote
  #8  
Old 08-29-2001, 09:45 PM
oscarjf1 oscarjf1 is offline
Registered User
Join Date: Aug 2001
Location: I live in the US
Posts: 107
oscarjf1 is on a distinguished road
Send a message via AIM to oscarjf1
n/m

Ahh forget it. I decided to use an NPC for each fish, and have the NPC detect the player, instead of having the player detect the NPC....much easier. I finished my script in like 10 minutes this way....

Thanks for your help though!
__________________
I speek on behalf of my staff.
~laterz

Lagoonia Staff
-Tiki God Of Power
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:42 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.