Jump to content

Scripting help, possibly.


exneph

Recommended Posts

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 by exneph
Link to comment
Share on other sites

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

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...