Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-09-2003, 08:54 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Chest Template

I just spontaneously scripted a univeral chest NPC that could perhaps replace the default one. Dunno, comment it.

If you decide to use it, make sure to replace the parts that are obviously placeholders

NPC Code:

function chest_open() {
// What should happen once the chest is opened, playerrupees ++ or so
}
if (created) {
setstring this.mystring,SOME_UNIQUE_NAME;
}

join chests;
//#CLIENTSIDE
if (created) {
// Same as already done serverside
setstring this.mystring,SOME_UNIQUE_NAME;
// Optional:
setstring this.image_open,your_chest_graphic;
setstring this.image_closed,your_chest_graphic;
this.part_open = { params for setimgpart };
this.part_closed = { params for setimgpart };
// End Optional
setstring this.image_chestitem,graphic_for_item_in_chest;
this.part_chestitem = { params for changeimgpart };
init();
}



class chests:
NPC Code:

if (created)
setshape 1, 32, 32;
if (actionchest_open) {
if (strtofloat(#p(0)) == id) {
if (lindexof(#s(this.mystring), clientr.chests_opened) < 0)
addstring clientr.chests_opened, #s(this.mystring);
chest_open();
}
}
//#CLIENTSIDE
if (playertouchsme) {
if (playery - y == 1 && this.active == true) {
triggeraction x+1, y+1, chest_open, #v(id);
this.active = false;
setimgpart #s(this.image_open), this.part_open[0], this.part_open[1], this.part_open[2], this.part_open[3];
play chest.wav;
showimg 200, #s(this.image_chestitem), x+1 - this.part_chestitem[2]/32, y+0.5 - this.part_chestitem[3]/32;
changeimgpart 200, this.part_chestitem[0], this.part_chestitem[1], this.part_chestitem[2], this.part_chestitem[3];
sleep 2;
hideimg 200;
}
}
function init() {
if (lindexof(#s(this.mystring), clientr.chests_opened) < 0)
this.active = true;
else this.active = false;

if (strlen(#s(this.image_open)) < 1) setstring this.image_open, default_open_graphic;
if (!strlen(#s(this.image_closed)) < 1) setstring this.image_closed, default_closed_graphic;

if (arraylen(this.part_open) < 1) this.part_open = {default params};
if (arraylen(this.part_closed) < 1) this.part_closed = {default params};

if (this.active == false) setimgpart #s(this.image_open), this.part_open[0], this.part_open[1], this.part_open[2], this.part_open[3];
else setimgpart #s(this.image_closed), this.part_closed[0], this.part_closed[1], this.part_closed[2], this.part_closed[3];
}



As I just typed it from scratch, it sure contains some major logical and typistic flaws, please tell me about them.
I suggest that these chests are secured not only by unwalkable tiles or whatever, but by putting them into a seperate level, as it is in theory possible to trigger the chest_open action without in fact touching the chest, using trainers.
Also, they obviously only work with the standard chest size of 2x2 tiles

Last edited by Loriel; 08-10-2003 at 05:07 PM..
Reply With Quote
  #2  
Old 08-10-2003, 04:47 PM
faenix faenix is offline
Registered User
Join Date: Jul 2003
Posts: 56
faenix is on a distinguished road
hmm interesting what does it do that the default one doesnt? i guess it's more versatile in some ways but then i think that the default ones provides enough for players who are using chests anyway... if a player wants more out of the chest it should be their job to script it themselves
__________________
In a mad world, only the mad are sane.
Reply With Quote
  #3  
Old 08-10-2003, 05:05 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Well, why should they have to if I already did the job, and there is more interesting stuff to do?

btw, I recommend not using my script as it is horribly buggy.
Reply With Quote
  #4  
Old 08-10-2003, 05:08 PM
faenix faenix is offline
Registered User
Join Date: Jul 2003
Posts: 56
faenix is on a distinguished road
hehe hmm yea... its hard to make a bugless gscript i think anyway theres just so many situations that not all of them could possibly be tested. but i guess that's true for all games which is why there's beta versions and testing and etc...
__________________
In a mad world, only the mad are sane.
Reply With Quote
  #5  
Old 08-10-2003, 05:39 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
This one is bad by design, though.
Reply With Quote
  #6  
Old 08-10-2003, 06:57 PM
TB3 TB3 is offline
Registered User
TB3's Avatar
Join Date: May 2001
Location: US of A State of VA
Posts: 658
TB3 is on a distinguished road
Send a message via Yahoo to TB3
I made one on fah that was a replica of the one that is built in graal except you could change every single aspect it even set a flag subject to its level and placement but it was like zco instead of co flags
It used a showimg for showing what contents poped out though but still had same everything it could however be set that once a person opened it others couldnt or that everyone could open it once.

I like yours too though i havent tested it but the way it looks it seems stable
__________________

To the sun of your age, I arise
Reply With Quote
  #7  
Old 08-10-2003, 07:10 PM
Destorm Destorm is offline
Owner of Leviathan?
Destorm's Avatar
Join Date: Apr 2003
Location: England
Posts: 161
Destorm is on a distinguished road
Send a message via AIM to Destorm
Erm, posting full scripts is against the rules if I remember rightly but thats not my problem...anyways posting a script which is terribly buggy is going to do nothing but confuse new scripters who will try and learn from your script and learn your mistakes as being correct X_x
__________________

-Make sure you lock every thread you can Mods-
Reply With Quote
  #8  
Old 08-10-2003, 07:18 PM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
Quote:
Originally posted by Destorm
Erm, posting full scripts is against the rules if I remember rightly but thats not my problem...anyways posting a script which is terribly buggy is going to do nothing but confuse new scripters who will try and learn from your script and learn your mistakes as being correct X_x
Pardon me while i laugh, ha + ha... + ha!


Anyways, i'm using this script, i added some new features as *wont name* and *no name*.

me and loriel fixed almost all bugs tough.
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #9  
Old 08-10-2003, 07:20 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
See it as a challenge to spot the errors
Reply With Quote
  #10  
Old 08-11-2003, 12:32 AM
wonderboysp2p wonderboysp2p is offline
Registered User
wonderboysp2p's Avatar
Join Date: Sep 2002
Location: -Wonderboy
Posts: 537
wonderboysp2p is on a distinguished road
Send a message via AIM to wonderboysp2p
loriel fooled us all!! we thought he was givin us a cool script but instead he gave us a test!!! ooooh
__________________

we are the llama FORUms!!!EWQ Ce13d5423f23!! 2e1 @$6tgv3uy65!
Reply With Quote
  #11  
Old 08-11-2003, 05:14 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally posted by Destorm
Erm, posting full scripts is against the rules if I remember rightly
No, that's only if the script is in response to a request for such.
__________________
Reply With Quote
  #12  
Old 08-11-2003, 05:44 AM
SaijinGohan SaijinGohan is offline
Registered User
SaijinGohan's Avatar
Join Date: Jul 2001
Location: U.S.A - Ohio
Posts: 536
SaijinGohan is on a distinguished road
Send a message via AIM to SaijinGohan Send a message via MSN to SaijinGohan
Hmm. Thats pretty nice loriel. It's not 'perfect' but it's useable. I think I'll add to it.
__________________

Job: A Legend

And you think that you have played Graal forever? Ha!
Reply With Quote
  #13  
Old 08-12-2003, 03:59 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Why don't we just use

if (created){
setimg chest.png;
this.opened=false;
} if (playertouchsme){
play chest.wav;
//give items
setimg chestopen.png;
this.open=true;
}
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #14  
Old 08-12-2003, 04:26 PM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Because that has far less functionality and won't work on any server?
__________________
Reply With Quote
  #15  
Old 08-12-2003, 06:53 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Oh yes i forgot about those two unimportant things.
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
Reply


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 01:03 PM.


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