Script adding spell while running

Post » Wed Jun 20, 2012 11:14 am

I just can't get the hang of this new scripting language. It's so frustrating.
Can someone knowledgable about how to script Skyrim show me how to add a spell to the player while they are running?
Here is how I would have written it in Oblivion (if my memory of that scripting language is right)

scriptname RunningSpell

Begin GameMode

If (player.isrunning == 1)
player.addspell SuperSpeedSpell

Else
player.removespell SuperspeedSpell

End

I've poured throught the wiki and Youtube, but I'm lost. Help?
User avatar
CArla HOlbert
 
Posts: 3342
Joined: Wed Feb 21, 2007 11:35 pm

Post » Wed Jun 20, 2012 8:02 pm

Here are some things concerning this that I found in the wiki, but I still don't get it.

Examples ; Adds the sheep spell to the player
if (Game.GetPlayer().AddSpell(SheepSpellProperty))
Debug.Trace("Sheep spell added to the player")
endIf

; Adds the sheep spell to the player, silently
if (Game.GetPlayer().AddSpell(SheepSpellProperty, false))
Debug.Trace("Sheep spell added to the player (like a ninja!)")
endIfNotes

bool Function IsRunning() native
if !Forrest.IsRunning()
Debug.Trace("Run, Forrest, Run!")
endIf

So, what are the parenthesis for after GetPlayer? Do I need to use Extend Actor at my scriptname? What does bool and native mean exactly?
User avatar
James Potter
 
Posts: 3418
Joined: Sat Jul 07, 2007 11:40 am

Post » Wed Jun 20, 2012 9:12 pm

	Spell Property SuperSpeedSpell Auto	If Game.GetPlayer().IsRunning() != Game.GetPlayer().HasSpell(SuperSpeedSpell)		If Game.GetPlayer().IsRunning()			Game.GetPlayer().AddSpell(SuperSpeedSpell)		Else			Game.GetPlayer().RemoveSpell(SuperSpeedSpell)		EndIf	EndIf
There is no GameMode as blocktypes have been replaced with http://www.creationkit.com/Event.
User avatar
George PUluse
 
Posts: 3486
Joined: Fri Sep 28, 2007 11:20 pm

Post » Wed Jun 20, 2012 7:34 pm

Thank you JustinOther,
I'm embarassed I forgot my Endif, but it's been frustrating figuring this out.
I don't quite get what "Auto" is for and the Wiki isn't very clear. Maybe it's like Gamemode in Oblivion, running things in the background?
I like how you thought to add the != measure to ensure the actor doesn't have the spell already. Thank you for that. It probably saved me more headaches.
User avatar
Emilie Joseph
 
Posts: 3387
Joined: Thu Mar 15, 2007 6:28 am

Post » Wed Jun 20, 2012 10:41 am

No prob, and there's a start. Auto is one of Papyrus' http://www.creationkit.com/Extends. If a Property name matches exactly the EditorID of its intended target Form/Ref, it will automatically be pointed to the appropriate target when filled by the editor in the attached form's edit window. For instance,
Actor Property PlayerREF Auto
lets you use PlayerREF in lieu of Game.GetPlayer(), GetPlayer() being a member of http://www.creationkit.com/Game_Script_(Papyrus) (Skyrim\Data\Scripts\Game.PSC).
User avatar
Leah
 
Posts: 3358
Joined: Wed Nov 01, 2006 3:11 pm


Return to V - Skyrim