TryToAddToFaction - ReferenceAlias

Member of: ReferenceAlias Script

This is a convenient way to add an actor in an alias to a faction without calling GetActorReference() on it. It's mostly useful in cases where you have lots of aliases that may or may not be filled and you want to call AddToFaction() on them without having to test for a reference being present first.

SyntaxEdit

bool Function TryToAddToFaction(Faction FactionToAddTo)
	Actor ActorRef = GetActorReference()
	if ActorRef
		ActorRef.AddToFaction(FactionToAddTo)
		Return True
	EndIf
	Return False
EndFunction

ParametersEdit

  • FactionToAddTo: The faction to add the actor to

Return ValueEdit

True if the actor was added to the faction, false if no actor existed to be added.

Notes:Edit

  • True is a reflection that the actor reference existed -> and AddToFaction() was called on it
  • AddtoFaction() is an external call to the actor script, which does not wait, or return a value.
  • Consquently, add to faction can still be queued or processing by the time this function returns true.
  • False behaves as expected, no reference in alias, no actions performed

ExamplesEdit

; Try to add the boss to the bandit faction
BossAlias.TryToAddToFaction(BanditFaction)

See AlsoEdit