Aller au contenu

Photo

Idea for random treasure system.


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
JJM152

JJM152
  • Members
  • 301 messages
I just wanted to throw this out there as a potential solution for creating an add-in that adds some random magical equipment to the game and get some feedback from people more experienced with the toolset than I (Just started looking at it tonight) on if it's plausible.

Now, from poking around tonight I've noticed that treasure seems to get generated based on the contents of several 2da files that are broken down into categories (I assume this is to prevent dead elves from dropping darkspawn weapons and vice versa). Well, this got me thinking (and I admit this is based on a lot of assumptions).

What if I went and modified those 2da files (I assume by creating m2da files) to include a small chance  in each Category (rank as well) of dropping a custom object that I create of a base type (Say, an armor or a sword, or a ring).

Now, here is where the massive assumption takes place...

I'm assuming that there is some sort of event that I can catch on the object when it is instantiated into either the creature or container. If this is the case, then I would like to catch that object (one time) and run a custom script that would generate a variety of random properties and then set them on the item via the AddItemProperty() method. Another assumption here is that properties I add dynamically at runtime will be saved with the character data in the save file and the item won't regenerate its properties when the game is loaded!

Anyway, does this sound like a half way decent way to provide some additional treasure options to the single player campaign without interfering with any other potential modules? Also, is there perhaps a smarter way of doing this? And finally, I guess I need to know the following:
  • Is there an event I can catch the first time an object is created?
  • Is there a way for me to get a scaling number in that event, or a reference to the PC's level for my own scaling?
I'm positive I can handle the scripting requirements to generate the properties intelligently (assuming I can even get that far), but like I said, I've only started looking at the toolset tonight so I was wondering if anyone else has tried this approach and if there is anything glaringly wrong with it.

Thank you

#2
JJM152

JJM152
  • Members
  • 301 messages
Although it's kind of lame to responding to my own post,I thought I might save someone some trouble by following this up with what I've learned today:

It appears that items do not receive events on creation like creatures do, so having the item configure itself with magical properties is probably a no go.

It looks like you may actually have to override the following:
  • placeable_core: EVENT_TYPE_SPAWN
  • creature_core: EVENT_TYPE_DYING
In the case of placeable_core the EVENT_TYPE_SPAWN event directly calls the GenerateTreasure method from sys_treasure_h via an internal method, Placeable_HandleSpawned() in placeable_h. In the case of creature_core the event is simply passed on to the sys_treasure script which then handles it generates loot.

The problem is that I don't want to directly modify the treasure_h file, although I suspect that I may have to. I could modify the events with my own handlers for placable_core and creature_core, but if I do that then I have to either do it on every item/object (not going to happen) or I have to do it globally through the events.xsl file... and then I don't know (because of lack of documentation) which scripts I have to pass the handlers on to from that point other than the obvious ones.

Frankly the event handling/chains are pretty poorly documented for such a massive part of the games internal engine and I'm finding it pretty slow going figuring this stuff all out. :(

#3
JJM152

JJM152
  • Members
  • 301 messages
Another followup for the sake of anyone searching for solutions:



My above hypothesis turned out to be true. I am overriding both events via redirection from the enginevents.GDA



Right now I am fooling around with my magic-fication routines, but hopefully I will have something to show the community soon!