lfnetwork.com mark read register faq members calendar

Thread: OnEnter script question
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 06-23-2009, 09:21 AM   #1
R2-X2
Junior Member
 
R2-X2's Avatar
 
Join Date: Dec 2008
Location: Above Lehon
Posts: 352
Current Game: KotOR again. F*** yeah.
OnEnter script question

And again a scripting question:

How two make scripts that check if an NPC already exists in a module, check a GlobalNumber (or two) and if the NPC doesn't exist and the GlobalN. is right, spawns an NPC? And, is there a way to do it with multiple NPCs in one script?



Beep.
R2-X2 is offline   you may: quote & reply,
Old 06-23-2009, 01:38 PM   #2
zbyl2
Junior Member
 
zbyl2's Avatar
 
Join Date: May 2008
Location: a galaxy far far away...
Posts: 320
Contest winner - Modding Veteran Modder 
Add this to your OnEnter script, it will check if NPC was already spawned in module and if globals were set:
Code:
      if(GetGlobalNumber("NAME_OF_YOUR_GLOBAL") == X // Global number equals X
        && GetGlobalNumber("NAME_OF_SECOND_GLOBAL") == X // cause you asked for two globals ;)
        && !GetIsObjectValid(GetObjectByTag("TAG_OF_YOUR_NPC"))) { // only if NPC doesn't exist in module
            
               CreateObject(OBJECT_TYPE_CREATURE, "YOUR_NPC", Location(Vector(0.0, 0.0, 0.0), 0.0f));    //remember to change tag of your NPC and coordinates
          }


Hope that helps : )

Last edited by zbyl2; 06-23-2009 at 01:43 PM.
zbyl2 is offline   you may: quote & reply,
Old 06-23-2009, 02:28 PM   #3
R2-X2
Junior Member
 
R2-X2's Avatar
 
Join Date: Dec 2008
Location: Above Lehon
Posts: 352
Current Game: KotOR again. F*** yeah.
Yep that helps. Thank you.
If I want to use just one of these conditions, I just would have to put an "//" (without the quotes, sure) in front of them, or, if I don't use the first one change the "&&" to an "if", right?



Beep.
R2-X2 is offline   you may: quote & reply,
Old 06-23-2009, 02:40 PM   #4
zbyl2
Junior Member
 
zbyl2's Avatar
 
Join Date: May 2008
Location: a galaxy far far away...
Posts: 320
Contest winner - Modding Veteran Modder 
You may completely remove line you don't want. And yeah, if you don't want first one you'll need to replace && with "if(" later.
zbyl2 is offline   you may: quote & reply,
Old 06-23-2009, 03:11 PM   #5
R2-X2
Junior Member
 
R2-X2's Avatar
 
Join Date: Dec 2008
Location: Above Lehon
Posts: 352
Current Game: KotOR again. F*** yeah.
Ok, everything cleared, thanks!



Beep.
R2-X2 is offline   you may: quote & reply,
Old 06-25-2009, 09:24 AM   #6
R2-X2
Junior Member
 
R2-X2's Avatar
 
Join Date: Dec 2008
Location: Above Lehon
Posts: 352
Current Game: KotOR again. F*** yeah.
Your script doesn't work. I always get a syntax error at "if"



Beep.
R2-X2 is offline   you may: quote & reply,
Old 06-25-2009, 10:35 AM   #7
zbyl2
Junior Member
 
zbyl2's Avatar
 
Join Date: May 2008
Location: a galaxy far far away...
Posts: 320
Contest winner - Modding Veteran Modder 
I can compile it.
Did you add "void main() {" at the very beginning? Like this one:
Code:
void main(){
      if(GetGlobalNumber("NAME_OF_YOUR_GLOBAL") == X 
        && GetGlobalNumber("NAME_OF_SECOND_GLOBAL") == X 
        && !GetIsObjectValid(GetObjectByTag("TAG_OF_YOUR_NPC"))) { 
            
               CreateObject(OBJECT_TYPE_CREATURE, "YOUR_NPC", Location(Vector(0.0, 0.0, 0.0), 0.0f));  
          }
}
It's always needed to add void main() at beginning of all your scripts (except they're conditional scripts for conversation, but well), otherwise you won't compile anything.
zbyl2 is offline   you may: quote & reply,
Old 06-27-2009, 06:19 AM   #8
R2-X2
Junior Member
 
R2-X2's Avatar
 
Join Date: Dec 2008
Location: Above Lehon
Posts: 352
Current Game: KotOR again. F*** yeah.
ouch. I always forget it.
Everything should be cleared now.



Beep.
R2-X2 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 > OnEnter script question

Tags
onenter, scripting

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:53 AM.

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