lfnetwork.com mark read register faq members calendar

Thread: Problem Setting Custom NPC as Player Character
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 08-05-2013, 09:13 PM   #1
Malxados
Rookie
 
Malxados's Avatar
 
Join Date: Feb 2009
Location: Mandalore
Posts: 221
Current Game: Warframe, SC Blacklist, KOTOR1
Problem Setting Custom NPC as Player Character

So, I'm trying to make a script that removes all party members (both from the current party and from being select-able in the party selection screen), adds a custom version of Darth Nihilus to the party, and makes him the PC (rather than the exile); it's this last bit that's been giving me trouble now. Here's the script (minus some commented-out sections):

Code:
//nihilus_switch

#include "k_inc_debug"


void main(){

  int i;
  object oPC = GetFirstPC();

  for (i = 0; i < 12; i++){
      RemoveNPCFromPartyToBase(i);
      RemoveAvailableNPC(i);    
  }


  AddAvailableNPCByTemplate(5, "p_darthnihilus");
  object oNih = SpawnAvailableNPC(5, GetLocation(GetFirstPC()));
  AddPartyMember(5, oNih);
  SwitchPlayerCharacter(5);

}
If I take out the "SwitchPlayerCharacter(5);" line, the rest seems to work fine- I get the custom Nihilus in my party, and everyone else is gone (and I sometimes get random items or credits, not sure why that is). However, the game freezes when I try to make him the PC; is there a reason scripting-wise why this isn't working?

Thanks


"But God demonstrates His own love toward us, in that while we were still sinners, Christ died for us." (Romans 5:8, NKJV)
"For the wages of sin is death, but the gift of God is eternal life in Christ Jesus our Lord." (Romans 6:23, NKJV)

Ask me about my sig!

Bao-Dur: I'll take the one who was stupid enough to threaten us instead of shoot us when he had the chance.

k_inc_force bothers me.
Malxados is offline   you may: quote & reply,
Old 08-05-2013, 09:32 PM   #2
JCarter426
Senior Member
 
JCarter426's Avatar
 
Join Date: Feb 2008
Location: Look to your left.
Posts: 1,635
No, it's just a problem with the SwitchPlayerCharacter function. I believe I solved it by adding NoClicksFor(1.5) immediately preceding SwitchPlayerCharacter.


JCarter426 is offline   you may: quote & reply,
Old 08-05-2013, 09:41 PM   #3
Malxados
Rookie
 
Malxados's Avatar
 
Join Date: Feb 2009
Location: Mandalore
Posts: 221
Current Game: Warframe, SC Blacklist, KOTOR1
Quote:
Originally Posted by JCarter426 View Post
No, it's just a problem with the SwitchPlayerCharacter function. I believe I solved it by adding NoClicksFor(1.5) immediately preceding SwitchPlayerCharacter.
That didn't seem to help at all =( And this is for TSL, although you probably assumed that


"But God demonstrates His own love toward us, in that while we were still sinners, Christ died for us." (Romans 5:8, NKJV)
"For the wages of sin is death, but the gift of God is eternal life in Christ Jesus our Lord." (Romans 6:23, NKJV)

Ask me about my sig!

Bao-Dur: I'll take the one who was stupid enough to threaten us instead of shoot us when he had the chance.

k_inc_force bothers me.
Malxados is offline   you may: quote & reply,
Old 08-05-2013, 10:17 PM   #4
JCarter426
Senior Member
 
JCarter426's Avatar
 
Join Date: Feb 2008
Location: Look to your left.
Posts: 1,635
Hmm... you should probably also put some time in between Nihilus being spawned and the switch. Also I don't think the NPC should be in the active party... in looks like my script explicitly removes them if so.

Here's the whole source code for my script, which does work and doesn't crash the game, as far as I can tell:
Show spoiler

The relevant parts are cases 4 and 8, as well as the subroutines they include, particularly SwitchPC.


JCarter426 is offline   you may: quote & reply,
Old 08-05-2013, 11:29 PM   #5
Malxados
Rookie
 
Malxados's Avatar
 
Join Date: Feb 2009
Location: Mandalore
Posts: 221
Current Game: Warframe, SC Blacklist, KOTOR1
Quote:
Originally Posted by JCarter426 View Post
Hmm... you should probably also put some time in between Nihilus being spawned and the switch. Also I don't think the NPC should be in the active party... in looks like my script explicitly removes them if so.

