Crystallization NPC
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
- Kalico
- Posts: 41
- Joined: Tue Mar 27, 2007 3:45 am
Crystallization NPC
Is it possible to make an npc that can crystallize armor/weapons/jewelry for players?
-
- L2j Veteran
- Posts: 1554
- Joined: Mon Oct 10, 2005 6:49 pm
yes, and it is pretty easy actually. The hardest part is the interface.
There are three things you can do:
1) Write a multisell xml and display it with exc_multisell (to only show items that exist in the player's inventory). This will give players the nicest interface, but enchanted items will not gain a bonus in the number of crystals they reward. Also, if new items are added (for example in later chronicles), you will need to edit your multisell and add them. Both of the above are natural side-effects, since multisells are hardcoded.
2) Write a jython script, including huge arrays of all the item ids that the player can submit. Within jython, you can iterate through the items in the player's inventory and whatever items match listings in your array can be displayed, once for each enchantment level. You can generate a link that stores the item's object id, such that the script can find exactly what item it is. There is a call to the core which returns the number of crystals given an item (includes a bonus for enchantment). So your script can reward the crystals.
The interface here will look ugly, since it will essentially be a list of links. Additions of new items to the DB will again mean that you will need to edit your arrays. However, crystal counts are automatic and more accurate.
3) Instead of writing huge arrays, you can iterate through the items in the player's inventory and check if the items get crystallized into more than 0 crystals. The interface will look the same as in #2, but you save yourself from having to type in those huge arrays. On the other hand, this might be a little slower than #2.
For #2 and #3 suggestions, you can find an example on how to generate the HTM and communicate the player's choice back to your script by looking a the final exchange in our implementation of fate's whispers, or (if you have them) the old mammon scripts.
Solution #1 might be the easiest to write, since it requires no scripting, and looks the prettiest...but I already told you its disadvantages.
There are three things you can do:
1) Write a multisell xml and display it with exc_multisell (to only show items that exist in the player's inventory). This will give players the nicest interface, but enchanted items will not gain a bonus in the number of crystals they reward. Also, if new items are added (for example in later chronicles), you will need to edit your multisell and add them. Both of the above are natural side-effects, since multisells are hardcoded.
2) Write a jython script, including huge arrays of all the item ids that the player can submit. Within jython, you can iterate through the items in the player's inventory and whatever items match listings in your array can be displayed, once for each enchantment level. You can generate a link that stores the item's object id, such that the script can find exactly what item it is. There is a call to the core which returns the number of crystals given an item (includes a bonus for enchantment). So your script can reward the crystals.
The interface here will look ugly, since it will essentially be a list of links. Additions of new items to the DB will again mean that you will need to edit your arrays. However, crystal counts are automatic and more accurate.
3) Instead of writing huge arrays, you can iterate through the items in the player's inventory and check if the items get crystallized into more than 0 crystals. The interface will look the same as in #2, but you save yourself from having to type in those huge arrays. On the other hand, this might be a little slower than #2.
For #2 and #3 suggestions, you can find an example on how to generate the HTM and communicate the player's choice back to your script by looking a the final exchange in our implementation of fate's whispers, or (if you have them) the old mammon scripts.
Solution #1 might be the easiest to write, since it requires no scripting, and looks the prettiest...but I already told you its disadvantages.
I'm a joyful, merriful, playful, curious, young, little elf!!! 
I'm also a High(tech) Elf, (computer) wiz!

I'm also a High(tech) Elf, (computer) wiz!
-
- L2j Veteran
- Posts: 1554
- Joined: Mon Oct 10, 2005 6:49 pm
This could mean a couple of things:
1) Some tiny change in your script has an error and causes the script to not compile.
2) Some change in your htms or parent directory jy files make your script unreachable.
3) Some change in core (like renaming or moving a function/variable) caused your script to stop working after updating.
1) Some tiny change in your script has an error and causes the script to not compile.
2) Some change in your htms or parent directory jy files make your script unreachable.
3) Some change in core (like renaming or moving a function/variable) caused your script to stop working after updating.
I'm a joyful, merriful, playful, curious, young, little elf!!! 
I'm also a High(tech) Elf, (computer) wiz!

I'm also a High(tech) Elf, (computer) wiz!
- Kalico
- Posts: 41
- Joined: Tue Mar 27, 2007 3:45 am
Well, I got the script to list all the items in my inventory. (hoorah!)
Now I am wondering how I would go about determining if an item is crystallizable or not
EDIT2: Scratch that question, figured it out.
EDIT: Also, can I call an event directly instead of opening an intermediate dialog in onTalk?
EDIT3: I decided I don't really care about this question.
And my NPC works!
I'm a happy tabby.
EDIT4: Hmmm, seems I messed something up, its not even loading it now.
EDIT5: One indent messed me up, I wonder how I lost it...
Now I am wondering how I would go about determining if an item is crystallizable or not
EDIT2: Scratch that question, figured it out.
EDIT: Also, can I call an event directly instead of opening an intermediate dialog in onTalk?
EDIT3: I decided I don't really care about this question.
And my NPC works!

EDIT4: Hmmm, seems I messed something up, its not even loading it now.
EDIT5: One indent messed me up, I wonder how I lost it...