Non working combat script

Post » Sat Aug 06, 2016 9:57 am

Hello, back again.


Could anyone please tell me why this script is not working, as it has been a long long time since I have worked with papyrus and cannot understand why this does not work.



Attached this to a blank quest with both start game enabled and run once both checked.




In quest Alias I have created a specific reference of Player(ref) in cell (any) where I have placed the script in Papyrus scripts filling in the property with Player(ref) and cell(any)




The script is below:



ScriptName Playercombatcontrols extends ReferenceAlias



import game

import debug

Actor Property PlayerRef Auto

auto State forStart

Event OnCombatStateChanged(Actor PlayerRef, int combatState)

if combatState != 0

game.disableplayercontrols(true,true,true,true,true,true,true)

gotoState("forstop")


endIf

endEvent

endState


State forstop

Event OnCombatStateChanged(Actor PlayerRef, int combatState)

if combatState != 1

game.disableplayercontrols(false,false,false,false,false,false,false)

gotoState("forstart")


endIf

endEvent

endState




Have I done something stupid? As I stated I have been far removed from papyrus for a while so this is very possible.


Also the game.disableplayercontrols has been implemented mainly to show whether the script works or not while in game.


Thanks.
User avatar
Céline Rémy
 
Posts: 3443
Joined: Sat Apr 07, 2007 12:45 am

Post » Sat Aug 06, 2016 5:33 am

Per the wiki:


  • This event will not work to detect when the player changes combat states. It can only detect combat state changes for other actors.

oh and the quest should not be set to run once I do not think, otherwise reload games will not work (not sure).

User avatar
KiiSsez jdgaf Benzler
 
Posts: 3546
Joined: Fri Mar 16, 2007 7:10 am

Post » Sat Aug 06, 2016 4:23 am

Thanks for the reply! Damn that is annoying, don't suppose you or anyone else has another way to detect player combat as this won't? :) Thanks!

User avatar
Alycia Leann grace
 
Posts: 3539
Joined: Tue Jun 26, 2007 10:07 pm

Post » Sat Aug 06, 2016 8:33 am

Hey everyone I have got my script working, here it is in case anyone has a similar problem:



ScriptName Playercontrols extends Quest




Import Debug




Import Game




Actor Property PlayerRef Auto

int Bugz

Event OnInit()

Bugz=1

debug.notification("You cannot use this item while in combat.")

While (Bugz==1)


if (PlayerRef.IsInCombat())



Utility.Wait(1.0)

else



Utility.Wait(1.0)

endif

endWhile



EndEvent
User avatar
james tait
 
Posts: 3385
Joined: Fri Jun 22, 2007 6:26 pm

Post » Sat Aug 06, 2016 5:41 am

That should work only once or twice depending on the Quest having to restart.



Best way to track when the player enters combat is to attach an ability with a condition that internally checks every second if the player isInCombat or not.

User avatar
Ria dell
 
Posts: 3430
Joined: Sun Jun 25, 2006 4:03 pm

Post » Sat Aug 06, 2016 5:10 am

Been working fine for me for the past week or so, very accurate as well :) Will update if I run into problems.

User avatar
Beast Attire
 
Posts: 3456
Joined: Tue Oct 09, 2007 5:33 am


Return to V - Skyrim