Need some help converting old Oblivion scripts to Papyrus

Post » Tue Jun 19, 2012 4:28 am

Just need some help converting my old kill script to Papyrus

Heres the code


Scriptname aaaKillScript;;;=======================================================event OnEffectStart()	if GetDead == 0;	   message "Debug: Kill Script Working"	   Kill	endifendEvent  



The errors I am getting in Papyrus when compiling

Starting 1 compile threads for 1 files...
Compiling "aaaKillScript"...
e:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\aaaKillScript.psc(9,5): variable GetDead is undefined
e:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\aaaKillScript.psc(9,13): cannot compare a none to a int (cast missing or types unrelated)
e:\program files\steam\steamapps\common\skyrim\Data\Scripts\Source\aaaKillScript.psc(11,7): variable Kill is undefined
No output generated for aaaKillScript, compilation failed.

Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on aaaKillScript


Any and all help is appreciated
User avatar
Sarah Knight
 
Posts: 3416
Joined: Mon Jun 19, 2006 5:02 am

Post » Tue Jun 19, 2012 3:35 pm

Because your script needs to be attached to an http://www.creationkit.com/ActiveMagicEffect_Script, it needs to extend that type:
ScriptName aaaKillScript extends ActiveMagicEffect

When calling a non-global function without explicitly stating the object on which it's being called, the compiler will assume the object to which the script is attached will call the function. Neither http://www.creationkit.com/GetDead_-_Actor nor http://www.creationkit.com/Kill_-_Actor exist for a script extending ActiveMagicEffect, though. You need to call them on an object of type http://www.creation kit.com/Actor_Script.

Specifically, you need to use the first Actor parameter that should be in your definition of the native http://www.creationkit.com/OnEffectStart_-_ActiveMagicEffect event:
Event OnEffectStart(Actor akTarget, Actor akCaster)	if (!akTarget.GetDead())		Debug.Notification("Debug: Kill Script Working")		akTarget.Kill()	endifEndEvent
As you can see, you also need a set of parentheses after function calls, like Kill, even if you're not passing them any parameters. Instead of "Message", you'll want to use the global http://www.creationkit.com/Notification_-_Debug function to display a string to the screen.

GetDead's return value is of type bool, so instead of requiring your script to auto-cast the int value "0" to "false", I've used the boolean NOT operator to specify the condition you want.

I hope that helps.

Cipscis
User avatar
Dragonz Dancer
 
Posts: 3441
Joined: Sat Jun 24, 2006 11:01 am

Post » Tue Jun 19, 2012 3:51 am

Thank you that will help put me in the right direction on getting some of my code over from Oblivion
User avatar
Melanie Steinberg
 
Posts: 3365
Joined: Fri Apr 20, 2007 11:25 pm


Return to V - Skyrim