Here's the whole source code for my script, which does work and doesn't crash the game, as far as I can tell:
Show spoiler

The relevant parts are cases 4 and 8, as well as the subroutines they include, particularly SwitchPC.
Good grief, that is quite the script haha; after looking through it (and your post) I changed my script to this, but it still freezes the game up:

Show spoiler


"But God demonstrates His own love toward us, in that while we were still sinners, Christ died for us." (Romans 5:8, NKJV)
"For the wages of sin is death, but the gift of God is eternal life in Christ Jesus our Lord." (Romans 6:23, NKJV)

Ask me about my sig!

Bao-Dur: I'll take the one who was stupid enough to threaten us instead of shoot us when he had the chance.

k_inc_force bothers me.
Malxados is offline   you may: quote & reply,
Old 08-06-2013, 12:34 AM   #6
JCarter426
Senior Member
 
JCarter426's Avatar
 
Join Date: Feb 2008
Location: Look to your left.
Posts: 1,635
Hmm... perhaps you should try SpawnAvailableNPC instead of CreateObject.


JCarter426 is offline   you may: quote & reply,
Old 08-06-2013, 01:57 AM   #7
Malxados
Rookie
 
Malxados's Avatar
 
Join Date: Feb 2009
Location: Mandalore
Posts: 221
Current Game: Warframe, SC Blacklist, KOTOR1
Quote:
Originally Posted by JCarter426 View Post
Hmm... perhaps you should try SpawnAvailableNPC instead of CreateObject.
I may have confused myself into thinking that SpawnAvailableNPC wouldn't work in this situation, but my logic seems to have been faulty hah; so I switched it out, but it still freezes.

I tried messing around with the .utc file some more (matching it up more with what the other npc's templates look like), but with no success yet.


"But God demonstrates His own love toward us, in that while we were still sinners, Christ died for us." (Romans 5:8, NKJV)
"For the wages of sin is death, but the gift of God is eternal life in Christ Jesus our Lord." (Romans 6:23, NKJV)

Ask me about my sig!

Bao-Dur: I'll take the one who was stupid enough to threaten us instead of shoot us when he had the chance.

k_inc_force bothers me.
Malxados is offline   you may: quote & reply,
Old 08-06-2013, 03:29 AM   #8
JCarter426
Senior Member
 
JCarter426's Avatar
 
Join Date: Feb 2008
Location: Look to your left.
Posts: 1,635
Hmm... let me see if I can nail down the essential parts of my script. I'm actually having trouble reading my own script... oops.

But I think this works:
Code:
void SwitchPC() {

AssignCommand(GetFirstPC(), ClearAllActions());
SetNPCSelectability(5, 1);
ActionWait(0.5);
SpawnAvailableNPC(5, GetLocation(GetFirstPC()));
RemovePartyMember(5);
SwitchPlayerCharacter(5);
SetPartyLeader(5);

}

void main() {

NoClicksFor(1.5);
SetGlobalFadeIn(2.0, 1.0, 0.0, 0.0, 0.0);
AddAvailableNPCByTemplate(5, "p_darthnihilus");
AssignCommand(GetFirstPC(), ClearAllActions());
DelayCommand(0.2, SwitchPC());

}
I think it's just picky about the timing.


JCarter426 is offline   you may: quote & reply,
Old 08-06-2013, 11:55 AM   #9
Fair Strides 2
Witty Programmer
 
Fair Strides 2's Avatar
 
Join Date: Jan 2012
Location: Oregon, United States
Posts: 557
Current Game: Master of Orion 2
Helpful! 
Quote:
Originally Posted by JCarter426 View Post
Hmm... let me see if I can nail down the essential parts of my script. I'm actually having trouble reading my own script... oops.

But I think this works:
Show spoiler
I think it's just picky about the timing.
Well, here's the OnEnter script for the Freedon Nadd Tomb Outside...
Show spoiler


Hope it helps. I don't see the game spawning the party leader first, so it might be automatic?

I forget which armband mod it was(Either the Workbox or Mr Defender's), but it had the option of changing the partly leader/player character and it would always freeze...


All of my mods are available on Deadlystream.

Always remember modders: "Quality= Effort*Time"

KSE 3.3.4 is LIVE!!! Check it out here.

Check out WalkSwitch, the Walkmesh-changing tool!
Fair Strides 2 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 > Problem Setting Custom NPC as Player Character

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 05:05 PM.

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