Extending to objectreference and actor

Post » Wed Jun 20, 2012 9:37 pm

How do I extend to objectreference and actor scripts?

I'm trying to get an actor take all of his defeated opponent's items but since I extended to Actor, I can't find a way to use RemoveAllItems() in that script.
User avatar
JESSE
 
Posts: 3404
Joined: Mon Jul 16, 2007 4:55 am

Post » Wed Jun 20, 2012 11:10 pm

Cast 'As ObjectReference', perhaps?
User avatar
Angus Poole
 
Posts: 3594
Joined: Fri Aug 03, 2007 9:04 pm

Post » Thu Jun 21, 2012 1:49 am

As ObjectReference?
Well heres the script and the output if that will help...
Spoiler
Scriptname LootItems extends Actor
{Loot stuff}


Event OnCombatStateChanged(Actor akTarget, int aeCombatState)

if (aeCombatState == 1)
if (akTarget.GetKiller() == self)
Debug.MessageBox("loot time!")
akTarget.RemoveAllItems(ObjectReference akTransferTo = self, bool abKeepOwnership = false)

endif
endif

endEvent

Spoiler
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\LootItems.psc(10,26): no viable alternative at input 'ObjectReference'
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\LootItems.psc(10,61): required (...)+ loop did not match anything at input ','
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\LootItems.psc(10,91): required (...)+ loop did not match anything at input ')'

User avatar
Catherine N
 
Posts: 3407
Joined: Sat Jan 27, 2007 9:58 pm

Post » Wed Jun 20, 2012 4:25 pm

Odd it won't indent
User avatar
x a million...
 
Posts: 3464
Joined: Tue Jun 13, 2006 2:59 pm

Post » Wed Jun 20, 2012 4:17 pm

Indentation: You have to flick the WYSIWYG switch in the post editor.

Script: Ah... NM about the 'As ObjectReference' part. You just need to specify the arguments.
ScriptName LootItems extends Actor{Loot stuff}Event OnCombatStateChanged(Actor akTarget, int aeCombatState)	If aeCombatState == 1		If akTarget.GetKiller() == Self			Debug.MessageBox("loot time!")			akTarget.RemoveAllItems(Self)		EndIf	EndIfEndEvent
User avatar
CRuzIta LUVz grlz
 
Posts: 3388
Joined: Fri Aug 24, 2007 11:44 am

Post » Wed Jun 20, 2012 5:51 pm

Im confused, why Game.Player()? or is that an example.
I'm trying to get the killer to loot anyone it kills such as other actors.


Nvm I get it now. Thanks. :D
User avatar
Sherry Speakman
 
Posts: 3487
Joined: Fri Oct 20, 2006 1:00 pm

Post » Wed Jun 20, 2012 10:48 am

*fix'd, then, by substituting w/ 'Self'.
User avatar
Bitter End
 
Posts: 3418
Joined: Fri Sep 08, 2006 11:40 am

Post » Wed Jun 20, 2012 7:26 pm

FYI for future reference. You're copying and pasting the decleration samples for the function signatures.

akTarget.RemoveAllItems(ObjectReference akTransferTo = self, bool abKeepOwnership = false)

Don't provide your object types in the functions you call
akTarget.RemoveAllItems(akTransferTo = self, abKeepOwnership = false)

And finally, you don't necessarily have to specify the parameter names assuming you are providing ALL of the parameters and/or don't need to override a default:

akTarget.RemoveAllItems(self, false)

Assuming you have a reference to your target via akTarget, and that self is the actor that the script is running on and you want to move all the items to.

-MM
User avatar
alicia hillier
 
Posts: 3387
Joined: Tue Feb 06, 2007 2:57 am

Post » Thu Jun 21, 2012 1:35 am

Ill keep that in mind MM, thanks!
User avatar
Blaine
 
Posts: 3456
Joined: Wed May 16, 2007 4:24 pm


Return to V - Skyrim