Jump to content

Photo

Need help with Oncombat script


  • Please log in to reply
18 replies to this topic

#1
Maleagant

Maleagant

    Journeyman

  • Members
  • Pip
  • 30 posts
This script is supposed to force the Follower actor to Cast the Werewolfchange spell at the beginning of combat. (Yes I know this is a once a day power, useing it as a test spell (to make sure the script works) before I modify it to a lesser power for multiple uses on the Follower).


Here's my script:


ScriptName activateSelfOnCombatBegin extends Actor
{Script that lives on an actor that simply activates itself on Combat Begin}

import game
import debug

auto State waiting
	Event OnCombatStateChanged(Actor actorRef, int combatState)
		if combatState != 0 ; 0 = not in combat, so if the state isn't 0, they entered combat
			gotoState("allDone")
			activate(Self)
		endIf
	endEvent
endState

State allDone
	;do nothing
endState
	
SPELL Property WerewolfChange  Auto  

Event OnCombat (Kythiraamanan)

		Werewolfchange.cast(Self, Self)
endEvent



I am receiving this error when compiling:

Compiling "activateSelfOnCombatBegin"...
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\activateSelfOnCombatBegin.psc(22,29): missing ID at ')'
No output generated for activateSelfOnCombatBegin, compilation failed.

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

Any help would be apreciated (or a script if anyone knows one that works like this)

Thanks :D

Edited by Maleagant, 11 April 2012 - 03:38 AM.


#2
Maleagant

Maleagant

    Journeyman

  • Members
  • Pip
  • 30 posts
My second attempt:

ScriptName activateSelfOnCombatBegin extends Actor
{Script that lives on an actor that simply activates itself on Combat Begin}

import game
import debug

auto State waiting
	Event OnCombatStateChanged(Actor actorRef, int combatState)
		if combatState != 0 ; 0 = not in combat, so if the state isn't 0, they entered combat
			gotoState("allDone")
			activate(Self)
		endIf
	endEvent
endState

State allDone
	;do nothing
endState
	
SPELL Property WerewolfChange  Auto  

Event OncombatStateChanged(sskythiraamanan akTarget, 0 aeCombatState)

	if (akTarget == Game.GetPlayer())
		if (aeCombatState == 1)
			Werewolfchange.Cast(Kythiraamanan())
		endif
	endif

EndEvent


Gives this error:

Compiling "activateSelfOnCombatBegin"...
c:\program files (x86)\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\activateSelfOnCombatBegin.psc(22,53): no viable alternative at input '0'
No output generated for activateSelfOnCombatBegin, compilation failed.

#3
fg109

fg109

    Faithful poster

  • Members
  • PipPipPipPip
  • 1,244 posts
I do not know where you got that script, but there are lots of things wrong with it.

Why do you have states in your script when you're not using them for anything? You have a command telling your script to go to one state, but no command telling it to go back to the previous state. What is 'sskythiraamanan' and 'Kythiraamanan'? Why are you trying to have the actor activate itself instead of casting the transform spell like you wanted?

Anyway, I would use a script like this:

Scriptname Example extends Actor

SPELL Property WerewolfChange Auto

Event OnCombatStateChanged(Actor actorRef, int combatState)

	if (combatState == 1)	;started combat
		WerewolfChange.Cast(Self)
	elseif (combatState == 0)	;left combat
		DispelSpell(WerewolfChange)
	endif

EndEvent


#4
RandomlyAwesome

RandomlyAwesome

    Journeyman

  • Members
  • Pip
  • 40 posts
I'm not A scripter but this may work

So instead of
Event OnCombatStateChanged(Actor actorRef, int combatState)
                if combatState != 0 ; 0 = not in combat, so if the state isn't 0, they entered combat
try
Event OnCombatStateChanged(Actor actorRef, int combatState)
                if (Follower.GetCombatState() != 0)  ; 0 = not in combat, so if the state isn't 0, they entered combat
Replace the word follower with your follower's id/name tough(not sure which one is needed)
And if THAT doesn't work try this
Event OnCombatStateChanged(Actor actorRef, int combatState)
                if aeCombatState != 0 ; 0 = not in combat, so if the state isn't 0, they entered combat
Edit:Ohh well I'm too late fg109's script should be perfect tough.

Edited by RandomlyAwesome, 11 April 2012 - 06:35 AM.


#5
scrivener07

scrivener07

    Faithful poster

  • Premium Member
  • 1,201 posts
Fg's script is perfect. It will work on any actor you attach the script to. Nice script :thumbsup:

#6
Maleagant

Maleagant

    Journeyman

  • Members
  • Pip
  • 30 posts

I do not know where you got that script, but there are lots of things wrong with it.

Why do you have states in your script when you're not using them for anything? You have a command telling your script to go to one state, but no command telling it to go back to the previous state. What is 'sskythiraamanan' and 'Kythiraamanan'? Why are you trying to have the actor activate itself instead of casting the transform spell like you wanted?

Anyway, I would use a script like this:

Scriptname Example extends Actor

SPELL Property WerewolfChange Auto

Event OnCombatStateChanged(Actor actorRef, int combatState)

	if (combatState == 1)	;started combat
		WerewolfChange.Cast(Self)
	elseif (combatState == 0)	;left combat
		DispelSpell(WerewolfChange)
	endif

EndEvent


I tried this out, it works, but there is a slight issue, She will change into a werewolf when she enters combat, But she will not change back after leaving it. Any ideas? (By the way I will be giveing you full credit for this in the Mod since you've helped me solve the issue if we can actually get this to work).

#7
scrivener07

scrivener07

    Faithful poster

  • Premium Member
  • 1,201 posts

                Self.DispelSpell(WerewolfChange)



#8
Maleagant

Maleagant

    Journeyman

  • Members
  • Pip
  • 30 posts

                Self.DispelSpell(WerewolfChange)


It compiles, but she still wont change back :(

#9
scrivener07

scrivener07

    Faithful poster

  • Premium Member
  • 1,201 posts
Maybe there is a separate spell that handles changing back to a humanoid. Ive never looked at the werewolf spells myself so that could be bunk.

#10
Maleagant

Maleagant

    Journeyman

  • Members
  • Pip
  • 30 posts

Maybe there is a separate spell that handles changing back to a humanoid. Ive never looked at the werewolf spells myself so that could be bunk.


It looks like she actually dispels it, but she remains a werewolf race, May need to somehow add a function that saves her race before the transformation and then sets her race back to herself after combat ends.

(Like Douge does with his Skeever Fevor quest on youtube only he uses a single shot quest, whereas were trying to make this continuous every time thing.)

And unfortunately the papyrus script commands work differently on NPC's Vs Quest Alias's (Tried just modifying his set race script but to no avail) :(

Edited by Maleagant, 11 April 2012 - 07:59 AM.





Page loaded in: 1.156 seconds