PDA

View Full Version : Spawning player?


zbyl2
03-12-2009, 09:36 AM
Some details: I want to have Mandalore fights alone with Mandalorians on Dantooine. To do it I turned player into Mandalore after conversation. Problem is, player should be still around when Mandalore fights enemy (staying there like normal NPC and just observing fight) How can I spawn player in module? (with all his equipment etc.)
For now, I've got this:
// Prototypes
void sub1();
void sub2();
void sub3();

void sub1() {
SwitchPlayerCharacter(2);
}

void sub2() {
int int1 = 0;
int1 = 0;
while ((int1 < 12)) {
if (IsNPCPartyMember(int1)) {
RemovePartyMember(int1);
}
(int1++);
}
}

void sub3() {
object oFakePC = SpawnAvailableNPC(NPC_PLAYER,Location(Vector(311.6 9995,106.55496,1.94050),90.0f));
ChangeToStandardFaction(oFakePC, STANDARD_FACTION_NEUTRAL);
SetGlobalFadeIn(1.0,1.0);
}

void main() {
SetGlobalFadeOut(0.0,0.0);
sub2();
DelayCommand(0.3, sub1());
DelayCommand(0.5,sub3());
}
Everything works perfectly except part when player should be spawned.


Help?

swfan28
03-12-2009, 10:56 AM
I don't think the PC can be removed from the party except by turning him into an NPC. This means that in order to have him stand around passive you'll need to spawn a neutral character (a commoner) and use a disguise effect to make him look like the PC. This can be done like this:
effect PCdisguise = EffectDisguise(GetAppearanceType(GetFirstPC()));
ApplyEffectToObject(DURATION_TYPE_PERMANENT, PCdisguise, oFakePC, 0.0);Duplicating his items will be more difficult. You'll probably need to get the PC's visible items (weapons, armor and headgear) and equip them on the FakePC during a fade to black before turning the PC into Mandalore. Also the scripting of the Korriban Tomb vision where the "partymembers" attack the Exile may give some insight into duplicating the equipped items.

zbyl2
03-12-2009, 11:05 AM
Yeah, well, I know how spawn player like NPC. I did it that way before:
void SetMandalore();

void SetMandalore() {
SwitchPlayerCharacter(2);
SetGlobalFadeIn(0.0,1.0);
ChangeToStandardFaction(GetObjectByTag("mand_lead"), STANDARD_FACTION_HOSTILE_1);
AssignCommand(GetObjectByTag("mand_lead"),ActionAttack(GetFirstPC()));
}


void main() {

SetGlobalFadeOut(0.0,0.0);
object oFakePC = CreateObject(OBJECT_TYPE_CREATURE,"fake_pc605",Location(Vector(311.69995,106.55496,1.94050),90.0 f));
SetGoodEvilValue(oFakePC, GetGoodEvilValue(GetFirstPC()));
DuplicateHeadAppearance(oFakePC,GetFirstPC());


//Remove ALL Party Members
int int1 = 0;
int1 = 0;
while ((int1 < 12)) {
if (IsNPCPartyMember(int1)) {
RemovePartyMember(int1);
}
(int1++);
}


//Turn PC into Mandalore
DelayCommand(1.0,SetMandalore());
}

Problem is inventory - I have NO idea how to copy it on NPC :/

swfan28
03-12-2009, 11:53 AM
zbyl2 wrote:
Problem is inventory - I have NO idea how to copy it on NPC :/Hopefully this will do the trick.
object oItem = GetItemInSlot(INVENTORY_SLOT_BODY, GetFirstPC());
if (GetIsObjectValid(oItem)) {
GiveItem(oItem, oFakePC);
AssignCommand(oFakePC, ActionEquipItem(oItem, INVENTORY_SLOT_BODY, TRUE));
}and the same for other slots. Since the same thing will be done here multiple times with different parameters, you should write this as a function that is called from the main script. The script would be easier to read and you could use it again with different parameters to reset the party after the fight.

If this doesn't work you could try DelayCommand with about 1 second delay for equipping the items. It might prove to be more reliable.

zbyl2
03-12-2009, 12:04 PM
Man - you're awesome. It works perfectly :)