sekan Posted June 21, 2007 Share Posted June 21, 2007 Well i am trying to spawn an npc and i asked Mindtwistah if he could spawn the npc with editing the git file ( i am not good a editing the git file) . He did it and he send it to me after he edit it and i maked a mod file of it. Then the npc is spawned but i cant talk to it. Still i have changed the Npc tag and which convertion name it should use when i start a convertion . Then i tried to make a script but then the npc didn't spawn. So plz help me. Here is the script i made void main() { location lDestination = Location(Vector(95.08, 86.55, 0.0), 0.0); object oNew = CreateObject(OBJECT_TYPE_CREATURE, "my npc tag", lDestination); } This is for k1 Link to comment Share on other sites More sharing options...
Master Zionosis Posted June 21, 2007 Share Posted June 21, 2007 You can spawn an NPC using this script: void main() { float x=-64.56150f; float y=-37.58458; float z=0.00000; float r=84.72446f; vector vecNPC=Vector(x,y,z); location locNPC=Location(vecNPC, r); object oNPC=GetObjectByTag("[color=red]TAG_OF_NPC[/color]"); object oTarget=CreateObject(OBJECT_TYPE_CREATURE,"[color=red]NAME_OF_NPC[/color]",locNPC); object oPC=GetFirstPC(); AssignCommand(oNPC,ActionMoveToObject(oPC)); AssignCommand(oNPC,ActionStartConversation(oPC,"[color=red]CONVERSATION_NAME[/color]")); } Do a whereami cheat to get the X, Y and Z coordinates for the script and replace NAME_OF_NPC with the file name of the NPC (without the .UTC extension) and replace TAG_OF_NPC with the tag of the NPC you want to spawn and replace CONVERSATION_NAME with the conversation name of the NPC without the .dlg extension. Hope this helps Link to comment Share on other sites More sharing options...
stoffe Posted June 21, 2007 Share Posted June 21, 2007 Well i am trying to spawn an npc and i asked Mindtwistah if he could spawn the npc with editing the git file ( i am not good a editing the git file) . He did it and he send it to me after he edit it and i maked a mod file of it. Then the npc is spawned but i cant talk to it. Still i have changed the Npc tag and which convertion name it should use when i start a convertion. Made sure you've set the name of the DLG file in the Conversation field in the UTC template, and make sure the name of the DLG file is valid (max 16 characters long, alphanumerical characters or underscore only). Also make make sure you have assigned the proper AI script in the OnDialog event slot in the UTC file (k_def_dialogue01 is the default one). Then i tried to make a script but then the npc didn't spawn. So plz help me. void main() { location lDestination = Location(Vector(95.08, 86.55, 0.0), 0.0); object oNew = CreateObject(OBJECT_TYPE_CREATURE, "my npc tag", lDestination); } There is nothing wrong with this script from what I can see, it should work fine to spawn an NPC if used properly. Make sure where it says "my npc tag" does not contain the tag, but the name of the UTC file you want to spawn the character from (without the UTC extension). The UTC file needs to be properly named (max 16 character, alphanumerical/underscore only) for it to work as well, and present either in the module file or in the override folder. Also make sure the X and Y coordinates are correct. Link to comment Share on other sites More sharing options...
sekan Posted June 25, 2007 Author Share Posted June 25, 2007 Both script works fine( i had made a mistake). But i have another question. How do i make a script that makes a new npc spawn after you have get a quest etc quest: Kill a guy at Korriban. Then he will spawn on korriban after you have get the quest. Link to comment Share on other sites More sharing options...
tk102 Posted June 26, 2007 Share Posted June 26, 2007 Since you got the previous spawning scripts to work, you can use them as templates for your Korriban spawning script. I think the question you are asking is "How should I make the script fire?" That's always a question that needs answering in every script-related mod. You say you're getting a quest right? Well typically you get quests through dialogs. If your dialog takes place in the same area, you can fire the spawn script directly from the dialog. If the dialog that grants the quest is in a different module, you'll have to set a flag that you can check later (eg. using a global variable, having a special item in your inventory, etc.) Then, in the area you want the character to spawn, you'll have to find some way of triggering your script (eg. attach to an existing dialog, use script injection in the area's OnEnter event, create a custom trigger, etc) Your script will perform the flag check and then decide whether or not to spawn the creature if the criteria is met. Link to comment Share on other sites More sharing options...
sekan Posted June 26, 2007 Author Share Posted June 26, 2007 Yes it's a quest. Hmm the special item could be a datapad but how do i create a trigger when i enter a module if my item is a datapad? Link to comment Share on other sites More sharing options...
tk102 Posted June 26, 2007 Share Posted June 26, 2007 Yes it's a quest. Hmm the special item could be a datapad but how do i create a trigger when i enter a module if my item is a datapad? If you wanted to use the datapad (we'll say its tag is "sekan_datapad") and you were not using Journal entries you could do something like: void main() { [color=palegreen]// First check to see if the entering object is the PC[/color] if (!GetIsPC(GetEnteringObject)) { return; } [color=palegreen]// Now check if the sekan_datapad exists[/color] if (!GetIsObjectValid( GetObjectByTag("sekan_datapad") ) { return; } [color=palegreen]// So far so good, now check to make sure we haven't spawned already // let's assume the NPC to spawn isn't going to get killed, so we can just // check for his presence[/color] if (!GetIsObjectValid( GetObjectByTag("sekan_npc") ) { CreateObject( OBJECT_TYPE_CREATURE, "sekan_npc_resref", GetLocation(GetEnteringObject) ); } } The cleaner way would be to use Journal entries because you can keep track of when its time to spawn more easily. If your quest was 'sekan_quest', you could do something like [color=palegreen]// First check to see if the entering object is the PC [/color] if (!GetIsPC(GetEnteringObject)) { return; } [color=palegreen] // Now see our quest is at the point where we want to spawn[/color] int nQuest = GetJournalEntry("sekan_quest"); [color=palegreen] // let's pretend that in your quest, step 20 is when you to spawn[/color] if (nQuest == 20) { CreateObject( OBJECT_TYPE_CREATURE, "sekan_npc_resref", GetLocation(GetEnteringObject) ); [color=palegreen] //now that we've spawned him, we'll change our quest number[/color] AddJournalQuestEntry("sekan_quest", 25); } } With this second code snippet, you don't even check for the presence of the datapad. That way if the PC decided he wanted to stash the datapad in one of the Ebon Hawk's plastisteel containers, he would still get the guy to spawn, whereas in the first script, he would not. The only thing is that you'll have to make sure when the datapad is first acquired, you set the Journal entry correctly (to 20 in this example). See also Darth333's Quest tutorial (Journal Entries) here. Link to comment Share on other sites More sharing options...
sekan Posted June 26, 2007 Author Share Posted June 26, 2007 What do i do if there are multiple npcs that needs to be spawned? Link to comment Share on other sites More sharing options...
sekan Posted June 27, 2007 Author Share Posted June 27, 2007 Anyway i have tried some times to get the script work but i just get errors. void main() { if (!GetIsPC(GetEnteringObject)) { return; } (!GetIsObjectValid( GetObjectByTag("hk47_bounties") ) { return; } if (!GetIsObjectValid( GetObjectByTag("Groska") ) { CreateObject( OBJECT_TYPE_CREATURE, "Groska", GetLocation(GetEnteringObject) ); } } What is wrong? I get errors in the seceond return and i dont know why. Please help. Link to comment Share on other sites More sharing options...
tk102 Posted June 27, 2007 Share Posted June 27, 2007 Fixed. void main() { if (!GetIsPC(GetEnteringObject())) { return; } if (!GetIsObjectValid( GetObjectByTag("hk47_bounties") )) { return; } if (!GetIsObjectValid( GetObjectByTag("Groska") )) { CreateObject( OBJECT_TYPE_CREATURE, "Groska", GetLocation(GetEnteringObject()) ); } } Link to comment Share on other sites More sharing options...
sekan Posted June 27, 2007 Author Share Posted June 27, 2007 Fixed. void main() { if (!GetIsPC(GetEnteringObject())) { return; } if (!GetIsObjectValid( GetObjectByTag("hk47_bounties") )) { return; } if (!GetIsObjectValid( GetObjectByTag("Groska") )) { CreateObject( OBJECT_TYPE_CREATURE, "Groska", GetLocation(GetEnteringObject()) ); } } Yeah it works but how do i set the cordinates in this script or must i make two diffrent scripts? Link to comment Share on other sites More sharing options...
tk102 Posted June 27, 2007 Share Posted June 27, 2007 Yeah it works but how do i set the cordinates in this script or must i make two diffrent scripts? Just like you did in your first post with lDestination. 1. Add a line at the beginning: [color=palegreen]location lDestination = Location(Vector(95.08, 86.55, 0.0), 0.0);[/color] 2. Replace the GetLocation(GetEnteringObject()) in the CreateObject function with lDestination. Link to comment Share on other sites More sharing options...
sekan Posted June 28, 2007 Author Share Posted June 28, 2007 Thanks tk102. Link to comment Share on other sites More sharing options...
sekan Posted June 29, 2007 Author Share Posted June 29, 2007 I have a little problem. I have killed the npc i spawned but he when i enter the sith academy again he's alive. How can i fix that? Link to comment Share on other sites More sharing options...
Mindtwistah Posted June 30, 2007 Share Posted June 30, 2007 TK:s post in this thread: http://lucasforums.com/showthread.php?t=143536 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.