Custom Items

From Hercules Wiki
Revision as of 10:36, 13 January 2013 by Nameless2you (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Structure

First, let's take a look at the item_db in the db folder, and its structure:

ID,DBName,ScreenName,Type,Price,Sell,Weight,ATK,DEF,Range,Slot,Job,Upper,Gender,Loc,wLV,eLV,
Refineable,View,{Script},{OnEquip_Script},{OnUnequip_Script}
  • ID: ID of the item.
  • DB Name: This first name is the DB name. When you use @item and you know the name of the item, but not the ID, type this name instead. Try making the ScreenName the same as this so you wont get confused.
  • ScreenName: This is the name the server shows.
  • Type: Purpose of the item.
0 = Usable : healing
2 = Usable : other
3 = Misc
4 = Weapon
5 = Armor
6 = Card
7 = Pet Egg
8 = Pet Equipment
10 = Arrow/Ammunition
11 = Usable : delayed consumption (items with script "pet" or "itemskill")
  • Price: Default NPC buying price in Zeny.
  • Sell: NPC selling price in Zeny.
  • Weight: Weight of the item * 10. Means, an item of 0.1 weight each, must be entered as 1.
  • ATK: Base weapon attack, in case of a weapon.
    • In RE enabled servers this field have a optional delimiter : to define this item's weaponMATK bonus, for example, 30:50 would mean the item gives 30 atk and 50 weaponMATK
  • DEF: Base defense for armor-type items.
  • Range: Maximum range in map cells a weapon allows to be the player apart from it's target.
  • Slot: Amount of card slots in weapon/armor-type items.
  • Job: Which jobs this item is available for. Values below can be combined to achieve availability for multiple job classes, i. e. 0x2|0x4 -> 0x6 (Swordman+Mage)
(S.) Novice         (2^00): 0x00000001
Swordman            (2^01): 0x00000002
Mage                (2^02): 0x00000004
Archer              (2^03): 0x00000008
Acolyte             (2^04): 0x00000010
Merchant            (2^05): 0x00000020
Thief               (2^06): 0x00000040
Knight              (2^07): 0x00000080
Priest              (2^08): 0x00000100
Wizard              (2^09): 0x00000200
Blacksmith          (2^10): 0x00000400
Hunter              (2^11): 0x00000800
Assassin            (2^12): 0x00001000
Unused              (2^13): 0x00002000
Crusader            (2^14): 0x00004000
Monk                (2^15): 0x00008000
Sage                (2^16): 0x00010000
Rogue               (2^17): 0x00020000
Alchemist           (2^18): 0x00040000
Bard/Dancer         (2^19): 0x00080000
Unused              (2^20): 0x00100000
Taekwon             (2^21): 0x00200000
StarGladiator       (2^22): 0x00400000
Soul Linker         (2^23): 0x00800000
Gunslinger          (2^24): 0x01000000
Ninja               (2^25): 0x02000000
All Classes               : 0xFFFFFFFF
Every Job Except Novice   : 0xFFFFFFFE
  • Upper: Specifies whether the item can be used by normal, baby or reborn classes. Values below can be combined, i. e. 1|4 -> 5 (Normal+Baby Classes)
    • Note: Setting 2 enables the item for Transcendant and 3rd classes. Use 8 to enable the item for 3rd classes only.
1 = Normal
2 = Reborn Classes (High Wizards, Champions etc.) (includes 3rd classes)
4 = Baby Classes
8 = 3rd Classes
  • Gender: Gender restriction for the item.
0 = Female
1 = Male
2 = No restriction (both)
  • Loc: Equipment location of armor and arrow-type items. Values below can be combined, i. e. 136 would indicate both accessory slots (typical value for accessories).
(2^0)      1 = Lower headgear
(2^1)      2 = Right hand
(2^2)      4 = Mantle
(2^3)      8 = Accessory 1
(2^4)     16 = Armor
(2^5)     32 = Left hand
(2^6)     64 = Shoes
(2^7)    128 = Accessory 2
(2^8)    256 = Upper headgear
(2^9)    512 = Middle headgear
(2^10)  1024 = Styles Upper headgear
(2^11)  2048 = Styles Middle headgear
(2^12)  4096 = Styles Lower headgear
(2^15) 32768 = Arrow (arrow-type items only)
  • wLV: Weapon level of an item (1-4), other items 0.
  • eLV: The minimum base level required for using/equipping the item.
  • Refineable: Whether the item is available for refining (1) or not (0).
  • View: Specifies the client-side look for the item.
    • Weapon-type items:
      1. Daggers
      2. One-Handed Swords
      3. Two-Handed Swords
      4. One-Handed Spears
      5. Two-Handed Spears
      6. One-Handed Axes
      7. Two-Handed Axes
      8. Maces
      9. (not used)
      10. Wand/Staff
      11. Bows/Crossbows
      12. Knuckle Weapons
      13. Musical Instruments
      14. Whips
      15. Books
      16. Katars
      17. Revolvers
      18. Rifles
      19. Shotguns
      20. Gatling guns
      21. Grenade launchers
      22. Fuuma shuriken
    • Shield-type items:
      1. Guard, Novice Guard
      2. Buckler
      3. Shield, Holy Guard, Evangelist
      4. Mirror Shield
    • Ammunition-type items:
      1. Arrows
      2. Throw-able daggers
      3. Bullets
      4. Shells
      5. Grenades
      6. Shuriken
      7. Kunai
    • Headgear-type items: Please see the View IDs section of this guide.
  • {Script}: This is where you put your item bonus. Whether it's an usable item or an equip item, it will take effect according to the item type.
  • {OnEquip_Script}: This is where the bonus you want to be applied upon equipping goes. It will only execute as soon as you equip the item.
  • {OnUnequip_Script}: This is where the bonus you want to be applied upon unequipping goes. It will only execute as soon as you unequip the item.

In the doc folder look for a text file called "item_bonus", it shows all the scripts items can have and how they work.

Item Placement on Data Folder

After you make your item, put it in your item_db2.txt, so that you will not run into conflicts when updating the SVN later. Then go to your data folder and modify the following files, one after another.

idnum2itemdisplaynametable.txt

This file holds the item names, as displayed inside the client. Each item added as:

ItemID#ItemName#

ItemID is the number from your ID column inside the item db. If your item name contains spaces, replace those with _ (underscore).

idnum2itemdesctable.txt

This file contains the description of your item, when it is right-clicked. The syntax for an item is:

ItemID#
Item Description Line 1
Item Description Line 2
#

You can use any amount of lines for the description. If your description contains a #, make sure it is followed by a space character.

idnum2itemresnametable.txt

This file sets the inventory and drop-sprite for an the item. Item is defined as follows:

ItemID#SpriteName#

The SpriteName is the name of the files in collection and item folders inside texture and the ones inside sprite folder. If you want to use the look of an another item, search for it's id and copy the sprite name from there.

itemslotcounttable.txt

In this file you set the amount of visible slots for the item. You do not need to add 0 slot items or items, which do not have slots at all (i. e. usable items). Syntax:

ItemID#NumberOfSlots#

NumberOfSlots should be a number from 1-4, larger values might have undesired effects.

Files for non-identified items

The following files specify the name, description and look for items, which have not yet been identified. Their syntax follows the same rules as for the files with idnum prefix. Normally the same text is entered for non-equipment and generic description (which can be copied from official items) is used for equipment of all sorts (weapons, armor, headgears).

  • num2itemdesctable.txt
  • num2itemdisplaynametable.txt
  • num2itemresnametable.txt

Client Side

The custom item you have downloaded should have six files. Two .bmp files, two .spr files, and two .act files. The person who has released the sprite has hopefully properly labeled what is what, if they have not please see the next section, for now, in our example, we have:

Headgear.act
Headgear.spr
Headgear_collection.bmp
Headgear_drop.act
Headgear_drop.spr
Headgear_item.bmp

Pretend "headgear" is your sprite's name, you will copy headgear.act and headgear.spr to C:\Program Files\Gravity\RO\data\sprite\¾Ç¼¼»ç¸®\¿©, if you have 64-bit Windows, Program Files will be Program Files (x86). Once you have copied these files rename them, and add a ¿© to the beginning of the name. You will not be able to type this, instead copy and paste the symbol from either your address bar, or from this page. If you want to be more tidy you can also add a underscore. Now headgear.act and headgear.spr are ¿©headgear.act and ¿©headgear.spr (or if you were tidy, ¿©_headgear.spr and ¿©_headgear.act). Now, go back to the folder where the files are, copy them again but this time to C:\Program Files\Gravity\RO\data\sprite\¾Ç¼¼»ç¸®\³², and you will be putting a ³² at the beginning of the name instead of ¿©.

After you are done, copy the headgear_collection.bmp to C:\Program Files\Gravity\RO\data\texture\À¯ÀúÀÎÅÍÆäÀ̽º\collection and rename it to just headgear.bmp, so it no longer has _collection. The reason you can not rename this before its copied is because there may be another file with that name already, so you cannot rename it. Now copy headgear_item.bmp to C:\Program Files\Gravity\RO\data\texture\À¯ÀúÀÎÅÍÆäÀ̽º\item and also rename that so it no longer has _item in its name, and is just headgear.bmp. Now copy headgear_drop.act and .spr to C:\Program Files\Gravity\RO\data\sprite\¾ÆÀÌÅÛ and remove _drop, so that its just headgear.act and .spr.

If you can not decipher what is the drop sprite and what is the equip sprite, download Spr Conview which is a simple sprite viewer. Now double click the sprite file, and find the program SPR Conview which will be wherever you downlaoded it to, and open the file with it. If its the drop sprite, it will only have one frame. Where is the frame? Its located at the bottom of the window in the program, look for "Sprite: 1/1". If it has more than one frame, its the equip sprite.

If this process confused you, here is an example folder, the sprite is done by drkangel. The folder is virus free.

View IDs, Having A Custom Item Without Xray

Look in your data folder and make sure there is a folder named "lua files", if there is not make it.Download the most recent lub package and extract it to your lua files folder in your data folder. Download the most recent accname.lua and accessoryid.lua, put it in your datainfo folder that is inside the lua files folder. Now download this lub compiling tool, and put it in the datainfo folder. Now, Open accessoryid.lua in the datainfo folder with notepad or a text editor of your choice, go all the way down until the names stop. Add your custom gears before the } symbol. You should use a high number just like with your custom item's database ID, or use unused IDs to be sure you won't have to redo them all in the future, or at least for a while. Example:

	ACCESSORY_PINKBUNNY_HAIRBAND = 663,
	ACCESSORY_GREENBUNNY_HAIRBAND = 664,
	ACCESSORY_OLD_ELFEAR = 665,
	ACCESSORY_THA_MAERO_MASK = 666,
	ACCESSORY_THANATOS_MAI_MASK = 667,
	--668 free
	ACCESSORY_FISHPIN = 669,
	ACCESSORY_CUSTOM_HAT = 900,
}

