Jump to content

can a magic effect be applied via inventory item?


bombchu

Recommended Posts

Hello :)

 

I was just wondering if there's a way to apply a magic effect to any and all actors upon receiving a specific item into their inventory. I have the scripts written to give the item through dialogue and apply the affect, but i want to be able to "pickpocket" it into their inventory and have it applied as well. Is there a way to do this?

 

Thank you! :)

Link to comment
Share on other sites

  • Replies 40
  • Created
  • Last Reply

Top Posters In This Topic

I'm very new to the mod making world, and I admittedly would have no idea how to do that. Would you care to help me with the exact coding (I'd obviously credit you in the finished mod), or maybe point me in the direction of a tutorial for doing this?

 

Thanks! :)

Link to comment
Share on other sites

Couldn't you use a OnContainerChanged event to cast the magic effect when the item changes inventories?

That looks promising. Would I just attach that script to the magic effect and reference the item under properties?

 

edit: Nevermind, scripts on magic effects are only for defining the effect, and would nullify the effect as I've set it up. The item then? Or would this be something I'd have to make a new quest for?

 

Thanks again :smile:

 

 

edit 2: It doesn't appear that I can reference the player's inventory as a container, which I assume means I wouldn't be able to reference an actor's inventory either. If i'm wrong, let me know, because this seems like the easiest way to accomplish what I want to accomplish.

Edited by bombchu
Link to comment
Share on other sites

I'll have a better look at it when I get home, but you would have the script attached to the item as it is the one changing containers.

 

Oh and both the actors and players inventory counts as a container.

Link to comment
Share on other sites

Alright, thanks. Yea, I know that player/actor inventories technically count as containers, but i saw no way to add them as script properties under the "container" type. I would imagine that the actor inventory "container" is especially tricky, since it could potentially be referencing almost any npc in the game. But then again, I still have a lot to learn :/

Link to comment
Share on other sites

Since it's an interaction between any NPC and a very specific item you put the script on the item. The actors themselves count as containers.

 

So in the item's script you put an event structured something like this. The cast of akNewContainer as Actor will be false if the item gets dropped into the world or placed into an actual inanimate container. And akOldContainer is the old location, but if the effect cleans itself up you don't need the second if statement.

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
    if akNewContainer as Actor ; an actor and not an inanimate container or dropped into the world
        ; Add the effect to akNewContainer here
    endif
    if akOldContainer as Actor ; item was being held by an actor
        ; if you need to remove the effect from the previous holder, you can do that here
    endif
EndEvent
Link to comment
Share on other sites

BTW I'm not sure if there is a way you can directly apply a magic effect via script, you need to make it into a spell and use SpellName.Cast(akNewContainer) Correct me if i'm wrong :P

Link to comment
Share on other sites

 

Since it's an interaction between any NPC and a very specific item you put the script on the item. The actors themselves count as containers.

 

So in the item's script you put an event structured something like this. The cast of akNewContainer as Actor will be false if the item gets dropped into the world or placed into an actual inanimate container. And akOldContainer is the old location, but if the effect cleans itself up you don't need the second if statement.

Event OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer)
    if akNewContainer as Actor ; an actor and not an inanimate container or dropped into the world
        ; Add the effect to akNewContainer here
    endif
    if akOldContainer as Actor ; item was being held by an actor
        ; if you need to remove the effect from the previous holder, you can do that here
    endif
EndEvent

 

Oh, I see. Stupid mistake thinking the containers had to have object references attached to them. But i can't seem to attach a script to my item :/ The dropdown menu is empty and the [...] button does nothing. It's an apple, if that helps. Is there something I'm missing?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...