Aegis Support Board: Nome's Guides - Aegis Support Board

Jump to content

ASB News! ASB 5.0 Beta V2 has now been released!. See here for more Info.

  • 5 Pages +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • This topic is locked

Nome's Guides Guides for NPC Scripting and More

#1 User is offline   Nome 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 181
  • Joined: 21-March 03

Posted 09 April 2003 - 07:05 PM

In here you will find guids for Installing NPCs, Making NPCs, Traders, Items, Mobs. . .and more.

Updated(4/21/03)
Added Altering Item Section.
Added Warp Portal Section.
0

#2 User is offline   Nome 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 181
  • Joined: 21-March 03

Posted 09 April 2003 - 07:08 PM

Making a NPC

First start off with the concept. What is it suppose to do? Who is it for? Does it require items? Is money involved? You should know this stuff before hand. I suggest writing the idea down.

Next is the research step.
You will need to know where to put the NPC, the easiest way to do this is to go to the exact spot you want to put this npc and type the /where command and write down those coordinates.
Then check to see which npc you would like to use. (There is a list in the mobname.txt file*)
Find out the name of the items as it appears in the database and not in the game. You will need to know the exact item name if you wish to make a working NPC script.

Building the NPC Script
All NPC Scripts should follow this basic structure.
npc "map" "name" spritename xpos ypos dir W H
OnClick:
<--Script Body-->
return


Break Down

Quote