You must compile to lub if you leave space between IDs, if you don't plan on compiling to lub, make sure you do not skip any numbers.

Now open accname.lua, do basically the same thing but just in a different way, and for the sprite. Add your item to the bottom, have it look like the ones above it, except have your items name and the item's sprite name.

	[ACCESSORY_IDs.ACCESSORY_PINKBUNNY_HAIRBAND] = "_ÇÎÅ©Åä³¢¸Ó¸®¶ì",
	[ACCESSORY_IDs.ACCESSORY_GREENBUNNY_HAIRBAND] = "_±×¸°Åä³¢¸Ó¸®¶ì",
	[ACCESSORY_IDs.ACCESSORY_OLD_ELFEAR] = "_°í´ë¿äÁ¤ÀDZÍ",
	[ACCESSORY_IDs.ACCESSORY_THA_MAERO_MASK] = "_Ÿ³ªÅ佺Àǽ½ÇÄ°¡¸é",
	[ACCESSORY_IDs.ACCESSORY_THANATOS_MAI_MASK] = "_Ÿ³ªÅ佺ÀÇÁõ¿À°¡¸é",
	[ACCESSORY_IDs.ACCESSORY_FISHPIN] = "_¹°°í±âÇÉ",
	[ACCESSORY_IDs.ACCESSORY_CUSTOM_HAT] = "_Sprite_Name_Here",
}

