exneph Posted March 15, 2012 Share Posted March 15, 2012 (edited) So, trying to delve into scripting with this, and it's seemingly more a pain than it was in Morrowind. At least to me. Anyway.. I'm trying to get an activator to spawn an item from a form, but to be placed at a linkedref xmarker. Essentially, push button, item spawns where xmarker is located in editor. I thought I had it down, but for the life of me.. Also, bonus points if at all possible to get the item to delete itself on hit via projectile. Thought I had that out too, but.. Man. I mean, is it even possible to set a spawn at a linked ref, only activated via object? I don't like to just ask for script handouts, because I'm trying to learn this myself, but some of the tutorials are just.. Meh. Well, wikia tutorials. Or I'm just reading them wrong. Bah, I don't know. Thanks everyone. Edit: Alright. I've attached the script to the Xmarker itself, and just used the OnActivate and PlaceAtMe(Game.GetForm()). Upon setting the marker's active parent to a button, it does indeed spawn the item, and at no other time, once per click. Second question: Is it possible to set it so that on hit, the spawned form will be deleted? Heh. I'm happy, I made something work! Edited March 15, 2012 by exneph Link to comment Share on other sites More sharing options...
fg109 Posted March 15, 2012 Share Posted March 15, 2012 Object references can receive an event called OnHit. So just attach a script to the base item of whatever you're spawning, telling it to delete itself when it receives this event. Link to comment Share on other sites More sharing options...
exneph Posted March 15, 2012 Author Share Posted March 15, 2012 Ahhhh, I get you.. I'm going to give that a go and see how it works. Now, I'd probably need to create new forma for the items spawning, though, right? Link to comment Share on other sites More sharing options...
exneph Posted March 16, 2012 Author Share Posted March 16, 2012 I do hate to bump an old topic of mine, but I'm running into a slight problem. I have the script set up for OnHit, and everything compiled and saved fine. The only place where I can add the Delete() is right before the EndEvent for the script to compile properly. I know I must be doing this wrong, because the object deletes itself the moment it tries to spawn, now. However, once the Delete() function is removed from the script, the item will spawn. Now, I have the spawn script on the xmarker, activate parent to the button. Works beautifully. The base object that spawns has the script for OnHit. When the base object is placed in the world via editor (when it has the delete function written after the OnHit script), once it gets hit it gets deleted. Works perfectly. Is there any place where I should put the function other than where it is? And, if possible, could the delete function be enabled after a certain amount of seconds after OnHit? Thanks again. Link to comment Share on other sites More sharing options...
fg109 Posted March 16, 2012 Share Posted March 16, 2012 Try this: Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked) if (akAggressor == Game.GetPlayer() Debug.Notification("I just got hit by the player!") RegisterForSingleUpdate(5) endif EndEvent Event OnUpdate() Debug.Notification("It's been 5 seconds, deleting myself!") Disable() Delete() EndEvent Link to comment Share on other sites More sharing options...
exneph Posted March 16, 2012 Author Share Posted March 16, 2012 You know, I was reading through the Wikia trying to figure out the Disable(), Delete().. I know it mentioned somewhere OnUpdate, but never figured out how to put that in. Thanks again, fg109! I'll see how that works! Link to comment Share on other sites More sharing options...
Recommended Posts