Jump to content

How to attach script to player?


hidconsp

Recommended Posts

I have been trying to make a script that works when

1.Player is equipping certain item

2.Player uses a spell

 

So what I came up with is.

 

Scriptname castSpell extends ObjectReference

Event OnSpellCast(Form akSpell)
debug.MessageBox("Player used a spell")
endEvent

 

 

But I have a hard time where to attach this script.

 

From what I have read in tutorials, it looks like I have to make a blank quest,

 

add player as quest alias,

 

then attach the script on the "Reference Alias" tab.

 

 

 

This works, but not when I attach this script to the item...

 

And I think it would be best to keep things neat, without using quest.

 

Plus I want npcs to use the item, but I cannot add all npcs to quest aliases...

 

Can anyone help me please?

Edited by hidconsp
Link to comment
Share on other sites

You are trying to technically catch two events. When something is equipped and when something is cast. To do that you'd want to do this...

 

Scriptname castSpell extends ObjectReference

Event OnSpellCast(Form akSpell)
       debug.MessageBox("Player used a spell")
endEvent

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
 if akBaseObject as Weapon
   Debug.MessageBox("This actor just equipped a weapon!")
 endIf
endEvent

 

yes a blank quest to run this is how you'd do it.

 

 

...

 

actually im confused. Is this script mean to be on the item or player?

Link to comment
Share on other sites

Thanks a lot Korodic,

 

I really need a person to confirm that I was doing the right way.

 

 

But what I want to do is not checking whether the player equipped a weapon...

 

It is like this:

 

A magical amulet that gives you 10 magicka when casting a spell

 

 

Well, but if there is no way to attach only 1 script to the item,

 

I am satisfied, and ready to do tedious works...

Link to comment
Share on other sites

You are trying to technically catch two events. When something is equipped and when something is cast. To do that you'd want to do this...

 

Scriptname castSpell extends ObjectReference

Event OnSpellCast(Form akSpell)
       debug.MessageBox("Player used a spell")
endEvent

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
 if akBaseObject as Weapon
   Debug.MessageBox("This actor just equipped a weapon!")
 endIf
endEvent

 

yes a blank quest to run this is how you'd do it.

 

 

...

 

actually im confused. Is this script mean to be on the item or player?

 

That's what I am confused, too.

 

I have made a script to be attached to the player,

 

but how can I modify it to be attached to the item?

Link to comment
Share on other sites

Well, now I don't think I want to attach the script to the item anymore...

 

but I've got another problem.

 

This,

 

Scriptname castSpell extends ReferenceAlias  

actor property player auto

armor property amulet auto

Event OnSpellCast(Form akSpell)
If (player.getAV("Magicka") < 50) && (player.getequipped amulet == 1)
	player.restoreAV("Magicka", 30)
endIf
endEvent

 

failes to be compiled.

 

There seems to be a problem with "player.getequipped amulet == 1"

 

This is frustrating....

Link to comment
Share on other sites

  • Recently Browsing   0 members

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