lfnetwork.com mark read register faq members calendar

Thread: Spawning player?
Thread Tools Display Modes
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Old 03-12-2009, 09:36 AM   #1
zbyl2
Junior Member
 
zbyl2's Avatar
 
Join Date: May 2008
Location: a galaxy far far away...
Posts: 320
Contest winner - Modding Veteran Modder 
Spawning player/copying player's inventory to NPC?

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:
Code:
// 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.69995,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?

Last edited by zbyl2; 03-12-2009 at 11:26 AM.
zbyl2 is offline   you may: quote & reply,
Old 03-12-2009, 10:56 AM   #2
swfan28
Rookie
 
Join Date: May 2007
Location: Finland
Posts: 157
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:
Code:
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.
swfan28 is offline   you may: quote & reply,
Old 03-12-2009, 11:05 AM   #3
zbyl2
Junior Member
 
zbyl2's Avatar
 
Join Date: May 2008
Location: a galaxy far far away...
Posts: 320
Contest winner - Modding Veteran Modder 
Yeah, well, I know how spawn player like NPC. I did it that way before:
Code:
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.0f));
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 :/
zbyl2 is offline   you may: quote & reply,
Old 03-12-2009, 11:53 AM   #4
swfan28
Rookie
 
Join Date: May 2007
Location: Finland
Posts: 157
Quote:
zbyl2 wrote:
Problem is inventory - I have NO idea how to copy it on NPC :/
Hopefully this will do the trick.
Code:
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.

Last edited by swfan28; 03-12-2009 at 11:55 AM. Reason: typo
swfan28 is offline   you may: quote & reply,
Old 03-12-2009, 12:04 PM   #5
zbyl2
Junior Member
 
zbyl2's Avatar
 
Join Date: May 2008
Location: a galaxy far far away...
Posts: 320
Contest winner - Modding Veteran Modder 
Man - you're awesome. It works perfectly
zbyl2 is offline   you may: quote & reply,
Post a new thread. Add a reply to this thread. Indicate all threads in this forum as read. Subscribe to this forum. RSS feed: this forum RSS feed: all forums
Go Back   LucasForums > Network > Knights of the Old Republic > Editing / Modding > Holowan Laboratories > Spawning player?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:18 AM.

LFNetwork, LLC ©2002-2011 - All rights reserved.
Powered by vBulletin®
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.