Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Chest Template (https://forums.graalonline.com/forums/showthread.php?t=46955)

Loriel 08-09-2003 08:54 PM

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 :(

faenix 08-10-2003 04:47 PM

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 :rolleyes:

Loriel 08-10-2003 05:05 PM

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.

faenix 08-10-2003 05:08 PM

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... ^^

Loriel 08-10-2003 05:39 PM

This one is bad by design, though.

TB3 08-10-2003 06:57 PM

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 ;)

Destorm 08-10-2003 07:10 PM

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

mhermher 08-10-2003 07:18 PM

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.

Loriel 08-10-2003 07:20 PM

See it as a challenge to spot the errors :)

wonderboysp2p 08-11-2003 12:32 AM

loriel fooled us all!! we thought he was givin us a cool script but instead he gave us a test!!! ooooh :megaeek:

Kaimetsu 08-11-2003 05:14 AM

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.

SaijinGohan 08-11-2003 05:44 AM

Hmm. Thats pretty nice loriel. It's not 'perfect' but it's useable. I think I'll add to it.

GoZelda 08-12-2003 03:59 PM

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;
}

Kaimetsu 08-12-2003 04:26 PM

Because that has far less functionality and won't work on any server?

GoZelda 08-12-2003 06:53 PM

Oh yes i forgot about those two unimportant things.


All times are GMT +2. The time now is 02:52 AM.

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