How can I make an actor become aggressive towards the player

Post » Wed Jun 20, 2012 11:18 pm

Alright I'm trying to make a quest where an actor betrays the player and starts attacking him.

It goes like this: The player accepts the quest and the actor follows him. The player goes into the cave and then walks into a trigger box which enables stage 30 of the quest:


Scriptname STQActivatorScript extends ObjectReference  Quest property quest01 auto Event onActivate(ObjectReference akActionRef)if(quest01.GetStage() == 20)quest01.SetStage(30)endifendevent




Stage 30 completes objective 20 and stops scene01(which is the scene that makes the actor follow the player) and starts scene2(which is where he betrays the player) and enables 2bandits to help him try and kill the player:


SetObjectiveCompleted(20)STQHuntScene01.Stop()STQHuntScene02.Start()Alias_Bandit1.GetReference().Enable()Alias_Bandit2.GetReference().Enable()

When scene 2 starts it removes the faction "DunPlayerAllyFaction" and adds the faction "BanditFaction" to the actor:


STQHunter.AddToFaction(BanditFaction)STQHunter.RemoveFromFaction(DunPlayerAllyFaction)

This is what I have tried:
What I tried at first is adding him to the faction "BanditFaction" through a papyrus script.
Then I tried making him aggressive which also didn't work. This also made him attack various things which ended up making the quest not work.

Then I tried adding him to the faction "DunPlayerAllyFaction" as default then removing said faction and then adding the bandit faction whilst keeping him in very aggressive mode.



And finally here is the file: http://filesmelt.com/dl/StreamQuest.rar
(Just find the interior cell called BleakRockCave. The actor is right outside the cave.)
User avatar
Jordan Fletcher
 
Posts: 3355
Joined: Tue Oct 16, 2007 5:27 am

Post » Wed Jun 20, 2012 1:51 pm

You should be able to just use

STQHunter.StartCombat(Game.GetPlayer())
User avatar
Arrogant SId
 
Posts: 3366
Joined: Sat May 19, 2007 11:39 am

Post » Wed Jun 20, 2012 8:34 pm

hah! I knew I would feel stupid when the solution came up.

Thank you! I will see if it works.
User avatar
Eddie Howe
 
Posts: 3448
Joined: Sat Jun 30, 2007 6:06 am

Post » Wed Jun 20, 2012 1:20 pm

Alright I tried to assign the script to the end of scene 2. It didn't recognize the function "StartCombat".

I tried creating a new stage which would get enabled when the scene is over. But there it wouldn't recognize the function.

I tried assigning it to an actor just to see if it would recognize the function there. And it didn't.


I don't understand whats going on because StartCombat is on the wiki page and everything and I have often used these sorts of functions before without a problem.


The code that gets run at the end of scene 2 looks like this:

GetOwningQuest().SetObjectiveDisplayed(30)Bandit1.StartCombat(Game.GetPlayer())Bandit2.StartCombat(Game.GetPlayer())frederick.StartCombat(Game.GetPlayer())


All properties are ObjectRefrence properties.
User avatar
Eduardo Rosas
 
Posts: 3381
Joined: Thu Oct 18, 2007 3:15 pm

Post » Wed Jun 20, 2012 2:31 pm

You could also put them in a faction, and in the CK set it as friendly to the player so that they arent inherantly hostile. Then, via script, use http://www.creationkit.com/Faction.SetEnemy_(Papyrus) to make their faction hostile towards the player.
User avatar
Anthony Rand
 
Posts: 3439
Joined: Wed May 09, 2007 5:02 am

Post » Wed Jun 20, 2012 9:12 am

StartCombat() is a function from the actor script, so you need to have the bandits declared as actors, not object references. Or you could use casting and do this:

GetOwningQuest().SetObjectiveDisplayed(30)(Bandit1 as Actor).StartCombat(Game.GetPlayer())(Bandit2 as Actor).StartCombat(Game.GetPlayer())(frederick as Actor).StartCombat(Game.GetPlayer())
User avatar
[Bounty][Ben]
 
Posts: 3352
Joined: Mon Jul 30, 2007 2:11 pm

Post » Wed Jun 20, 2012 3:25 pm

StartCombat() is a function from the actor script, so you need to have the bandits declared as actors, not object references. Or you could use casting and do this:

GetOwningQuest().SetObjectiveDisplayed(30)(Bandit1 as Actor).StartCombat(Game.GetPlayer())(Bandit2 as Actor).StartCombat(Game.GetPlayer())(frederick as Actor).StartCombat(Game.GetPlayer())

Ah of course. Thank you.

I have yet to properly understand the fundamentals of papyrus.
User avatar
Valerie Marie
 
Posts: 3451
Joined: Wed Aug 15, 2007 10:29 am


Return to V - Skyrim