Search the Community
Showing results for tags 'event'.
Found 1 result
-
One of the things I would like to do for a mod I'm working on is have non-droid units use special weapons like the flamethrower and carbonite emitter. The first problem with this, as far as I can see, is that when it comes to targeting enemies human characters use force powers in the spot where droids use item spells. So I've created a flamethrower item that can be equipped by both humans and droids but only one of them can use it to target enemies. There are some ways around this. I looked at a mod that implemented a flamethrower for human characters. Instead of targeting an enemy, the flamethrower would targeting the user like an energy shield. Then the script that resolves the spell finds an enemy near the user to fire the flamethrower. This is pretty clever, but I don't like it as a solution because you can't choose who to target. So I had another idea. I would simply create a force power called "Use Item". The power would activate a script that would find the item equipped on the armband and then activate it. This is where I'm having some trouble. I've created the following script and hooked up everything so it runs, but it doesn't activate the item. //:: k_sup_useitem // Custom script by Box // This is a script for using a custom weapon from a spell // This could be considerably more tricky #include "k_inc_debug" void main() { object oItem; // The item to use int nInventorySlot; // The inventory slot where we're keeping the item event evItem; // Event for activating item? object oTarget; // Item target location lTarget; // Item target location // Get the item we're trying to activate // This seems pretty simple so I imagine it works nInventorySlot = INVENTORY_SLOT_LEFTARM; oItem = GetItemInSlot(nInventorySlot, OBJECT_SELF); // Activate the item obtained // Not sure exactly what is going on here with "events" oTarget = GetSpellTargetObject(); lTarget = GetSpellTargetLocation(); evItem = EventActivateItem(oItem, lTarget, oTarget); // I'm guessing this is what we need to run next // If the last block returned an event for activating an item, this should perform the event and activate the item, right? SignalEvent(OBJECT_SELF, evItem); } I've never written a script like this using "events" before. I just found functions in the documentation that seemed like they would do what I wanted. Unfortunately while I can verify that the script is called, it doesn't actually activate the item. I don't know if there are only certain items that can be activated. Most consumable items seem similar in their .uti files with a property that determines what spell is cast when the item is used. I was assuming that an event activating an item would work similarly, but I can't even get this to activate a regular energy shield. On the other hand, I've considered a completely different approach. Instead of trying to activate the item from a script, I would instead just determine the identity of the item equipped and then perform the effect of the item right in this script. There's a problem with that though. I've been using weapons and energy shields with a cooldown effect, so instead of having 5-10 uses before disappearing, they have unlimited uses but can only but have to wait 60 seconds before being used again. If I bypass actually activating the item with this script, then I need to figure out a way to implement a cooldown system. I have no experience doing anything like that. I assume it would probably involve global variables and heartbeat scripts but I don't know where to start. So that's my situation. I think it's a pretty interesting problem and it would be really cool if we could figure it out. What do you guys think? Does anyone know how in-script item activation or cooldowns work? Or maybe you guys have a different way of looking at this problem.