Delete the accname.lub and accessoryid.lub. Now that you are done, make sure luac.exe is in your datainfo folder, right click the luac.exe, create a shortcut, right click the shortcut, and click properties, in the target area, add right after the quotes, with the quotes:

-o "accessoryid.lub" "accessoryid.lua"

So that it looks something like this:

"C:\Program Files (x86)\Gravity\RO\data\lua files\datainfo\luac5.0.2.exe" -o "accessoryid.lub" "accessoryid.lua"

Do this also to "accname.lub" except instead of accessoryid in the quotes, do accname. If there is any lua file leftover, you may want to move it somewhere else just for future changes, like My Documents. For future reference, this is also how you turn the other lub files to lua files.

Modifications

Sprite Replacement

To replace a headgear with your customized headgear, just delete one of the items you want, and replace your customised item ID with that id.

Lets say you have something like this:

15000,Angel_Wing,Angel Wing,4,,10,10,0,,1,0,0,3,0,0,0,0,0,{},{},{}

And there's an item you wont need, such as:

2220,Hat,Hat,5,1000,,200,,2,,0,10477567,2,256,,0,1,16,{},{},{}

Well, to replace it, just delete everything in the hat line but its ID, and paste there your custom item, all the line but the ID. Should be like this:

2220,Hat,Hat,5,1000,,200,,2,,0,10477567,2,256,,0,1,16,{},{},{}
15000,Angel_Wing,Angel Wing,4,,10,10,0,,1,0,0,3,0,0,0,0,0,{},{},{}
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2220,Angel_Wing,Angel Wing,4,,10,10,0,,1,0,0,3,0,0,0,0,0,{},{},{}

