Jump to content

OnCombatStateChanged > ForceRefTo akTarget


Recommended Posts

I'm trying to force a combat target of my follower into a quest with her.

I am trying to use the following setup:

 

Quest Alias: 'CombatTarget' (Optional, Dead, Disabled, Destroyed)

Specific Reference: Forced to <NONE>

 

In the Alias attached Quest of my follower I run the following code:

 

ReferenceAlias Property pCombatTarget Auto Const

Event OnCombatStateChanged(Actor akTarget, int aeCombatState)

	if (aeCombatState == 0)
		Debug.Trace("Ivy has left combat")

	elseif (aeCombatState == 1)
		
		Actor CT
		CT = Ivy.GetCombatTarget()

		;only start a special attack when the conditions are met.
		if Ivy.GetDistance(CT) > 720 && Ivy.GetDistance(CT) < 8000

			;reset the special attacks quest.
			p_ivy_special_attacks.Reset()
			Utility.Wait(0.1)
			p_ivy_special_attacks.Start()
			Utility.Wait(0.2)

			pCombatTarget.ForceRefTo(CT)
			;give some time for the engine to fill the ref..
			Utility.Wait(0.5)

			;start a random special attack scene in the special attacks quest.
			p_ivy_special_attacks_Attack_Selector.Start()
		 endif

	elseif (aeCombatState == 2)
		Debug.Trace("Ivy is searching...")
	endIf

endEvent
But whatever code I run against akTarget, it always bombs out in the papyrus log with 'cannot run this on a NONE object'.

I can't check the distance, I can't force the actor into my target.

Yet... the combat state changed.. so there must be a combat target right?

 

I've tried forcing refs from other events as well and that failed also.

To make sure I was not failing on something else with combat, I hooked into the player.additem event. That has an akTarget as well, also always empty.. yet I CAN runn stuff like 'haskeyword' on it.

I'm very lost at this point.

 

I want to:

 

- Identify a combat target of my follower.

- Run a mini quest with both actors.

 

But it's all failing on me filling the CombatTarger alias with Ivy's actual combat target.

Any help is really appreciated.. it's so frustrating being stuck like this. :sad:

Edited by Reginald001
Link to comment
Share on other sites

Not really an expert here, but some guess from own experience.

- Do not set Specific reference, just keep every fill option empty;

- There's no need to reset quest every time, just update the CT alias and run the Scene;

- Reset without Stop and trying to Start() (again, is there a real need to restart?);

- F4 quests do reset alias data on Stop(), no need to Reset (unless you need to clear all done Stages), and they successfully refill auto-fill aliases after being restarted (unlike in Skyrim - wiki says, it was a trouble);

Edited by hereami
Link to comment
Share on other sites

Thanks! Some good tips in there. I'll check to remove the reset.

 

I managed to fix it by implementing a while loop that waits for the alias to fill. Apparently the combattarget is not always filled, or not always valid, so in that case the loop stops and the special move is skipped.

Edited by Reginald001
Link to comment
Share on other sites

Thanks! Some good tips in there. I'll check to remove the reset.

 

I managed to fix it by implementing a while loop that waits for the alias to fill. Apparently the combattarget is not always filled, or not always valid, so in that case the loop stops and the special move is skipped.

Good you succeeded : ) Curious, if loop includes GetCombatTarget value or alias check only, i'd suppose, it should be filled immediately after ForceRefTo. But really confused now about giving any tips, all said worked somehow for me and simple aliases, yes, but now as i've dealt with a dynamic RefCollection for the first time, got completely stuck - my alias keeps alive no matter what i do - Reset or Stop, and keeps running packages. Stupored. Don't understand a thing.

Link to comment
Share on other sites

 

Thanks! Some good tips in there. I'll check to remove the reset.

 

I managed to fix it by implementing a while loop that waits for the alias to fill. Apparently the combattarget is not always filled, or not always valid, so in that case the loop stops and the special move is skipped.

Good you succeeded : ) Curious, if loop includes GetCombatTarget value or alias check only, i'd suppose, it should be filled immediately after ForceRefTo. But really confused now about giving any tips, all said worked somehow for me and simple aliases, yes, but now as i've dealt with a dynamic RefCollection for the first time, got completely stuck - my alias keeps alive no matter what i do - Reset or Stop, and keeps running packages. Stupored. Don't understand a thing.

 

I stepped away from forcing the ref into an alias to begin with, like this:

 

 

    Ivy = pIvy.GetActorRef()
    pPlayerRef = Game.GetPlayer()

    CombatTarget = Ivy.GetCombatTarget()
    While Ivy.GetAllCombatTargets().Length > 0 && CombatTarget == None
        CombatTarget = Ivy.GetCombatTarget()
        utility.wait(0.1)
    Endwhile

 

I check her combattargets.length because it's a better indicator than IsInCombat() and it prevents the loop from running indefinitely. It works like a charm. (Videos available of all of this in action if you google 'companion ivy' and check the latest forum threads).

Link to comment
Share on other sites

  • Recently Browsing   0 members

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