Jump to content

Spawning an object with a script?


PollyEdaline

Recommended Posts

I'm making a new update for my mod, Drinks of Cyrodiil. I'm basically adding empty potion bottles. Basically what I need to know is if there is a way to spawn objects in front of the player after he drinks a potion. I think I do

 

begin OnDrop player

 

Since this seems to be the only way for the game to recognize a potion has been drunk. But I don't know what to do next!! Ideally, the potion would also be "thrown" in front or in back of the player, although this is optional. If you help me out, you will get HUGE credit in my mod, and I know that isn't much but it's all I can offer.

 

Please help me out here!

Link to comment
Share on other sites

I'm making a new update for my mod, Drinks of Cyrodiil. I'm basically adding empty potion bottles. Basically what I need to know is if there is a way to spawn objects in front of the player after he drinks a potion. I think I do

 

begin OnDrop player

 

Since this seems to be the only way for the game to recognize a potion has been drunk. But I don't know what to do next!! Ideally, the potion would also be "thrown" in front or in back of the player, although this is optional. If you help me out, you will get HUGE credit in my mod, and I know that isn't much but it's all I can offer.

 

Please help me out here!

 

I have an idea, not completely sure if it would work...

 

Have the begin OnDrop player attached to the potion that the player will be drinking. When this script activates have it add an empty bottle into the player's inventory. Have a new script attached to the empty bottle starting with "begin OnAdd". In that script use the following function "player.Drop EmptyBottle 1". It's kind of messy in the sense that it will say "EmptyBottle added" then "EmptyBottle removed" in the upper left. However the overall effect should be what you are looking for. If this sounds acceptable I can write up the script for you. There might be other ways, but this is what came to my mind.

Link to comment
Share on other sites

The problem is that inventory objects can't reference themselves. You could use placeatme to create a bottle after the potion has been drunk, but it would appear at the player's feet. Even if you used an activator to move to the proper height, then act as the calling reference for the bottle creation, it still wouldn't look right. Serpent is halfway there, something like;

begin onactivate

player.additem *empty bottle ID* 1

player.drop *empty bottle ID* 1

activate

end

Might work when scripted on the potion bottle (not spell, the item), but that can get had to manage depending on how many drinks you want this to work with, in addition to the messages for an item popping up all the time. I really don't think there's a clean (not requiring you to script every bottle, or makign messages appear constantly) to get anything like this done. You might be able to get rid of half the problem if you don't mind adding a scripted spell to the potion effects, but as this would be something just as visible, it may not be a good idea. Other than that, I guess you're going to have to decide if this is such an important part of your mod or not.

Link to comment
Share on other sites

Doesn't OnActivate trigger when using a potion? Anyway, you could have an extra magical effect on all of your potions.

Just add this script to one of the enchantments (BUT ONLY ONCE PER ITEM):

scn ImmaPotion

float temp
ref self
ref bottle

Begin ScriptEffectStart
set self to getself;Good practice, now it'll work on NPCs as well :)
set bottle to self.placeatme *Empty Bottle ID* 1

; If we want the bottle to be "dropped" (not at feet), remove the ";"s below:
;set temp to bottle.getpos z + 60
;bottle.setpos z temp

; Want some k00l visuals as well? (Unrealistic, but k00l :))
bottle.PlayMagicShaderVisuals effectAtronachFlame
End

Begin ScriptEffectFinish
bottle.StopMagicShaderVisuals effectAtronachFlame
End

EDIT: The last part (visuals) will set the bottles on fire :)

Link to comment
Share on other sites

Doesn't OnActivate trigger when using a potion?

 

Yes, this is intentional, that way it catches when the potion is used, creates the bottle, drops the bottle, then continues using the potion. The only problem would be having to add something so that if the potion itself can be picked up if dropped without this effect being triggered.

Link to comment
Share on other sites

Doesn't OnActivate trigger when using a potion? Anyway, you could have an extra magical effect on all of your potions.

Just add this script to one of the enchantments (BUT ONLY ONCE PER ITEM):

scn ImmaPotion

float temp
ref self
ref bottle

Begin ScriptEffectStart
set self to getself;Good practice, now it'll work on NPCs as well :)
set bottle to self.placeatme *Empty Bottle ID* 1

; If we want the bottle to be "dropped" (not at feet), remove the ";"s below:
;set temp to bottle.getpos z + 60
;bottle.setpos z temp

; Want some k00l visuals as well? (Unrealistic, but k00l :))
bottle.PlayMagicShaderVisuals effectAtronachFlame
End

Begin ScriptEffectFinish
bottle.StopMagicShaderVisuals effectAtronachFlame
End

EDIT: The last part (visuals) will set the bottles on fire :)

 

Great, but I don't really want the flame. Can I leave out the ScriptEffectFinish? Or is that still necessary? I will go see if this works now

 

EDIT: Do you mean like create a new effect like where, say, Restore Health is? I scroll to Script Effect and then try and select my script but it just isn't there. What am I doing wrong?

Link to comment
Share on other sites

Doesn't OnActivate trigger when using a potion? Anyway, you could have an extra magical effect on all of your potions.

Just add this script to one of the enchantments (BUT ONLY ONCE PER ITEM):

scn ImmaPotion

float temp
ref self
ref bottle

Begin ScriptEffectStart
set self to getself;Good practice, now it'll work on NPCs as well :)
set bottle to self.placeatme *Empty Bottle ID* 1

; If we want the bottle to be "dropped" (not at feet), remove the ";"s below:
;set temp to bottle.getpos z + 60
;bottle.setpos z temp

; Want some k00l visuals as well? (Unrealistic, but k00l :))
bottle.PlayMagicShaderVisuals effectAtronachFlame
End

Begin ScriptEffectFinish
bottle.StopMagicShaderVisuals effectAtronachFlame
End

EDIT: The last part (visuals) will set the bottles on fire :)

 

The problem is likely the fact that you tried to reference an object that can be picked up. Oblivion doesn't like this, even though it still lets the script compile. What you might have to do instead is create an activator at the proper height, then have that activator remove itself once it creates the bottle. IE creating the activator with this script, setting the position, then having another script (on the activator) that creates the bottle after 1 second (to allow it to be moved into the proper position, then removes itself.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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