Jump to content

Help with a script?


lFostelR

Recommended Posts

Scriptname JTAeatscript extends ActiveMagicEffect


Idle Property IdleEatingStandingStart AUTO

Idle Property chaireatingstart AUTO

Event OnEffectStart (Game.player.SetDontMove(),actor akactor, actor akCaster)

Game.player.SetDontMove()

if Game.Getplayer().GetSitState() == 0

; While the player has a weapon drawn, try to have him sheathe it every tenth-second.

while !EscapeClause && player.IsWeaponDrawn() && !player.IsDead()

Game.player.SetDontMove()==3.playidle(IdleEatingStandingStart)

endif

if Game.Getplayer().GetSitState() == 3

Game.Getplayer().playidle(chaireatingstart)

endif


EndEvent



can anyone tell me how to add a function to this example that will disable movement untill the effect is over?

something like:

player.SetDontMove()

Game.DisablePlayerControls


keep in mind, I have zero scripting skills.

Link to comment
Share on other sites

If you don't want the player to be able to move through input (W, S, A, D) then Game.DisablePlayerControls is the way to go, SetDontMove just stops the actor (in your case the player actor) from moving / being pushed around, so the player can potentially still do actions that could stuff up the animations.

 

So an example of what it could look like (If I am reading what you are asking correctly) could look like this:

Scriptname JTAeatscript  extends ActiveMagicEffect
 
Idle Property IdleEatingStandingStart AUTO
Idle Property chaireatingstart AUTO

Event OnEffectStart (actor akTarget, actor akCaster)
	Game.player.SetDontMove()
	Game.DisablePlayerControls() ; Which by default disables movement, fighting (attacking input), activating and entering menus
	if Game.Getplayer().GetSitState() == 0
	; While the player has a weapon drawn, try to have him sheathe it every tenth-second.
		while !EscapeClause && player.IsWeaponDrawn() && !player.IsDead()
			Game.player.SetDontMove().playidle(IdleEatingStandingStart)
		endwhile
	elseif Game.Getplayer().GetSitState() == 3
		Game.Getplayer().playidle(chaireatingstart)
	endif
 
EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	Game.EnablePlayerControls() ;Sister Function to Disable which by default enables all.
EndEvent
Edited by Arocide
Link to comment
Share on other sites

this fails to compile, any idea why?

 

Compiling "JTAeatscript"...
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(7,6): a property cannot be used directly on a type, it must be used on a variable
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(7,6): player is not a property on script game or one of its parents
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(7,13): none is not a known user-defined type
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(11,9): variable EscapeClause is undefined
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(11,25): variable player is undefined
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(11,32): none is not a known user-defined type
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(11,52): variable player is undefined
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(11,59): none is not a known user-defined type
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(12,8): a property cannot be used directly on a type, it must be used on a variable
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(12,8): player is not a property on script game or one of its parents
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(12,15): none is not a known user-defined type
C:\Program Files (x86)\Steam\steamapps\common\skyrim\Data\Scripts\Source\JTAeatscript.psc(12,29): none is not a known user-defined type
No output generated for JTAeatscript, compilation failed.
Batch compile of 1 files finished. 0 succeeded, 1 failed.
Failed on JTAeatscript
Edited by foster xbl
Link to comment
Share on other sites

edit, I'm sorry I posted wrong info the script I want to add to looks like this

 

Scriptname JTAeatscript extends ActiveMagicEffect
Idle Property IdleEatingStandingStart AUTO
Idle Property chaireatingstart AUTO
Event OnEffectStart (actor akactor, actor akCaster)
if Game.Getplayer().GetSitState() == 0
Game.Getplayer().playidle(IdleEatingStandingStart)
endif
if Game.Getplayer().GetSitState() == 3
Game.Getplayer().playidle(chaireatingstart)
endif
EndEvent
Link to comment
Share on other sites

  On 11/19/2014 at 2:59 AM, foster xbl said:

this fails to compile, any idea why?

 

I quite simply copy pasted what you posted, there are numerous errors in the script which need to be addressed.

 

  On 11/19/2014 at 3:02 AM, foster xbl said:

 

edit, I'm sorry I posted wrong info the script I want to add to looks like this

 

Scriptname JTAeatscript extends ActiveMagicEffect
Idle Property IdleEatingStandingStart AUTO
Idle Property chaireatingstart AUTO
Event OnEffectStart (actor akactor, actor akCaster)
if Game.Getplayer().GetSitState() == 0
Game.Getplayer().playidle(IdleEatingStandingStart)
endif
if Game.Getplayer().GetSitState() == 3
Game.Getplayer().playidle(chaireatingstart)
endif
EndEvent

 

 

now that makes a lot more sense. It would be pretty simple, just add PlayerControls functions like this:

Scriptname JTAeatscript  extends ActiveMagicEffect

Idle Property IdleEatingStandingStart AUTO
Idle Property chaireatingstart AUTO

Event OnEffectStart (actor akactor, actor akCaster)
Game.DisablePlayerControls() ; Which by default disables movement, fighting (attacking input), activating and entering menus

If akactor.GetSitState() == 0
	akactor.playidle(IdleEatingStandingStart)
ElseIf akactor.GetSitState() == 3
	akactor.playidle(chaireatingstart)
endif

EndEvent

Event OnEffectFinish(Actor akTarget, Actor akCaster)
	Game.EnablePlayerControls() ;Sister Function to Disable which by default enables all.
EndEvent

I assume the target of the magic effect is the player

Edited by Arocide
Link to comment
Share on other sites

  On 11/19/2014 at 3:47 AM, foster xbl said:

well this compiles, but doesn't work :sad:

my character still is able to move during the animations the script plays

 

How exactly is your magic effect applied? is it an Ability or a Spell, is it a constant effect or concentration or fire and forget?

Edited by Arocide
Link to comment
Share on other sites

I thought your name looked familiar, I've used your mod before :smile: .

 

This makes it much simpler, they are set as fire and forget so it won't work the way I set it out, my bad.

 

The most simple solution I could think of that requires little rewriting would be something like this:

Scriptname JTAeatscript  extends ActiveMagicEffect

Idle Property IdleEatingStandingStart AUTO
Idle Property chaireatingstart AUTO
Float Property animationDuration =  1.2 auto ;1.2 default, what you would want to do is change this to the duration (in seconds) of the animation, this will prevent movement for the duration of the animation, but is a property so you can customise the duration if need be per script instance via creation kit.

Event OnEffectStart (actor akactor, actor akCaster)
Game.DisablePlayerControls() ; Which by default disables movement, fighting (attacking input), activating and entering menus

If akactor.GetSitState() == 0
	akactor.playidle(IdleEatingStandingStart)
ElseIf akactor.GetSitState() == 3
	akactor.playidle(chaireatingstart)
endif
;if the duration will always be the same then you can just skip creating a property and directly place a float in the wait function.
Utility.Wait(animationDuration) ; Pauses Script execution for x seconds
Game.EnablePlayerControls() ;Sister Function to Disable which by default enables all.
EndEvent

Didn't test it but it should do what you want... I hope. You may also want to setDontMove as well, to prevent the player from being pushed around while the animations are playing, otherwise they could still ghost :wink:

Edited by Arocide
Link to comment
Share on other sites

  • Recently Browsing   0 members

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