// All module events #include "utility_h" #include "wrappers_h" #include "events_h" void main() { event ev = GetCurrentEvent(); int nEvent = GetEventType(ev); Log_Events("", ev); switch (nEvent) { //////////////////////////////////////////////////////////////////////// // Sent by: The engine // When: The module loads from a save game, or for the first time. This event can fire more than // once for a single module or game instance. //////////////////////////////////////////////////////////////////////// case EVENT_TYPE_MODULE_LOAD: { // this event can fire multiple times, and we only want to do this once // So we save a flag inside a number variable. We check it here and if its // set already then we know we've already done this before. The name of the // variable in quotes can be whatever you want. int iModuleLoaded = GetLocalInt(OBJECT_SELF, "aga_bowathena"); if (iModuleLoaded == 1) break; // get the object which contains the player object oPlayer = GetHero(); // The flag we save won't persist beyond the game session, so its a good idea to actually // look to see if the player already has the item, unless you WANT them to get another one // The name in quotes is the TAG of the item. So what we do is see how many of the item // the player already has, and if its 0, we know we haven't given it to them yet (or they sold it :p) int iItemCount = CountItemsByTag(oPlayer, "aga_bowofathena"); // if its 0, then let's give them the item. Now this first parameter is a RESOURCE identifier. Note // how its formatted. R"resource_file_name" // The "R" part is important and identifies it as a resource. The filename is just the filename of the // resource. You can see this in the toolset on the tabs up top. // The number 1 means give 1 item. if (iItemCount == 0) UT_AddItemToInventory(R"aga_bowofathena.uti",1); // lastly we set that number variable we talked about earlier, to save the fact that we've // done this already. SetLocalInt(OBJECT_SELF, "aga_bowathena", 1); break; } default: { break; } } }