This wiki is a copy of the original Oblivion CS wiki created and maintained by the UESP.net. See CSwiki:Copy Notice for more info.

GetSummoner

From the Oblivion ConstructionSet Wiki
Revision as of 05:19, 26 December 2009 by imported>Kyoma (New page: __NOTOC__ A User Function for use with Oblivion Script Extender '''Syntax:''' (summoner:ref) reference.Call GetSummoner Returns a reference to...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

A User Function for use with Oblivion Script Extender

Syntax:

(summoner:ref) reference.Call GetSummoner

Returns a reference to whoever summoned the calling actor.

Notes

  • This function must be called on a reference (Ref.call <function>)
  • If the summoner is not in the same cell as the summon then it will return 0.

Examples:

Getting an array with all the summons active on a reference (in this case a summon that is stored in the someSummonRef variable)

Let rSummoner := someSummonRef.Call GetSummoner

Code

ScriptName GetSummoner
ref rSummon
array_var arSummons
ref rActor
ref rFollower
long iFollower

Begin Function {}
	let rSummon := GetSelf
	let rActor := GetFirstRef 69 2
	While rActor
		if rActor.GetDead == 0 && rActor.GetDisabled == 0
			let arSummons := GetFollowers
			let iFollower := GetNumFollowers
			While iFollower > 0
				let iFollower -= 1
				let rFollower := GetNthFollower iFollower
				ar_Erase arSummons (ar_Find rFollower arSummons )
			Loop
			if eval (ar_Find rSummon arSummons) != -99999
				SetFunctionValue rActor
			endif
		endif
		let rActor := GetNextRef
	Loop
	let arSummons := ar_Null
End 

Alternative code for use with GetSummons (to avoid duplicate code)

ScriptName GetSummoner
ref rSummon
array_var arSummons
ref rActor

Begin Function {}
	let rSummon := GetSelf
	let rActor := GetFirstRef 69 2
	While rActor
		if rActor.GetDead == 0 && rActor.GetDisabled == 0
			let arSummons := rActor.Call GetSummons
			if eval (ar_Find rSummon arSummons) != -99999
				SetFunctionValue rActor
			endif
		endif
		let rActor := GetNextRef
	Loop
	let arSummons := ar_Null
End 

See Also