Jump to content

Fighter Rooster script


Recommended Posts

I was gonna make a Rooster that you will be able to summon, just for fun really and I peeked some at another Rooster companion and I thought, I just make the same but it does not work as I had expected and it has not been fun so far as the bloody Rooster refuses to fight.

 

AI is set too:

  • Aggression 0
  • Confidence 70
  • Energy 55
  • Responsibility 0
scn PekRoosterSCR

ref rEnemy
ref Me
ref Currenttarget
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Begin OnLoad
	Set Me to GetSelf
End

begin OnActivate
	
	if IsActionRef player
		SetIgnoreFriendlyHits 1
		if (Me.GetForceSneak == 0) && (player.IsSneaking == 1)
			Me.SetForceSneak 1
  		elseif (Me.GetForceSneak == 1) && (player.IsSneaking == 0)
			Me.SetForceSneak 0
		endif

		if PekSummonStuffQST.RoosterFollow == 1
			set PekSummonStuffQST.RoosterFollow to 0
			Message "'Rooster, wait here.'"
		elseif  PekSummonStuffQST.RoosterFollow == 0
			set PekSummonStuffQST.RoosterFollow to 1
			Message "'Rooster, come with me.'"
		endif

		EvaluatePackage
		playGroup Idle 1
	else
		activate
	endif
	
end

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Begin GameMode
	Set Me to GetSelf

	If ( PekSummonStuffQST.RoosterFollow == 1 )
		If ( player.isIncombat == 1 )
			;Message "Player is Fighting"
			If ( me.IsInCombat == 0 )
				Set Currenttarget to GetFirstRef 69 1
				While ( Currenttarget )
					If ( Currenttarget.GetCombatTarget == Player )
						StartCombat Currenttarget
						break
					EndIf
					set Currenttarget to GetNextRef
				Loop
			EndIf
		EndIf
	EndIf

End

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

begin OnStartCombat

;make sure not to attack friends after accidental hits.

	set rEnemy to getCombatTarget
	if GetShouldAttack rEnemy == 0 && Player.GetShouldAttack rEnemy == 0
		StopCombat
		StopCombatAlarmOnActor
		playGroup Idle 1
		return
	endif
end


The code I added is everything in the GameMode and when fighting starts, everyone just stands still now, no one is moving. I do recall we must redeposit the aggression? I did try to set aggression to 70 but then I also got attacked by it ;)

 

The OnStartCombat section doesn't seems to work as he do attack if he gets attacked but he doesn't seems to do any damage. Combat style is set to default and I also tried Default Clannfear Combat Style...

 

 

Link to comment
Share on other sites

I don't think you'll be able to get him to fight with zero Aggression, maybe if he's attacked first. The game uses Aggression and Disposition to determine whether or not to initiate combat. If Aggression is higher that Disposition the NPC will start combat ... otherwise they'll wait for another trigger (like being attacked).

Link to comment
Share on other sites

Thanks, that was what was needed really + I did a mod deposition and also made a timer

Begin GameMode

	If ( Timer < 3 )
		Set Timer to Timer + GetSecondsPassed
		Return
	Else
		Set Timer to 0
	EndIf


	Set Me to GetSelf

	If ( PekSummonStuffQST.RoosterFollow == 1 )
		If ( player.isIncombat == 1 )
			;Message "Player is Fighting"
			If ( me.IsInCombat == 0 )
				Set Currenttarget to GetFirstRef 69 1
				While ( Currenttarget )
					If ( Currenttarget.GetCombatTarget == Player )
						ModActorValue Aggression 30
						ModDisposition Currenttarget -100
						StartCombat Currenttarget
						break
					EndIf
					set Currenttarget to GetNextRef
				Loop
			EndIf
		Else 
			SetAv Aggression 10
		EndIf
	EndIf

End

The reason that The Rooster did stand still during combat and also made all others to stand still, was that the Chicken Creature folder made by mr_siika did lack all combat animations so I copied the Clannfear's animations to mr_siika's chicken folder and here you see the final lvl 10 Rooster in action with 1k health and attack 55. As soon as I got attacked, the Rooster started to crow and attacked. He did slaughter them all, while my char ran around in circles, avoiding combat and just watched him fight. :D

 

50803259138_5139b37d40_h.jpg

He did not have much health left after this. Fighting style is set to Default Clannfear so now I can release this. well soon at least... :wink:

Edited by Pellape
Link to comment
Share on other sites

The Rooster is a nutcase... I had to go to a subcell in the Testinghall and lock him in there... :/

 

He keeps getting Aggression 240 all time and attack everything and he killed half my farm, not that it will do much harm as they will respawn but why does he get aggression 240 as soon as I set it to 0?

He is in the same faction that every critter I added to the farm so he should protect them, not kill them nor attack me as their faction likes the playerfaction. It is like he have rabies and maybe he do?

 

It seems I need to work more with his script...

Link to comment
Share on other sites

