Page 1 of 1
Crystallization NPC
Posted: Sun Jun 24, 2007 2:03 pm
by Kalico
Is it possible to make an npc that can crystallize armor/weapons/jewelry for players?
Posted: Mon Jun 25, 2007 4:18 am
by Fulminus
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.
Posted: Mon Jun 25, 2007 5:37 am
by Kalico
Awesome! Thanks a lot.
I'll look into #3, I can live with a speed sacrifice for accurate crystal counts and less typing.
I know a bit python, but I'll have to research jython, and look into the Fate's Whisper files.
Thanks again.
Posted: Mon Jun 25, 2007 6:24 pm
by Kalico
I finished the skeleton of the script, even added a simple event, and it worked.
A couple times anyway, now my npc doesn't respond to events at all.
Posted: Mon Jun 25, 2007 7:22 pm
by Fulminus
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.
Posted: Mon Jun 25, 2007 7:29 pm
by Kalico
I got it working again. It was a typo
Now I need to work on enumerating crystallizable items in the player's inventory
Posted: Mon Jun 25, 2007 10:45 pm
by Kalico
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...