Graalians

Graalians (https://www.graalians.com/forums/index.php)
-   Creative Corner (https://www.graalians.com/forums/forumdisplay.php?f=17)
-   -   Tutorial: Creating a character NPC (https://www.graalians.com/forums/showthread.php?t=5548)

Emera 04-14-2012 04:19 PM

Tutorial: Creating a character NPC
 
I've been receiving numerous messages asking how to create a character NPC in the Graal Editor or Gonstruct. It's been really hard to explain over iPhone PM's and I think it'll be easier to explain in a forum thread. I'll be showing you how to create a character NPC step-by-step in the Graal Editor and Gonstruct.

Graal Editor
Spoiler

After you've opened your editor, you'll need to click the baddies,npcs,chests radio button on the far right panel. This will bring you to the NPC menu. From there we can drag and drop NPC's from the pane to the level. We're not going to be using the "noob" looking NPC though. This is scripted in GS1, and Graal currently uses GS2. Drag the outlined NPC character to the left of the "noob" on to the level.


As soon as you've dragged the NPC, the script editor window will appear. You will need to remove everything in the text box so it's blank and copy in the code in the image. Now, after you've done that you can edit the code so the NPC will look how you would like it to look. Edit the lines that say this.<feature> so that the NPC will be wearing what you want it to wear. this.attr[1] is the hat image. The lines that say this.colors[0] for example are the sleeves, coat, belt, shoes and skin colour of your NPC. They use this format.

colors[0] = hands
colors[1] = body
colors[2] = sleeves
colors[3] = shoes
colors[4] = belt



Gonstruct
Spoiler

After you've opened Gonstruct, you'll need to click the Tools tab on the far right pane in the editor. This will bring you to the NPC's pane. From there, you'll need to click New NPC. This will create a new NPC in the level.


After that, you'll need to double click the NPC to open up the script editor. Copy the script in the image into the script editor and edit the lines so the NPC looks how you'd like it to look as you are told in the Graal Editor tutorial. Edit the lines that say this.<feature> so that the NPC will be wearing what you want it to wear. this.attr[1] is the hat image. The lines that say this.colors[0] for example are the sleeves, coat, belt, shoes and skin colour of your NPC. They use this format.

colors[0] = hands
colors[1] = body
colors[2] = sleeves
colors[3] = shoes
colors[4] = belt



NPC Code

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
showCharacter();
  
  
this.body "body1.png";
  
this.head "head1.png";
  
this.shield "shield1.png":
  
this.attr[1] = "hat1.png";
  
this.colors[0] = "red";
  
this.colors[1] = "blue";
  
this.colors[2] = "green";
  
this.colors[3] = "purple";
  
this.colors[4] = "black";
  
this.ani "idle";
  
this.chat "Hello Graalians!";


That's it for the tutorial. If you have any questions to do with the tutorial or you need further information on creating NPC's, post here and I'll help you out. If you've enjoyed reading this tutorial or it's helped you out, a bit of green http://forums.graalonline.com/forums...reputation.gif is always welcome!

Cigam 04-14-2012 04:28 PM

Loved it! +Rep!

Emera 04-14-2012 04:29 PM

Thank you! Glad you liked it.

Cigam 04-14-2012 04:30 PM

Quote:

Posted by Emera (Post 95317)
Thank you! Glad you liked it.

Yes indeed. I'm 101% this helped me!

MattKan 04-14-2012 04:31 PM

Except you should never use this online as it is GS1, but okay...

Emera 04-14-2012 04:35 PM

Quote:

Posted by MattKan (Post 95324)
Except you should never use this online as it is GS1, but okay...

I mentioned that, but okay.
Quote:

Posted by Tutorial
We're not going to be using the "noob" looking NPC though. This is scripted in GS1, and Graal currently uses GS2.


callimuc 04-14-2012 04:36 PM

Quote:

Posted by MattKan (Post 95324)
Except you should never use this online as it is GS1, but okay...

For NPCs which are just idling around doing nothing special it´s ok to use GS1

Elusive 04-16-2012 02:03 PM

Good job. It will help those not in the know ;D! Any aspiring level artists/scripters need threads to come to, to answer their questions :) +rep when I can.

XENA* 04-16-2012 02:43 PM

Nice thread! :D

Dude1310 04-16-2012 10:59 PM

NPC Code

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
showCharacter();
  
  
this.body "body1.png";
  
this.head "head1.png";
  
this.shield "shield1.png":
  
this.attr[1] = "hat1.png";
  
this.colors[0] = "red";
  
this.colors[1] = "blue";
  
this.colors[2] = "green";
  
this.colors[3] = "purple";
  
this.colors[4] = "black";
  
this.ani "idle";
  
this.chat "Hello Graalians!";


This code contains many errors. I do not know how to fix this in leveleditor, as of i am a new level creator. Please rewrite the code, make sure you fix all the errors, and repost it. THX(:

Twinny 04-17-2012 01:28 AM

Quote:

Posted by Dude1310 (Post 96886)
NPC Code

PHP Code:

//#CLIENTSIDE
function onCreated() {
  
showCharacter();
  
  
this.body "body1.png";
  
this.head "head1.png";
  
this.shield "shield1.png":
  
this.attr[1] = "hat1.png";
  
this.colors[0] = "red";
  
this.colors[1] = "blue";
  
this.colors[2] = "green";
  
this.colors[3] = "purple";
  
this.colors[4] = "black";
  
this.ani "idle";
  
this.chat "Hello Graalians!";


This code contains many errors. I do not know how to fix this in leveleditor, as of i am a new level creator. Please rewrite the code, make sure you fix all the errors, and repost it. THX(:

Actually, this code is correct GS2. However, this will not run in level editor as previously stated above as level editor can only handle GS1, an archaic procedural language. In order to see the character NPC, you will need to upload this level to a Graal Server.

If you need to see the character offline, place a template character from the official Level Editor and simply modify the present values. Since this template is GS1, it will show.

Emera, I will add that you need to specify shieldpower otherwise it will not function properly.

Emera 04-17-2012 08:00 AM

Quote:

Posted by Twinny (Post 97008)
Actually, this code is correct GS2. However, this will not run in level editor as previously stated above as level editor can only handle GS1, an archaic procedural language. In order to see the character NPC, you will need to upload this level to a Graal Server.

If you need to see the character offline, place a template character from the official Level Editor and simply modify the present values. Since this template is GS1, it will show.

Emera, I will add that you need to specify shieldpower otherwise it will not function properly.

Thank you! I'll add that on later today when I've got the chance.

Revo* 04-17-2012 08:06 AM

Wish I had a computer :(

RenoDorvay 04-17-2012 08:18 AM

Awesome job :) I like it

Tricxta 04-17-2012 09:08 AM

how to count to 10 in gs1:
PHP Code:

for (this.i=0;this.i<10;this.i++){
  
message #v(this.i);
  
sleep 1;


K, I'll have my rep now thanks

callimuc 04-17-2012 01:13 PM

Quote:

Posted by Tricxta (Post 97281)
how to count to 10 in gs1:
PHP Code:

for (this.i=0;this.i<10;this.i++){
  
message #v(this.i);
  
sleep 1;


K, I'll have my rep now thanks

How to do it in GS2:

PHP Code:

function onCreated() {
  for (
this.i=0this.i<10this.i++) {
    
this.chat temp.i;
    
sleep(1);
  }


well I´d use temp.i rather than this.i if you will just need it in the onCreated() part.

Lollo 04-17-2012 01:31 PM

what about making a npc with personal head and body?=o

callimuc 04-17-2012 01:31 PM

Quote:

Posted by Lollo (Post 97345)
what about making a npc with personal head and body?=o

Change the filenames to yours. And make sure the images are 8bit.

Tricxta 04-25-2012 08:00 AM

Quote:

Posted by callimuc (Post 97335)
How to do it in GS2:

PHP Code:

function onCreated() {
  for (
this.i=0this.i<10this.i++) {
    
this.chat temp.i;
    
sleep(1);
  }


well I´d use temp.i rather than this.i if you will just need it in the onCreated() part.

your game of the obvious is here by accepted.

How to count from 10 to 1 in GS2:
PHP Code:

function onCreated() {
  for (
this.i=10this.i>=0this.i--) {
    
this.chat temp.i;
    
sleep(1);
  }



callimuc 04-25-2012 08:04 PM

Quote:

Posted by Tricxta (Post 102132)
your game of the obvious is here by accepted.

How to count from 10 to 1 in GS2:
PHP Code:

function onCreated() {
  for (
this.i=10this.i>=0this.i--) {
    
this.chat temp.i;
    
sleep(1);
  }



Maybe its kinda late for me but that should go down to 0 :P

MysticalDragon 05-01-2012 09:20 PM

I would do personally do!
PHP Code:

function onCreated() {
  for (
10>= 0--) {
   
this.chat temp.i;
   
waitfor(this"noevent"1);
  }


And replying to MattKan,
Its not ineffectiveness to use GS1 Characters online, has the same effect as GS2, although it isn't as clean as GS2. Its still perfectly fine.

Godoco 12-31-2012 02:55 PM

I really hate to bump old threads, but what is the GS1 code for implementing a GANI in an NPC?

Emera 12-31-2012 04:19 PM

Quote:

Posted by Godoco (Post 270293)
I really hate to bump old threads, but what is the GS1 code for implementing a GANI in an NPC?

I'm not good with GS1 at all, but I think it's just ani = moo; or charani = moo; under the showcharacter function.

callimuc 12-31-2012 04:22 PM

Quote:

Posted by Godoco (Post 270293)
I really hate to bump old threads, but what is the GS1 code for implementing a GANI in an NPC?

PHP Code:

if (created) {
  
showcharacter//or showcharacter() not sure anymore
  //outfitstuff here
  
setcharani ani,params//if you dont have parameters: setcharani ani,;



Tricxta 12-31-2012 10:13 PM

Quote:

Posted by callimuc (Post 270345)
PHP Code:

if (created) {
  
showcharacter//or showcharacter() not sure anymore
  //outfitstuff here
  
setcharani ani,params//if you dont have parameters: setcharani ani,;



showcharacter is only used if the player's a character, it tells the npc to use **** like a head and what not.

Also due to it being GS1, functions with 0 arguments meant not brackets had to be provided hence what I just said.

Also all commands for GS1 can be found in commands.rtf which should be lying around in some old graal file which you can scavenge from somewhere...


All times are GMT. The time now is 09:21 AM.

Powered by vBulletin/Copyright ©2000 - 2026, vBulletin Solutions Inc.