With EVENT_TYPE_CHARGEN_END, I used:
case EVENT_TYPE_CHARGEN_END:
{
int nMode = GetEventInteger(ev, 0); // Mode will be either CHARGEN_MODE_CREATE or CHARGEN_MODE_LEVELUP
object oChar = GetEventObject(ev, 0); // The character undergoing levelup
UT_AddItemToInventory(R"item_name.uti", 1);
}
The full script is more complicated since I need a check to see if the character has the ability in question and to see if the item already exists (i.e., has been given in a previous instance of the event interception), but I'll fill that in later when I know I have the basic event interception working correctly. It seems to me that this simple script should add "item_name.uti" to inventory every time EVENT_TYPE_CHARGEN_END fires. This didn't work, so I then assumed that my original assumption about when EVENT_TYPE_CHARGEN_END fires was faulty. A lot of assumptions, I know (and, yeah, I know what they say about assume).
So I moved on to EVENT_TYPE_ABILITY_ACQUIRED (which I now think would be a more elegant solution, if I could get it to work), using:
case EVENT_TYPE_ABILITY_ACQUIRED:
{
int nAcquired = GetEventInteger(ev, 0); // 1: ability acquired -1: ability lost
int nAbilityID = GetEventInteger(ev, 1);
object oChar = GetEventObject(ev, 0);
UT_AddItemToInventory(R"item_name.uti", 1);
}
Again, the final script will be more complex and include a check to see if the specific ability (the specialization's ABILITY_SPELL_HIDDEN_XXXXXX) was the one acquired, etc. But I wanted something simple to test with, and thought that this script would add "item_name.uti" to inventory every time an ability was acquired. But it doesn't.
In both cases, I added the appropriate line to my engineevents_mymod.xls/gda and pointed the Script String to my event handler script. Also in both, the variable ev is defined before the switch command, I just didn't paste the entire thing to keep the post clutter-free. The scripts compile fine, though.
I know there's EVENT_TYPE_PLAYERLEVELUP that fires every time the player requests to enter the level up screen, but don't know know of any event that fires when the player closes that screen, as I'd hoped CHARGEN_END did.
So two questions:
1. Is there a simpler way to solve the issue of giving the player an item when they select a specific specialization?
2. Assuming "no" is the answer to 1, am I clearly doing something wrong in these examples or do these events not fire when I'm thinking they should? Is there some event that would be better suited to my purposes?
Modifié par Sakaslan, 17 septembre 2010 - 10:05 .





Retour en haut