All you need to do now is changing the View ID to the Hat, and change your file names to its name. You can find them on the idnum2resnametable.txt Search for 2220 and the gibberish besides it, w/o the # # is the file name, then rename it to your custom item name.

Remember to add the files to data\sprite\¾ÆÀÌÅÛ (Icon sprite) and both data\sprite\¾Ç¼¼»ç¸®\³² (Male Item Sprite) and data\sprite\¾Ç¼¼»ç¸®\¿© (Female Item Sprite). Remember, these 2 last item names, must have either a ³²_ for male or ¿©_ for female, at the beginning of the name, both .spr and .act. Also, don't forget to change the other files:

idnum2itemdisplaynametable.txt , idnum2itemdesctable.txt , idnum2itemdesctable.txt , num2itemdesctable.txt , num2itemdisplaynametable.txt , num2itemresnametable.txt and itemslotcounttable.txt

Use these files if you want to replace sprites, they will be useful.

  • actOR: with the actor you modify the act file, which is the one who tells the client where does the weapon go and what does it have to do and at a certain moment.
  • SPR Conview: you can use these to view which sprite is which, and also see sequence per sequence.

Item Restrictions

Look on your db folder for a file called item_trade.txt and open it

Now, the pattern for a flag is:

Item ID, TradeMask, GM-Level Override
  • Item ID: the ID of your item.
  • TradeMask: Testrictions the item will have, such as being dropped, stored or traded. These values can be combined to achieve multiple effects.
1:Item can't be dropped
2:Item can't be traded (nor vended)
4:Item can only be traded with wedded partner
8:Item can't be sold to NPCs
16:Item can't be placed in the cart
32:Item can't be placed in the storage
64:Item can't be placed in the guild storage
  • GM-Level Override: This is the minimum GM level a player must have to avoid these restrictions.

Item Script

This section duplicates, in whole or part, the scope of itemskill, sc_start and skilleffect. Please discuss this issue on the talk page and conform with style guide by replacing the section with a link and a summary of the repeated material, or by spinning off the repeated text into an article in its own right.
This section's factual accuracy is disputed. Please see the relevant discussion on the talk page and comment on the further proceeding with this section. (September 2010)

Okay, I'll update this as I go; otherwise, I wont have anything new to show. First with usable items.

Well, there are 3 types of usables:

1.- Healing items, they have in the type field a 0.

2.- Other uses items, such as fly wings and so, which doesn't heal, but does have an instant effect, they have in the type field a 2.

3.- Usable items, which are skills that requires a target selection, therefore they have a delayed use, and in newer SVNs the item wont be gone until the target is chosen and the cast has finished. Means, you wont lose the item if the skill hasn't been done. They have in the type field an 11.

Now, for an item skill, the pattern for a skill is:

itemskill <skill id>,<skill level>;

Without <> of course.

Now, we go to our db\skill_db.txt and search for the blessing ID, searching for AL_ or blessing, but first, the structure of a skill:

id,range,hit,inf,element,nk,splash,max,list_num,castcancel,cast_defence_rate,inf2,maxcount,skill_type,blow_count,name,description

Now, the AL_BLESSING or Blessing Skill:

34,9,6,16,0,0x1,0,10,1,yes,0,0,0,magic,0,	AL_BLESSING,Blessing

We grab the ID and put it on our code:

itemskill 34,<skill lvl>;

Don't mind the actual level of the skill_db.txt for the skill level part. You can actually put the level you want here below 99, so lets pick 4:

itemskill 34,4;

And finally, insert it on the code.

,{ itemskill 34,4; },{},{}

There, we have a Lvl 4 Blessing item skill.

