[dismiss]
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.
Difference between revisions of "GetSummoner"
Jump to navigation
Jump to search
Added a third piece of code that extends the search to the player's last cell
imported>Kyoma (Updated the code to work for player summons) |
imported>Kyoma (Added a third piece of code that extends the search to the player's last cell) |
||
Line 9: | Line 9: | ||
*This function must be called on a reference (Ref.call <function>) | *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. | *If the summoner is not in the same cell as the summon then it will return 0. | ||
*When called on a summon that is in the process of disappearing it will return 0 | ** The very last piece of code has something that scans the player's last cell for the summoner, it should work for 95% of the time. | ||
*When called on a summon that is in the process of disappearing it will return 0 since the ''summoning'' has ended. Use [[GetDead]] to determine if a summon is still ''summoned''. | |||
==Examples:== | ==Examples:== | ||
Getting an array with all the summons active on a reference (in this case a summon that is stored in the '''someSummonRef''' variable) | 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 | Let rSummoner := someSummonRef.Call GetSummoner | ||
Line 27: | Line 28: | ||
let rSummon := GetSelf | let rSummon := GetSelf | ||
;Player requires special handling | |||
let arSummons := player.GetFollowers | let arSummons := player.GetFollowers | ||
let iFollower := player.GetNumFollowers | let iFollower := player.GetNumFollowers | ||
Line 37: | Line 39: | ||
SetFunctionValue player | SetFunctionValue player | ||
let arSummons := ar_Null | let arSummons := ar_Null | ||
else | |||
let rActor := GetFirstRef 69 2 | |||
While rActor | |||
if rActor.GetDead == 0 && rActor.GetDisabled == 0 | |||
let arSummons := rActor.GetFollowers | |||
let iFollower := rActor.GetNumFollowers | |||
While iFollower > 0 | |||
let iFollower -= 1 | |||
let rFollower := rActor.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 | |||
endif | endif | ||
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 | let arSummons := player.Call GetSummons | ||
if eval (ar_Find rSummon arSummons) != -99999 | |||
SetFunctionValue player | |||
let arSummons := ar_Null | |||
else | |||
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 | endif | ||
let rActor := GetNextRef | |||
Loop | |||
endif | |||
let arSummons := ar_Null | let arSummons := ar_Null | ||
End | End | ||
Code that also checks the player's last visited cell when it was not found in the current cell (also uses [[GetSummons]]). | |||
ScriptName GetSummoner | ScriptName GetSummoner | ||
ref rSummon | ref rSummon | ||
array_var arSummons | array_var arSummons | ||
ref rActor | ref rActor | ||
ref rLast | |||
Begin Function {} | Begin Function {} | ||
Line 72: | Line 102: | ||
SetFunctionValue player | SetFunctionValue player | ||
let arSummons := ar_Null | let arSummons := ar_Null | ||
else | |||
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 | |||
if rActor == 0 | |||
let rLast := GetPlayersLastActivatedLoadDoor | |||
if rLast | |||
let rLast := rLast.GetParentCell | |||
if rLast | |||
let rActor := GetFirstRefInCell rLast 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 | |||
Break | |||
endif | |||
endif | |||
let rActor := GetNextRef | |||
Loop | |||
endif | |||
endif | endif | ||
endif | endif | ||
endif | |||
let arSummons := ar_Null | let arSummons := ar_Null | ||
End | End |