I haven't done any changing aggression via script (scripting is stuff above my pay grade) but I have learned that sometimes a more cautious approach is warranted when toying with settings like aggression. One of my favourite bandits (BanditMeleeFemale3B) has her aggression permanently at 256 now.

 

I believe it happened when I was learning the ins and outs of changing an individual NPC's aggression using the console ... I now only use modav aggression X but early on I was using setav aggression X. Using setav in the console is not something I recommend. When I check her aggression in the CS she is still aggression 100 (the vanilla value) but when checked in game via the console all references that are spawned from her baseID are at aggression 256, so something must have got "baked into" the save files.

 

I no longer try to lower aggression to zero. I have found that aggression 1 is sufficient to keep even the most aggressive from attacking. My console routine is first to getav aggression and then I modav aggression the returned value minus 1 (not all enemies have aggression 100, so you can't just assume modav aggression -99).

Link to comment
Share on other sites

Thanks - It did work great and he is back to the farm again, happy as a rooster can be.

 

I think I will add a variable:

 

Set TheNewVariable to Getav Aggression

Set TheNewVariable to TheNewVariable - (TheNewVariable * 2) + 10

Modactorvalue aggression TheNewVariable

 

Then it will always end up with 10, no matter what he had before :D

 

I did got strange values at my 2 pet followers that I use at my 2 different comps after I used setav, so I will modav all their values, those that I did set manually so they are not to weak but also not to powerful, but balanced as pet followers.

Edited by Pellape
Link to comment
Share on other sites

Well I did these changes and the GameMode section looks like this now:

Begin GameMode

	If ( Timer < 3 )
		Set Timer to Timer + GetSecondsPassed
		Return
	Else
		Set Timer to 0
	EndIf


	Set Me to GetSelf

	If ( PekSummonStuffQST.RoosterFollow == 1 )
		If ( player.isIncombat == 1 )
			;Message "Player is Fighting"
			If ( me.IsInCombat == 0 )
				Set Currenttarget to GetFirstRef 69 1
				While ( Currenttarget )
					If ( Currenttarget.GetCombatTarget == Player )
						ModActorValue Aggression 30
						ModDisposition Currenttarget -100
						StartCombat Currenttarget
						break
					EndIf
					set Currenttarget to GetNextRef
				Loop
			EndIf
		Else 
			Set RoosterAggro to Getav Aggression
			Set RoosterAggro to RoosterAggro - (RoosterAggro * 2 ) + 10
			ModActorValue Aggression RoosterAggro
			EvaluatePackage
			playGroup Idle 1
		EndIf
	Else
		Set RoosterAggro to Getav Aggression
		If ( RoosterAggro > 10 )
			Set RoosterAggro to RoosterAggro - (RoosterAggro * 2 ) + 10
			ModActorValue Aggression RoosterAggro
			EvaluatePackage
			playGroup Idle 1
		EndIf
	EndIf

End

And he seems to work perfect. First I forgot to set - (TheNewVariable * 2) as I only set it to - TheNewVariable and he had aggro 540 until I figured that out as the TheNewVariable - TheNewVariable = 0 and if we add 10, then we raised the aggro with 10 every 3 seconds and he got berserked and started to Crow like a maniac.

Link to comment
Share on other sites

Damn... Now I start to understand how the Actor Values really works as SetAV and ModAV changes 2 different values and that explains why the Rooster became more and more aggressive

  • SetAV changes the base value
  • ModActorValue changes a modded value

So if I ModAV my Conjuration -1, the base value is still 99 but my skill is 98

 

50813429301_2b53dfe88f_z.jpg

 

So when I modded the Roosters aggression, it went up +30 every time and I tried to set it down with the base value... No wonder he went up to 540 aggression :D

 

I thought SetAV and ModAV did change the same value...

 

There is also an OBSE function called ModAVMod but is not clear which of these 2 values it modifies, the base or modded value? But as it to point at ModAV as changing the same value, it changes the modded value but cannot exceed the base value, which ModAV is able to do.

Link to comment
Share on other sites

Good detective work Pellape. That may explain why my console experiments resulted the way they did (and my bandit girlfriend does always respond properly to modav aggression -255 ... after I have confirmed her current aggression is 256).

 

I see vanilla scripts using setav, but I can't say for certain which actor values are being manipulated (something I be paying closer attention to while I'm trying to figure out this scripting thing).

 

Have you seen the CS Wiki pages SetActorValue and ModActorValue ... some of the info on those pages makes a bit more sense to me now.

Link to comment
Share on other sites

Yes they sure do and I did another conclusion just now:

 

Setav sets the baseID

Getav gets the modded value Quote: Returns the current, modified value of the specified stat.

 

OBSE did introduced GetActorValueC but does not write if it is the base or modded value it returns. Only way I guess is to test it in a script as OBSE commands seldom return values in the Console, with some exceptions of course, like getbaseobject...

Edited by Pellape
Link to comment
Share on other sites

  • Recently Browsing   0 members

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