In a SP game, this should return the First PC every time. My question is, does it return the owned character, or the posessed character of the First PC?
In my module I have several on death scripts that resurrect the faction leader when an oppenent dies if the faction leader is dead. My intent is that the owned character of the player is resurrected, but I have been noticing that it does not always work that way. Here is the current script I am working on:
//////////////////////////////
#include "ginc_cutscene"
void main()
{
string sConversation = "2024_valheir_seir_keza_room";
/*
object oTalker = GetFirstPC();
int nIsInCombat = GetIsInCombat(oTalker);
//if the entering object is in combat, return.
*/
object oSelf = OBJECT_SELF;
object oKiller = GetLastKiller();
object oLeader = GetFactionLeader(GetLastKiller());
object oArea = GetObjectByTag("area_2081");
effect eResurrection = EffectResurrection();
if (GetIsDead(oLeader))
{
ApplyEffectToObject(DURATION_TYPE_INSTANT,eResurrection,oLeader);
}
AssignCommand(oLeader,SpeakString("Im oLeader"));
//this makes sure that oLeader is not dead or a summoned or dominated
//creature.
//while ((GetIsDead(oLeader))||
// (GetAssociateType(oLeader)!=ASSOCIATE_TYPE_NONE))
// {
// oLeader=GetNextFactionMember(oKiller,FALSE);;
// }
//ExecuteScript("ga_remove_aoe",oSelf);
DelayCommand(2.6,RemoveAllEffects(oLeader,TRUE));
DelayCommand(2.7,AssignCommand(oLeader,ClearAllActions(TRUE)));
DelayCommand(3.0,AssignCommand(oLeader,ActionStartConversation(oLeader,sConversation, FALSE,FALSE,TRUE)));
}
Question about GetFactionLeader()
Débuté par
M. Rieder
, janv. 01 2012 07:23
#1
Posté 01 janvier 2012 - 07:23
#2
Posté 01 janvier 2012 - 07:28
I think I fixed it by defining oLeader as:
object oLeader = GetOwnedCharacter(GetFactionLeader(GetLastKiller()));
But if anyone wants to comment, I would really like to hear what you have to say. I like to be as precise as possible in my object identifications.
object oLeader = GetOwnedCharacter(GetFactionLeader(GetLastKiller()));
But if anyone wants to comment, I would really like to hear what you have to say. I like to be as precise as possible in my object identifications.
#3
Posté 01 janvier 2012 - 11:35
here's some test code i wrote for returning
- GetFirstPC()
- GetFirstPC(FALSE)
- GetIsPC()
- GetIsOwnedByPlayer()
- GetIsPlayerCreated()
- GetIsRosterMember()
- GetFactionLeader()
- GetOwnedCharacter()
- GetControlledCharacter()
( compile it under whatever script title you want, and RunScript it while possessing various PCs, Companions, Familiars; it's purely informative and spits out nothing but debug text )
But recently I've found SetOwnersControlledCompanion(object oTarget) is very useful, as long as oTarget is a known given. Unfortunately I don't presently have the means to run the script under TrueMP conditions .... but i'm sure it could/would clear up a lot of ambiguity, there (esp. with tweaking).
in my experience, GetFactionLeader() returns the controlled character, yes - in SP ( in MP it very probably returns .. the Faction Leader! )
- GetFirstPC()
- GetFirstPC(FALSE)
- GetIsPC()
- GetIsOwnedByPlayer()
- GetIsPlayerCreated()
- GetIsRosterMember()
- GetFactionLeader()
- GetOwnedCharacter()
- GetControlledCharacter()
( compile it under whatever script title you want, and RunScript it while possessing various PCs, Companions, Familiars; it's purely informative and spits out nothing but debug text )
But recently I've found SetOwnersControlledCompanion(object oTarget) is very useful, as long as oTarget is a known given. Unfortunately I don't presently have the means to run the script under TrueMP conditions .... but i'm sure it could/would clear up a lot of ambiguity, there (esp. with tweaking).
in my experience, GetFactionLeader() returns the controlled character, yes - in SP ( in MP it very probably returns .. the Faction Leader! )
#4
Posté 02 janvier 2012 - 12:33
Good point about the difference between SP and MP environments. I have never played much MP and I wonder, in MP can you posess non PC companions? I wonder how that is handled?
#5
Posté 02 janvier 2012 - 03:37
idk, Matt :\\
maybe a friendly neighborhood PW-admin can add some insights,
Edit: like, if a companion or henchman gets added to group, does it get assigned to a/the particular player who picked on it?
maybe a friendly neighborhood PW-admin can add some insights,
Edit: like, if a companion or henchman gets added to group, does it get assigned to a/the particular player who picked on it?
Modifié par kevL, 02 janvier 2012 - 03:40 .
#6
Posté 02 janvier 2012 - 11:37
Yeah... I was hoping for some pain-insight on this problem. I just changed 87 scripts, and I hope I was right!
#7
Posté 21 juillet 2012 - 02:40
A note since I'm currently doing something with GetFactionLeader. GetFactionLeader seems to be somewhat broken for npcs: There is no leader for npc factions by default, the factionleader must be assigned. So a script that uses GetFactionLeader without a faction leader being set somewhere will not work and not give an error message (it would return an object invalid, but a script will compile and not give any error indicator).
Modifié par kamal_, 21 juillet 2012 - 04:47 .
#8
Posté 21 juillet 2012 - 04:33
I'm curious because the function is used several places to determine whether or not a critter is PC faction, so I'm also wondering if it's really possible to assign a Leader to an NPC faction .... for example,
the Companion & Monster AI uses stuff like this:
and
the Companion & Monster AI uses stuff like this:
int iAmMonster = !GetIsObjectValid(GetFactionLeader(OBJECT_SELF));
and
int GetIsPCGroup(object oAssociate = OBJECT_SELF)
{
return GetIsObjectValid(GetFactionLeader(oAssociate));
}
#9
Posté 21 juillet 2012 - 04:46
SetFactionLeader will make the creature that runs it the leader of it's faction. At least that's what it's described as doing. I didn't need to use that function for my scripting. So it would seem you could make a leader for a nonPC faction, at least based on that description.kevL wrote...
I'm curious because the function is used several places to determine whether or not a critter is PC faction, so I'm also wondering if it's really possible to assign a Leader to an NPC faction .... for example,
the Companion & Monster AI uses stuff like this:int iAmMonster = !GetIsObjectValid(GetFactionLeader(OBJECT_SELF));
andint GetIsPCGroup(object oAssociate = OBJECT_SELF) { return GetIsObjectValid(GetFactionLeader(oAssociate)); }
I wound up setting faction to a faction pig for my faction instead of setting to factionleader, since I'm using faction pigs for faction references anyway.
#10
Posté 21 juillet 2012 - 04:47
thanks for the headsup.





Retour en haut






