Graal Forums  

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

 
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-31-2001, 07:40 AM
Bravo_NPC-Admin1 Bravo_NPC-Admin1 is offline
Registered User
Join Date: May 2001
Location: Olympia, Washington USA
Posts: 25
Bravo_NPC-Admin1 is on a distinguished road
Send a message via AIM to Bravo_NPC-Admin1 Send a message via Yahoo to Bravo_NPC-Admin1
I need help with a script...

Here is a script I did last night:
NPC Code:

// NPC made by Boco
if (created || playerenters) {
setimgpart bravo_riverpan.gif,0,0,32,32;
}
if (playertouchsme) {
toweapons River Pan;
setimgpart bravo_riverpan.gif,0,0,32,32;
}
if (weaponfired) {
this.testx=int(playerx+1.5+(vecx(playerdir)*2));
this.testy=int(playery+2.5+(vecy(playerdir)*2));
if (board[this.testx+this.testy*64]==322) {
PanRiver();
} else {
setplayerprop #c,On WATER!;
}
}
function PanRiver() {
if (strtofloat(#s(client.Mineral))<strtofloat(#s(clie nt.MineralCount))) {
freezeplayer 0.3;
setani bravo_riverpan,;
sleep 0.3;
this.MineralTest=random(0,1);
if (this.MineralTest<=0.05) { this.MineralType=1; break; }
else if (this.MineralTest<=0.2) { this.MineralType=2; break; }
else if (this.MineralTest<=0.4) { this.MineralType=3; break; }
else { this.MineralType=0; }
if (this.MineralType==1) { GotGold(); }
else if (this.MineralType==2) { GotIron(); }
else if (this.MineralType==3) { GotBrass(); }
else if (this.MineralType==0) { setplayerprop #c,Something screwy...; }
if (strtofloat(#s(client.Mineral))>strtofloat(#s(clie nt.MineralCount))) { setstring client.Mineral,#s(client.MineralCount); }
} else {
setplayerprop #c,Bag full;
}
}
function GotGold() {
this.nuggets=int(random(1,2));
this.Nnuggets=strtofloat(#s(client.Mineral))+this. nuggets;
this.GNnuggets=strtofloat(#s(client.Mineral_Gold)) +this.nuggets;
setstring client.Mineral_Gold,#v(this.GNnuggets);
setstring client.Mineral,#v(this.Nnuggets);
say2 You got #v(this.nuggets) nuggets#bof Gold! You have #s(client.Mineral_Gold) gold nuggets#btotal.;
}
function GotIron() {
this.nuggets=int(random(1,2));
this.Nnuggets=strtofloat(#s(client.Mineral))+this. nuggets;
this.GNnuggets=strtofloat(#s(client.Mineral_Iron)) +this.nuggets;
setstring client.Mineral_Iron,#v(this.GNnuggets);
setstring client.Mineral,#v(this.Nnuggets);
say2 You got #v(this.nuggets) nuggets#bof Iron! You have #s(client.Mineral_Iron) iron nuggets#btotal.;
}
function GotBrass() {
this.nuggets=int(random(1,2));
this.Nnuggets=strtofloat(#s(client.Mineral))+this. nuggets;
this.GNnuggets=strtofloat(#s(client.Mineral_Brass) )+this.nuggets;
setstring client.Mineral_Brass,#v(this.GNnuggets);
setstring client.Mineral,#v(this.Nnuggets);
say2
You got #v(this.nuggets) nuggets#bof Brass! You have #s(client.Mineral_Brass) brass nuggets#btotal.;
}



The problem is that GotGold, GotIron, or the GotBrass functions won't call. At first I thought that the variable this.MineralType wasn't returning values correctly, but 'else if (this.MineralType==0) { setplayerprop #c,Something screwy...; }' proved otherwise, because my player would say "Something screwy..." whenever this.MineralType was equal to 0. I am confused. If you want to try this script out on your own, this is the NPC for the mineral sack:

NPC Code:

// NPC made by Boco
if (playertouchsme) {
say2
You got a bag;
setstring client.MineralCount,5;
setstring client.Mineral,0;
}

__________________
-Boco
  #2  
Old 05-31-2001, 08:48 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
uh...why do you have break in there? you only use those in a for or while loop....that might be your problem.

Kyle say you may make mineral name as temporary string and shorten script large amount.
  #3  
Old 05-31-2001, 09:47 PM
Bravo_NPC-Admin1 Bravo_NPC-Admin1 is offline
Registered User
Join Date: May 2001
Location: Olympia, Washington USA
Posts: 25
Bravo_NPC-Admin1 is on a distinguished road
Send a message via AIM to Bravo_NPC-Admin1 Send a message via Yahoo to Bravo_NPC-Admin1
OH CRAP! I forgot I had breaks in there....... This is a rough draft of the final script. I will shorten it...eventually =P
__________________
-Boco
 


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 11:32 AM.


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