npc "map" "name" spritename xpos ypos dir W H
  • npc - this declares the type of npc (npc, trader, guide, warp, mob -- I'll only cover npc)
  • "map" - you must enter the correct map name (ie. prontera, prt_fild01, moc_fild04, etc.,)
  • "name" - this is the name that appears under the NPC Sprite in game
  • spritename - This is where you declare the sprite to use. (ie., 4_F_Kafra1, 1_M_01, 8_F_Girl, etc.,)
  • xpos - This is the x position on the map (the first number from the /where command)
  • ypos - this is the y position on the map (the second number from the /where command)
  • dir - This decalres the direction the npc will face (This is a number value of 1-8)**
  • W - Honestly I am not sure what this really is. (I just put a 5 in here as default)***
  • H - Honestly I am not sure what this really is. (I just put a 5 in here as default)***

* There is no easy way to know what they look like, short of unpaking all the spr files or loading them into a line up on a map
** Some sprites do not have backsides so they will always face forward if you spin the camera around.
***I believe these are for the clickable area around the npc sprite, but I haven't proven that yet.


Commands for the Script Body
These are just a few of the more common ones.

[/list]

Quote


dialog
dialog "Hello, this is an example."

wait
---just type wait---

Quote

if
if v[VAR_MONEY] > 5000

else
---this declares what will happen when the if statement is not met.---

endif
---this ends the if - else statement---

Quote

choose menu
choose menu "Option 1" "Option 2" "Option 3" "Option 4"

case #
case 1 ---declares what will be done when it's option is selected---

break
---just type break, declares when the end of a case has been reached---

endchoose
---type by itself declares the end of the choose menu---

getgold
getgold 1000 ---give the palyer money, number entered behind it is the amount given---

dropgold
dropgold 1000 ---takes money from the player, number is ammount taken away---

getitem
getitem Jellopy 30 ---gives item to the player, item's name, ammount to be given---

dropitem
dropitem Jellopy 30 ---takes item from player, item's name, ammount to be taken---

close
---type by itself, closes a dialog window.---

Quote

while
while(1) ---This keeps a choose menu window open until canceled---

endwhile
endwhile ---Marks the end of the choose menu section to remain open---

exitwhile
exitwhile ---Continues script when window held open by while is closed.---

Commands grouped together need to be used together.
**Exception: Else does not always need to be used with an if statement, however it cannot be used outside an if statement.


Sample
npc "prontera" "Myname" 1_F_01 155 187 3 5 5
OnClick:
 dialog "[Myname]"
 dialog "Hello, I am a sample NPC to help show you how a script works."
 wait
 dialog "I'd like to offer you a selection or two.  So please choose one."
 while(1)
  choose menu "Get & Give Money." "Get & Give Item." "Nevermind."
  case 1
   dialog "[Myname]"
   dialog "I'll give you some money now."
   givegold 5000
   wait
   dialog "[Myname]"
   dialog "I'm sorry, but I must take it back now."
   dropgold 5000
   wait
   dialog "[Myname]"
   dialog "This has been a test.  Hehe."
   close
  break
  case 2
   dialog "[Myname]"
   dialog "Now we do the item give and get."
   getitem  Red_Gemstone 10
   wait
   dialog "[Myname]"
   dialog "Now I take it back, thanks for holding them."
   dropitem Red_Gemstone 10
   wait
   dialog "[Myname]"
   dialog "Well, you didn't get anything, but you got to see how I work.  Enjoy."
   close
  break
  case 3
  close
  return
  break
endchoose
endwhile
exitwhile
return

Things to know
Maximum character length for an npc to display per dialog command is 250.
0

#3 User is offline   Nome 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 181
  • Joined: 21-March 03

Posted 09 April 2003 - 07:09 PM

Installing a NPC Script
Foreword
Since this question comes up and most likely will come up a bit more. I'll try to make an easy-to-use painless guide to getting your custom made NPCs into the game.

There are 2 ways you can do it.

Option 1
  • Get your NPC script
  • Go to zone/npcdata/npc/NPC
  • Click on npc.sc
  • Add the new NPC script to the end of npc.sc
  • I suggest making a comment that lets you know what script it is when you go back to it.
  • Save the file
  • Close the file
  • Load up Zone Server
  • If you get a failed to compile npc.sc error
    • Close Zone
    • Go back to npc.sc
    • Look over your new script and make sure it's coded right
      • Dialog should have both quotes ""
      • if statements should use [ ] and not { }
      • Make sure you use the database names for items from itp.txt
      • Make sure your other variables match up to database names
      • Choose menu needs and Endchoose
      • If statements need endif
      • case statements need break
      • should always end an npc script with return


Option 2
**This is for those of you who plan to make more than 1 or 2 NPC
  • Have your NPC script ready in its own .sc file
  • Make a folder, name it whatever you want (for this guide I'll call it mynpc)

    Quote

    Make sure the folder is located in the zone/npcdata directory

  • Put the new .sc file into the folder mynpc
  • Go to zone/npcdata
  • Open the List.txt file
  • I suggest near the top, put:
    // mynpc Data
    ./npcdata/mynpc/scriptfilename.sc

  • Save List.txt as a text file and close
  • Run Zone Server to see if it loads
  • If it fails, see trouble shooting list from Option 1

* mynpc can be replaced with whatever name you want
** you should keep scriptfilename relativly short (some long names don't work)
*** if you put the wrong file name in list.txt, your zone server will not start.
**** You can also check the nps.asm file if an error pops up. It shoudl give you the exact line that is erroneous. (Thanks guryushka)
0

#4 User is offline   Nome 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 181
  • Joined: 21-March 03

Posted 09 April 2003 - 07:11 PM

Adding & Altering mobs in mob.sc
The way I found for increasing NPCs in the game. was to edit the mob.sc file.

With the mob.sc file, you have control over what spawns where, how many spawn in that map, if they are special spawns, where they can spawn.

You can add monsters if you want. I have added Santa Porings on my server and everyone seemed to enjoy that. If you have the Zone2 mob.sc, you can increase or decrease the amount of plants and mushrooms tha are in game. You can add monsters to maps that they aren't suppose to be in. My prontera city kinda has a weed problem, plants keep sprouting up everywhere.
putmob "map" x1 y1 x2 y2 # MONSTER minTime maxTime mobType

sample:
putmob "prt_fild01" 0 0 0 0 10 PORING 0 0 0

this code is the syntax they use.

putmob = command for placing the mob
"map" (map name) = this is the name of the map the monster shows up on
x1 = X coordinate on map monster will spawn at
y1 = Y coordinate on map monster will spawn at
x2 = This will give a radius to that spawn point, meaning a monster can spawn x2 squares from x1
y2 = This will give a radius to that spawn point, meaning a monster can spawn y2 squares from y1
# = This is the number of monsters per map (this is what you change on most statements there to increase or decrease your NPC count)
MONSTER = This is the monster's name from the database.
minTime = Minimum time for monster to spawn after death (this is what I think)
maxTime = Maximum time for monster to spawn after death (this is what I think)
mobType = If you change this, it give the monster a different monster quality from it's default. (By that I think you can make porings aggressive or supportive, I haven't messed with this, so I'm unsure)

If someone finds out anything different about what the stuff actually means, please let me know. Cause this is what I think I've found out so far.
0

#5 User is offline   Nome 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 181
  • Joined: 21-March 03

Posted 09 April 2003 - 07:11 PM

How to make a TRADER to come soon
0

#6 User is offline   Nome 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 181
  • Joined: 21-March 03

Posted 09 April 2003 - 07:12 PM

How to Alter Item Properties
or add to them

Foreword
This will explain how special items work. How you can alter them, add to them or even take away from them. Also if you think more into it, you will also be able to add properties to existing items. However, I should warn you. . . if you alter an item to much, it may cause the game to crash, or your zone will not load. Please take care in what you do.

Let's Start.

Quote

Steps
1. Go to  zone/itemdata directory and look for a file called special.sc
2. Open special.sc
3. Find the item you wish to modify/alter
4. Save the file
5. Restart or start up zone.


For the example I will be using the Proring Card (Poring_Card)

Basic setup of all items

Quote

item itemname
event eventtype:
actiontype
return

or

item itemname
event eventtype:
actiontype
return
event eventtype:
actiontype
return


Quote

Poring Card Setup

item Poring_Card
  event OnStartEquip:
   AddExtParam User VAR_LUKAMOUNT 1
  return
  event OnFinishEquip:
   SubExtParam User VAR_LUKAMOUNT 1
  return


item of course specifies what item gets the following properties.
event declares what kind of event will trigger the action
the action applies the affect to the character, item . . whatever.
return specifies the end of an event and tells the game to stop processing the actions and wait for the next event.

in the Poring Card example you see "user" this is one of two variables that can be used. Namely User is used for equiped items. The other is "target". I haven't tested this out, but based off the yggdrasil leaf, upon item use you can select a target other than yourself to use this on. So in theory, if you wanted to, you can add Jellopy to this file and use this
OnUseItem target HealHP 50
and jellopies will now heal a person you select for 50 hp. Again, in theory so don't hold me to it ^_^

Some items are usable only once and these usually follow the first basic layout
other items such as weapons, armor or cards will usually follow the 2nd setup.

Since there really isn't much else for me to explain, I'll list events and actions that can be used.

Events:
OnStartHolding - When the item enters your inventory (only character inventory not storage or cart)
OnStartEquip - When the character equips the item
OnFinishHolding - When item leave inventory
OnFinishEquip - When the character unequips the item
OnUseItem - When an item is used with a double click
OnAttacked - When character is attacked
OnConsume - Character consumes the item like apples or something
OnAtttack - When the character attacks

Actions:*
AddExtParam Adds extra parameters to a stat or other variable
SubExtParam Subtracts extra parameters to a stat or other variable
HealHP Heals HP (O.O)
HealSP Heals SP (o.O)
EnableSkill enables a skill
DisableSkill disables a skill

* You can find a bigger list of actions to use in the std.sc file. And there are many more, I just listed the basics anyone would really want to use

I would go on, but if I do, all I'd be showing you are examples, which you can see alot more yourself if you look thorugh the special.sc file. You will see examples of how most of the unlisted actions are used.. . you will see examples of how the listed actions are used and the syntax in which you must use.

I will leave you with this. If you add 10 actions, namely skill additions the item will not work, and probably crash your game.
0

#7 User is offline   Nome 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 181
  • Joined: 21-March 03

Posted 09 April 2003 - 07:13 PM

Making a Warp Portal

Making a warp portal is like making an NPC

Quote

Basic structure
warp "mapname" "description" xpos ypos w h
OnTouch:
moveto "mapname1" xpos1 ypos1
return


That's pretty much it

mapname = Name of map portal appears in
description = let you know what the protal does
xpos = x coordinates of portal location
ypos = y coordiantes of portal location
w = width of portals active area (left to right)
h = height of portals active area (top to bottom)
mapname1 = name of map character is teleported too
xpos1 = x coordinates of where character is telelported
ypos1 = y coordinates of where character is telelported

Not much too it, get xpos and ypos by checking the map in game, that's the best way

Ideas, you might want to try.

Since warp portals use the same enum.sc and std.sc files, I'm sure you can add hpfullheal and spfullheal and the characters are fully healed when they come out the other side. It'd be nice if you set up a map with a constant spawn of boss monsters. Just keep in mind you can do something with warp scripts that you can do with npc scripts.
0

#8 User is offline   Raven 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 105
  • Joined: 10-April 03

Posted 20 April 2003 - 07:42 PM

what if i want to make a npc quest that has requirement, such as...u need to talk with a certain npc first before the npc event happen? do i need to use variable like job_sw_01 ...and how to put that variable into the database?
0

#9 User is offline   Nome 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 181
  • Joined: 21-March 03

Posted 20 April 2003 - 08:05 PM

I'll try to add another section that will explain how to do it :lol:.
0

#10 User is offline   JechtSphere 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 7
  • Joined: 20-April 03

Posted 22 April 2003 - 01:06 AM

What about... an NPC that takes given items, and when those items are provided, then an item of the player's choice is given. Not just ANY item of their choice, but one of two. Will that be covered in trader? And how soon? ^_^
0

#11 User is offline   global 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 150
  • Joined: 28-April 03

Posted 29 April 2003 - 03:55 PM

what i need program i need for open npc.sc can't open files with sc .. plz help :lol:
0

#12 User is offline   Shuugo 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 122
  • Joined: 25-March 03

Posted 29 April 2003 - 04:08 PM

global, on Apr 29 2003, 07:55 AM, said:

what i need program i need for open npc.sc can't open files with sc .. plz help :lol:

Right click, open with..., and choose notepad if you are using win2k
It just a txt file.
0

#13 User is offline   global 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 150
  • Joined: 28-April 03

Posted 29 April 2003 - 04:33 PM

K WOOT!! thx :lol:
0

#14 User is offline   Nome 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 181
  • Joined: 21-March 03

Posted 30 April 2003 - 09:38 PM

I'll not be updating or adding to this thread anymore, as I am stepping down from anything RO related.

~Laters
0

#15 User is offline   sixbenz_511 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 57
  • Joined: 24-March 03

Posted 30 April 2003 - 10:04 PM

too bad.. hf with whatever ur gonna do..
0

#16 User is offline   Raven 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 105
  • Joined: 10-April 03

Posted 01 May 2003 - 06:57 AM

whyyyyyyyyyy?
0

#17 User is offline   Kinjin 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 248
  • Joined: 06-May 03

Posted 12 May 2003 - 11:07 PM

Is there a list somewhere that crossreferences mobname.txt to the actual sprites?
0

#18 User is offline   AznJimbo 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 30-May 03

  Posted 06 June 2003 - 10:49 PM

Hmmmm how do we get more than 1 npc? do we make another txt and put everything in or we put space and put anotehr npc name?
0

#19 User is offline   Angela 

  • Average Member
  • PipPipPipPip
  • Group: Members
  • Posts: 161
  • Joined: 21-April 03

  Posted 06 June 2003 - 11:31 PM

it doesn't matter!
if you choose to organize your npcs and make seperate files for them instead of putting 60000000000 of them in one huge file, make sure you update your list.txt to load those new npc text files as well.

Best Regards,

^^;;
0

#20 User is offline   AznJimbo 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 5
  • Joined: 30-May 03

Posted 06 June 2003 - 11:48 PM

hmmm i don't get thisss and i need a full explanation because i plan on making a server..
hmmmm ok list? and ZONE? what is zone jeesh so confusing
0

Share this topic:


  • 5 Pages +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users