Remember, one space before and one after the script, NOT TAB!

And so on with other skills. Just remember these steps and they should be fine. And remember, itemskill is NOT the same as skill. itemskill will make you CAST that skill, while skill will GIVE you the skill. If you give an item, whether delayed use or normal usable two itemskill commands, only the latter will come into effect, as you cannot cast two skills at the same time.

Now, for Potions.

Instead of using itemskill, we will use itemheal:

,{ itemheal 100,0; },{},{}

The green is the HP, the blue is the SP. To add that random heal amount effect, just pick a set amount, let's say 120, then pick 1 or 2 numbers, up to you. Then, add the rand() command, like this:

,{ itemheal rand(120,9,49),0; },{},{}

Explanation: This item will heal about 49~120 hp and 0 SP. To heal SP you change the 0 to a number. Like this:

,{ itemheal rand(120,9,49),50; },{},{}

It will now heal 50 SP. Now, for skilleffect and sc_start.

Okay, let's see. Here's a example of an item casting a skill and simulating a skill.

,{ itemskill 34,10; skilleffect 29,0; sc_start 12,140000,5; },{},{}

skilleffect will display on your client a skill visual effect. The pattern is:

skilleffect <skill ID>,<number>;
skill ID
Self-explanatory.
number
Have you seen those skills that shows up numbers upon casting? Such as heal? Well, putting a number there will display it. But only works on skills with numbers floating.

sc_start has the following pattern:

sc_start <status id>,<duration>,<val1>[,<unit id>];
status id
Refer to const.txt in your db folder for all effects. Open it with a text editor then search by either clicking edit, then find, or press and hold the ctrl key, and while still holding it press the f key, then release, and search for "SC_ALL -1". Everything below this is an effect. The effects stop at "e_gasp 0" which are emoticons.
duration
Is the amount time in milliseconds (1000 msec = 1 sec) that the status will be active.
val1
Typically it's the level of the skill, associated with this status.
unit id
Allows to start the status on an other unit, than the attached player. For players this is account id. This parameter is optional, and can be omitted.

Now, for the item I said, it will show you the visual effect of Blessing and cast on you a lvl 5 Agi-Up! skill for 140 seconds.

For more item scripts see script_commands.txt in your doc folder, as well as item_bonus.txt in your doc folder.

Weapon Sprite Solution (temporary)

This will help some while I find what I can do so you can use the ID of your choice.

It looks like the weapons behaves like mobs. They have the item sprite ID hardcoded in the exe. But look at this:

1265,Bloody_Roar,Bloody Roar,4,,10,1000,120,,1,0,4096,7,2,34,4,75,1,16,{ bonus bIgnoreDefRace,RC_DemiHuman; bonus bFlee,-160; bonus bFlee2,-160; bonus bNoRegen,1; bonus bNoRegen,2; },{},{}
1266,Test,Test,4,4000,2000,10,165,,1,0,4096,7,2,34,3,33,1,16,{}
// 1-Handed Axes
1301,Axe,Axe,4,500,,800,38,,1,3,8803555,7,2,2,1,3,1,6,{}

The item 1266, a katar, does show the item sprite. So my theory is, if you make a custom item with the next ID of the type of weapon you want, it will take its sprite. The weapons would be:

  • -, Daggers: does not have free IDs. I have to test this one
  • -, Katars: Starts on ID 1250. Has 35 free IDs
  • -, 1-Handed Sword: Starts on ID 1101. Only has 2 Free IDs (in svn 4025)
  • -, 2-Handed Sword: Starts on ID 1151. Has 30 free IDs
  • -, 1-Handed Axe: Starts on ID 1301. Has 43 free IDs
  • -, 2-Handed Axe: Starts on ID 1351. Has 32 free IDs
  • -, 1-Handed Spears: Starts on ID 1401. Has 34 free IDs
  • -, 2-Handed Spears: Starts on ID 1451. Has no free IDs
  • -, 2-Handed Staffs: same as before
  • -, Maces: Starts on ID 1501. Has 19 free IDs
  • -, Books: Starts on 1550. Has only 2 IDs.
  • -, Staffs: Starts on ID 1601. Has 79 free IDs
  • -, Bows: Starts on ID 1724. Has 26 free IDs
  • -, Knuckles: Starts on ID 1801. Has 95 free IDs
  • -, Instruments: Starts on ID 1901. Has 32 free IDs
  • -, Whips: Starts on ID 1950. Has 130 free IDs