Graal Forums

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

lordhelmut 01-20-2002 04:46 PM

Custom NPC
 
Alright I need someone fairly good at scripting. I am trying to learn and I need a kinda mini tutorial here. Can someone take me through a short step by step process for scripting things like animals, baddies or anything with custom sprites. I kinda know something about u gotta make variables that deal with how many hearts and speed and such but thats about it. If someone is willing to help I would gladly appreciate it.

lordhelmut 01-20-2002 04:47 PM

1 Attachment(s)
just for an example lets use this...

royce 01-20-2002 05:10 PM

Quote:

Originally posted by lordhelmut
just for an example lets use this...
#1. Do you want to use showimg or use gani?

lordhelmut 01-20-2002 05:35 PM

im trying to learn for free so showimg i guess

Mrmicro 01-20-2002 06:38 PM

*setcharani GANINAME,; - Sets a NPCs Gani

*setani GANINAME,; -Sets players Gani

Shard_IceFire 01-20-2002 11:22 PM

Mrmicro did you read his message??
Quote:

Originally posted by lordhelmut
im trying to learn for free so showimg i guess

Sennema 01-20-2002 11:59 PM

Re: Custom NPC
 
Quote:

Originally posted by lordhelmut
Alright I need someone fairly good at scripting. I am trying to learn and I need a kinda mini tutorial here. Can someone take me through a short step by step process for scripting things like animals, baddies or anything with custom sprites. I kinda know something about u gotta make variables that deal with how many hearts and speed and such but thats about it. If someone is willing to help I would gladly appreciate it.
I'll help you out as much as I can. First, you'll need to either know the dimensions of the image (like the width/height of each sprite, and the starting x/y of each sprite so that they're the same size). Then, you'd need to set variables like:
this.hearts=heartcount;
this.speed=speed; (normal speed is about 0.2 or 0.3, can't remember which one).
Then, you'd need to do an if (created){} stuff, which sets the variables, and the image and junk. You'd use showimg, for showing it. Then, you'd need to use a changeimgvis index,3; (3 is the same level as the player on the board). Then you'd need changeimgpart index,x,y,width,height; (x and y are the starting x/y of the current sprite, and width and height are how many pixels to display following the starting x/y).

That's all jumbled together, I know, so if you have problems understanding it (I have a lot of trouble understanding some of the things I write sometimes), let me know, and I'll spend a little more time on this sort of thing. Or just ask someone else. Either one works.

lordhelmut 01-21-2002 12:18 AM

Re: Re: Custom NPC
 
Quote:

Originally posted by Sennema


I'll help you out as much as I can. First, you'll need to either know the dimensions of the image (like the width/height of each sprite, and the starting x/y of each sprite so that they're the same size). Then, you'd need to set variables like:
this.hearts=heartcount;
this.speed=speed; (normal speed is about 0.2 or 0.3, can't remember which one).
Then, you'd need to do an if (created){} stuff, which sets the variables, and the image and junk. You'd use showimg, for showing it. Then, you'd need to use a changeimgvis index,3; (3 is the same level as the player on the board). Then you'd need changeimgpart index,x,y,width,height; (x and y are the starting x/y of the current sprite, and width and height are how many pixels to display following the starting x/y).

That's all jumbled together, I know, so if you have problems understanding it (I have a lot of trouble understanding some of the things I write sometimes), let me know, and I'll spend a little more time on this sort of thing. Or just ask someone else. Either one works.

Thank you, the main part I need to focus on is the sprites changing part. Like how to make the sprites change or something. The script I have seen before were like dog.gif*64 bla bla and I need to figure that part out most =D

Sennema 01-21-2002 12:56 AM

Hmm... it might work that way, but I haven't seen anything like that. Say each sprite was a square that was 50*50 pixels each.

To get the first image you'd use something like
NPC Code:

showimg 101,bogo_dog0.gif,x,y;
changeimgpart 101,0,0,50,50;
changeimgvis 101,3;



That would show the first sprite, the still dog from behind. Now, say you wanted the image of the dog sitting down while facing toward the player. You'd just do something like:

NPC Code:

if(dir=2&&stuff){
changeimgpart 101,100,250,50,50;
}



That would take the image and edit the part that's showing, giving you the dog sitting down. The actual dimensions are a little different that a 200*300 pixel image, but that's the general idea. Hope that helped.

lordhelmut 01-21-2002 02:13 AM

I think there is some kinda formula that people use that changes the sprites

Sennema 01-21-2002 02:35 AM

Yeah, your probably right. But I don't know what it is... sorry.

lordhelmut 01-21-2002 03:41 AM

If I take it out of one of the NPC's on Babylon think you could figure it out?

Sennema 01-21-2002 03:48 AM

Quote:

Originally posted by lordhelmut
If I take it out of one of the NPC's on Babylon think you could figure it out?
Yeah, I could probably figure it out then. All I'd need would be the images and the parts of the script that do the showing (Don't worry I won't steal or anything, I'm not into that type of thing).

lordhelmut 01-23-2002 09:06 AM

found it!

if (this.dir==3) setgifpart b_greenbird.png,192,this.sprite*32,64,32;

its the last part of that...

Saga2001 01-23-2002 03:42 PM

Quote:

Originally posted by Shard_IceFire
Mrmicro did you read his message??

mrmicro: no i was too busy picking my nose.

Saga2001 01-23-2002 03:46 PM

actually what i suggest is a simple code that is like x=dir*50 and than it places the cursor there, its very useful, does anyone know where i could get some idea of what all the drawingheights for changeimgvis are? cause i am in the dark on that one thing.

btedji 01-23-2002 08:24 PM

"npcprogramming.doc" in graal folder

Sennema 01-24-2002 05:40 AM

Quote:

Originally posted by Saga2001
actually what i suggest is a simple code that is like x=dir*50 and than it places the cursor there, its very useful, does anyone know where i could get some idea of what all the drawingheights for changeimgvis are? cause i am in the dark on that one thing.
Yeah, you should check the npcprogramming.doc, but basically it's like this:

1- below player
2- same level as player
3- above player
4- on the screen
and I heard that 5-10 draw overtop of 4, on the screen. I never read anything about that though...

lordhelmut 01-25-2002 11:10 AM

what is this? I saw it in one of Xaviars scripts its like dirgo = {-1,0,1,2,3} blah blah or something. I also saw it in a tutorial by Ace

Saga2001 01-26-2002 12:14 AM

bogo_dog.png...lol

lol

npcserver.doc in the your mom folder.

OutlawP2P 01-26-2002 01:42 AM

Quote:

Originally posted by Saga2001
bogo_dog.png...lol

lol

npcserver.doc in the your mom folder.


wtfs you dont make any sense stop it!

lordhelmut 01-26-2002 02:42 AM

what would have to be added to a baddy to make it work for many players? I have had bad experiences with the bats and stuff on babylon and if 2 or more people come in they freeze

lordhelmut 01-26-2002 03:46 AM

// NPC made by Lord Helmut
//widthofsprites=91
//heightofsprites=105
if(created){
this.xpos=x;
this.ypos=y;
this.hearts=20;
this.speed=1;
this.dir=0;
this.sprite=0;
setimgpart #f,91*2,0,91,105;
}
if(playersays(hi)){
timeout=.05;
}
if (timeout){
if (this.xpos>playerx){this.xpos-=this.speed};
if (this.ypos<playery){this.ypos+=this.speed};
if (this.xpos<playerx){this.xpos+=this.speed};
if (this.ypos>playery){this.ypos-=this.speed};
timeout=.05;
}

I did this so far but the character wont move =(

lordhelmut 01-26-2002 10:52 AM

please help?

Gohan43331 01-26-2002 11:19 AM

add this in your timeout sequence:
NPC Code:

x = this.xpos;
y = this.ypos;



and you for the setimg part try this: (based off your second post's image;
NPC Code:

setimgpart #f,91*16,0,45.5,52.5;



and when that dog gets moving, it's super fast...
NPC Code:

this.speed=.3 // or .4 which is graalian speed(about)



G'luck mate,
Gohan

Gohan43331 01-26-2002 11:20 AM

Quote:

Originally posted by lordhelmut
I did this so far but the character wont move =(
Character moving? Is the character supposed to move towards the dog or vica versa?


All times are GMT +2. The time now is 09:21 PM.

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