Aller au contenu

Photo

Question about GetFactionLeader()


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
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)));
}

#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
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.

#3
kevL

kevL
  • Members
  • 4 070 messages
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! )

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
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
kevL

kevL
  • Members
  • 4 070 messages
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?

Modifié par kevL, 02 janvier 2012 - 03:40 .


#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Yeah... I was hoping for some pain-insight on this problem. I just changed 87 scripts, and I hope I was right!

#7
kamal_

kamal_
  • Members
  • 5 254 messages
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
kevL

kevL
  • Members
  • 4 070 messages
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));

and

int GetIsPCGroup(object oAssociate = OBJECT_SELF)
{
return GetIsObjectValid(GetFactionLeader(oAssociate));
}


#9
kamal_

kamal_
  • Members
  • 5 254 messages

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));

and

int GetIsPCGroup(object oAssociate = OBJECT_SELF)
{
return GetIsObjectValid(GetFactionLeader(oAssociate));
}

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.

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
kevL

kevL
  • Members
  • 4 070 messages
thanks for the headsup.