Detect when player pick up ammo

Post » Sun Nov 18, 2012 11:30 pm

Hello

I would like detec when the player pick up a specific ammo. But we can't attach script to ammo for use OnContainerChanged()
It's a way for detect when player take it?
User avatar
Claire
 
Posts: 3329
Joined: Tue Oct 24, 2006 4:01 pm

Post » Mon Nov 19, 2012 7:03 am

Create a quest with an alias that points at the player. Add a script to the alias and you will get all the players events. OnItemAdded is probably the event you want. Check if the item is ammo:

if (akItemRef As Ammo)
; Do something...
endif
User avatar
Meghan Terry
 
Posts: 3414
Joined: Sun Aug 12, 2007 11:53 am

Post » Sun Nov 18, 2012 5:35 pm

Make an alias and fill it with PlayerRef. Then add the following code in the script section

Scriptname myAmmoAddedScript extends ReferenceAliasAmmo Property myAmmo  autoEvent OnItemAdded()   If akBaseItem == myAmmo.GetBaseObject()      ; do stuff   EndIfEndEventEvent OnItemRemoved()   If akBaseItem == myAmmo.GetBaseObject()      ; do stuff   EndIfEndEvent

EDIT: Ninja'd

- Hypno
User avatar
Lance Vannortwick
 
Posts: 3479
Joined: Thu Sep 27, 2007 5:30 pm

Post » Mon Nov 19, 2012 1:49 am

I never use Alias, how we creat it and link it with Quest?
User avatar
Gavin boyce
 
Posts: 3436
Joined: Sat Jul 28, 2007 11:19 pm

Post » Mon Nov 19, 2012 3:45 am

Look here

http://www.creationkit.com/Quest_Alias_Tab

http://www.creationkit.com/Category:Radiant_Story
User avatar
WTW
 
Posts: 3313
Joined: Wed May 30, 2007 7:48 pm

Post » Sun Nov 18, 2012 6:25 pm

Open up your quest, click on the "quest alias" tab at the top. Right-click in the list area and select "new reference alias". Give it a name then under fill type tick "unique actor" then fill it with the player reference (cell = (any), actor = player). Then add your papyrus script in the script section and your done. If the window is too big so you cannot see the "ok" button, just click on the name text box, hold shift and hit tab twice, then press enter

- Hypno
User avatar
stevie trent
 
Posts: 3460
Joined: Thu Oct 11, 2007 3:33 pm

Post » Sun Nov 18, 2012 10:30 pm

It is possible to applied an alias on all actor?

If i want detect when an actor is hit by this ammo, and using OnHit Event, it's possible?
User avatar
Tiffany Holmes
 
Posts: 3351
Joined: Sun Sep 10, 2006 2:28 am

Post » Sun Nov 18, 2012 2:34 pm

You might find the approach discussed in http://www.gamesas.com/topic/1349649-dynamically-attaching-scripts-to-actors-near-the-player/ useful for that.

Cipscis
User avatar
Chris Duncan
 
Posts: 3471
Joined: Sun Jun 24, 2007 2:31 am


Return to V - Skyrim