Miltiades Posted April 6, 2006 Share Posted April 6, 2006 I'm looking for the Onenter script for Manaan West Central (m26ac). There was a tutorial here how to spawn items and NCPs. According to the tutorial, I had to look at the .are file if I was unsure. But I can't make anything out of it, because there's no script that has "enter" in it's name. Does someone know what the Onenter script is? Link to comment Share on other sites More sharing options...
Tupac Amaru Posted April 6, 2006 Share Posted April 6, 2006 When you open the .are in a GFF Editor, the name of the script can be found in the 'OnEnter' field. For this module, it is k_pman_locked03. Link to comment Share on other sites More sharing options...
Miltiades Posted April 6, 2006 Author Share Posted April 6, 2006 Aah, that's how I have to do it. Thank you. Link to comment Share on other sites More sharing options...
Miltiades Posted April 7, 2006 Author Share Posted April 7, 2006 I'm having another problem. I want to spawn multiple NPCs into a module. I have asked this before. Tk102 gave me this script: void main() { object oEntering = GetEnteringObject(); object oPC=GetFirstPC(); object oNPCA; object oNPCB1; object oNPCB2; //use whereami armband to get good location coordinates location locSpawn=Location(Vector(43.41,-0.28,9.66), 0.0); if (GetIsPC(oEntering)) { //check if the soldier A is already spawned if (!GetIsObjectValid(GetObjectByTag("soldierAtag"))) { oNPCA=CreateObject(OBJECT_TYPE_CREATURE, "soldierAtemp", locSpawn); // since soldier A should spawn with the soldier B, we can assume // that they have also not yet been spawned. Spawn them now. oNPCB1=CreateObject(OBJECT_TYPE_CREATURE, "soldierBtemp", locSpawn); oNPCB2=CreateObject(OBJECT_TYPE_CREATURE, "soldierBtemp", locSpawn); // here you can script actions for the soldiers using their // object variables: oNPCA, oNPCB1, oNPCB2 // example: // AssignCommand(oNPCA,ActionMoveToObject(oPC)); // AssignCommand(oNPCB1,ActionMoveToObject(oPC)); // AssignCommand(oNPCB2,ActionMoveToObject(oPC)); // AssignCommand(oNPCB1,ActionMoveToObject(oPC)); // AssignCommand(oNPCA, ActionDoCommand(ActionStartConversation(oPC))); } } ExecuteScript("old231_enter", OBJECT_SELF); } It worked well. I didn't have any problems with it, because my 3 NPCs that i wanted to spawn then, were in group, standing next to each other. But now I want to spawn multiple NPCs, all with their own coordinates, into a module. And I can't seem to do it with this script. How do I do it? Link to comment Share on other sites More sharing options...
Patriarch Posted April 7, 2006 Share Posted April 7, 2006 Just define the different locations.....for locSpawn location locSpawn1=Location(Vector(43.41,-0.28,9.66), 0.0); location locSpawn2=Location(Vector(43.41,-0.28,20.66), 0.0); location locSpawn3=Location(Vector(43.41,-0.28,15.66), 0.0); Link to comment Share on other sites More sharing options...
Miltiades Posted April 7, 2006 Author Share Posted April 7, 2006 Doesn't work. Only the first NPC spawns. I don't think this has anything to do with it, but now it's for Kotor, and the previous time it was for TSL. Anyway, I tried to edit it a bit: if (!GetIsObjectValid(GetObjectByTag("soldierAtag"))) { oNPCA=CreateObject(OBJECT_TYPE_CREATURE, "soldierAtemp", locSpawn); I copied this bit two times, for NPC2 and 3. And that didn't work either. Link to comment Share on other sites More sharing options...
Patriarch Posted April 7, 2006 Share Posted April 7, 2006 Yeah But you HAVE to define a different locations and objects each time....ie "locSpawn1" is the first location and the first spawnin. vector vPosition=Vector(561.38702, 54.35939, 7.71483); location lWhereToSpawn=Location(vPosition,90.0); CreateObject(OBJECT_TYPE_CREATURE,"my_resref",lWhereToSpawn); for the second vector vPosition1=Vector(561.38702, 54.35939, 7.71483); location lWhereToSpawn1=Location(vPosition1,90.0); CreateObject(OBJECT_TYPE_CREATURE,"my_resref2",lWhereToSpawn1); Link to comment Share on other sites More sharing options...
Miltiades Posted April 7, 2006 Author Share Posted April 7, 2006 Where do I put this then in the script? And do I have to change something else in this beside the coordinates and the resref? Link to comment Share on other sites More sharing options...
Patriarch Posted April 7, 2006 Share Posted April 7, 2006 No the resref could be the the same if it is the same UTC you want to use.... Coordinates needs to differrent as you suggest. there is a handy script called something with fab_spawn that OE uses....could'nt really find as of now...sorry. My method is to alter the original script making an entry before all the original stuff....then in my own script making a conditional start.....I like this because then I can use booleans and globals to control my own script.... Bellow is a copy of the Ebon Hawk entry script with an additional script: void main() { ExecuteScript("my_script", OBJECT_SELF); if ((GetGlobalNumber("003EBO_Hatch") == 1)) { if ((!GetIsObjectValid(GetObjectByTag("EboHiddenContainer", 0)))) { CreateObject(64, "inveb001", GetLocation(GetWaypointByTag("WP_HIDDEN_CONTAINER")), 0); } } } Then my script would be like this void main() { int nGlobal = GetGlobalNumber("hell_spawn"); if ((nGlobal == 0)){ vector vPosition=Vector(561.38702, 54.35939, 7.71483); location lWhereToSpawn=Location(vPosition,90.0); //i should set a conditional here if i dont use a global or a boolean CreateObject(OBJECT_TYPE_CREATURE,"myresref",lWhereToSpawn); SetGlobalNumber("hell_spawn", 1); } } Then create a a new entry (number) i globalcat.2da called hell_spawn then try it out also you use the GetIsObjectValid....be carefull with that....I think that is the your actual problems.... if you forget about that part in your script then spawn all your NPCs, then afterwords set a globalnumber....Then you can make sure it will not happen the next time you enter the area....this is how OE does it. Link to comment Share on other sites More sharing options...
Miltiades Posted April 7, 2006 Author Share Posted April 7, 2006 So do I use the script of Tk102, or another one? I'm getting confused here :s I'm sorry if I'm bothering you with this, but I'm not smart when it comes to scripting and such. Link to comment Share on other sites More sharing options...
LiquidZoo Posted April 7, 2006 Share Posted April 7, 2006 Something like this //use whereami armband to get good location coordinates location locSpawn=Location(Vector(43.41,-0.28,9.66), 0.0); if (GetIsPC(oEntering)) { //check if the soldier A is already spawned if (!GetIsObjectValid(GetObjectByTag("soldierAtag"))) { oNPCA=CreateObject(OBJECT_TYPE_CREATURE, "soldierAtemp", locSpawn); // since soldier A should spawn with the soldier B, we can assume // that they have also not yet been spawned. Spawn them now. location locSpawn=Location(Vector(new coords), 0.0); oNPCB1=CreateObject(OBJECT_TYPE_CREATURE, "soldierBtemp", locSpawn); location locSpawn=Location(Vector(more new coords), 0.0); oNPCB2=CreateObject(OBJECT_TYPE_CREATURE, "soldierBtemp", locSpawn); // here you can script actions for the soldiers using their // object variables: oNPCA, oNPCB1, oNPCB2 // example: // AssignCommand(oNPCA,ActionMoveToObject(oPC)); // AssignCommand(oNPCB1,ActionMoveToObject(oPC)); // AssignCommand(oNPCB2,ActionMoveToObject(oPC)); // AssignCommand(oNPCB1,ActionMoveToObject(oPC)); // AssignCommand(oNPCA, ActionDoCommand(ActionStartConversation(oPC))); } } ExecuteScript("old231_enter", OBJECT_SELF); } What was listed above is how to use the global variables. Link to comment Share on other sites More sharing options...
Miltiades Posted April 7, 2006 Author Share Posted April 7, 2006 While trying to compile this, I got this error: Variable "LocSpawn" defined multiple times in the same scope. What's wrong? Link to comment Share on other sites More sharing options...
LiquidZoo Posted April 7, 2006 Share Posted April 7, 2006 Try using locSpawn2 and locSpawn3 for the second and third NPC's Link to comment Share on other sites More sharing options...
Miltiades Posted April 7, 2006 Author Share Posted April 7, 2006 Now compiling works, but the NPCs still don't spawn except for the first one. :s Link to comment Share on other sites More sharing options...
Patriarch Posted April 8, 2006 Share Posted April 8, 2006 Hello I am trying to tell you, that the scrip that you suggest and the on that liquid suggests will run each time you enter the module. If you enter that module again the the same operation will repeat in other words. This of course is ok if you can only enter that module once in each game, but if you imagine yourself entering the area, leave and come back then you will see the spawning again. (assuming that you've killed them or something) Therefore I suggest that you use a global variable as shown in my script above. this has to be made in the globalcat.2da void main() { int nGlobal = GetGlobalNumber("hell_spawn"); if ((nGlobal == 0)){ vector vPosition=Vector(561.38702, 54.35939, 7.71483); location lWhereToSpawn=Location(vPosition,90.0); CreateObject(OBJECT_TYPE_CREATURE,"myresref",lWhereToSpawn); vector vPosition1=Vector(561.38702, 54.35939, 7.71483); location lWhereToSpawn1=Location(vPosition1,90.0); CreateObject(OBJECT_TYPE_CREATURE,"myresref1",lWhereToSpawn1); vector vPosition2=Vector(561.38702, 54.35939, 7.71483); location lWhereToSpawn2=Location(vPosition2,90.0); CreateObject(OBJECT_TYPE_CREATURE,"myresref1",lWhereToSpawn2); // Having created all our NPC's we now have to make sure that this operation // does not happen again. We set the Global number to "1" because above //we stated that this script should only run if the global number is "0". SetGlobalNumber("hell_spawn", 1); //put some other stuff here for instance } } Link to comment Share on other sites More sharing options...
Pavlos Posted April 8, 2006 Share Posted April 8, 2006 Hello I am trying to tell you, that the scrip that you suggest and the on that liquid suggests will run each time you enter the module. If you enter that module again the the same operation will repeat in other words. This of course is ok if you can only enter that module once in each game, but if you imagine yourself entering the area, leave and come back then you will see the spawning again. (assuming that you've killed them or something) Therefore I suggest that you use a global variable as shown in my script above. this has to be made in the globalcat.2da I think using a global number is going a bit over the top to tell you the truth. You would be better off using a local boolean... provided you only use numbers between 110 and 159 - which appear to be unused. Really there is no reason for any of these scripts (So far as I can tell). void main() { if (GetLoadFromSaveGame()) { ExecuteScript("old_onenter", GetModule()); // So that if you are starting the module up from a saved game it doesn't run this script! } object oEntering = GetEnteringObject(); if ((oEntering == GetFirstPC())) { if (!GetIsObjectValid(GetObjectByTag("my_NPCtag"))) { // Insert one of your NPC tags here because // unless you plan on killing them if one is there then all should be there. vector MyVec = Vector(50.3, 67.1, 3.0); //Use the whereami cheat to get these. object oNPC1; object oNPC2; object oNPC3; // We have already checked to see if the object is valid. oNPC1 = CreateObject(OBJECT_TYPE_CREATURE, "myNPC_resref1", Location(MyVec, r)); // Replace "r" with the orientation in degrees, please. oNPC2 = CreateObject(OBJECT_TYPE_CREATURE, "myNPC_resref2", Location(MyVec, r)); oNPC3 = CreateObject(OBJECT_TYPE_CREATURE, "myNPC_resref3", Location(MyVec, r)); } } } We do not need multiple locations because the game will spawn them all around that point... Getting the orientation in KotOR I could be done in the following manner: void main() { object oPC = GetFirstPC(); float Orientation = GetFacing(oPC); string sOrient = FloatToString(Orientation, 10, 10); ActionStartConversation(oPC, "GetOrientation"); SetCustomToken(3000, sOrient); } Then attach that to an armband and in the dialogue file, as the first entry, you can put: Orientation = <CUSTOM3000>. I forget whether or not the <CUSTOM3000> needs a space between the 3000 and the custom, try both. Link to comment Share on other sites More sharing options...
Miltiades Posted April 8, 2006 Author Share Posted April 8, 2006 I've got a problems trying to compile your script, Pavlos. I get these errors three times: -Type mismatch in parameter 1 in call to "location" -Required argument missing in call to "CreateObject" Link to comment Share on other sites More sharing options...
Pavlos Posted April 8, 2006 Share Posted April 8, 2006 That is odd... it compiled fine for me. Are you sure you have changed "r" to your orientation? And I'm sorry, I misread your post above. You will need multiple locations if you are to spawn throughout the module. Link to comment Share on other sites More sharing options...
Miltiades Posted April 8, 2006 Author Share Posted April 8, 2006 Well, compiling worked, just made a little mistake. But yes, I want to spawn throughout the module, so I need multiple locations. How do I do that? Btw, is it weird that with every script I have tested (a few from this thread), my first NPC still spawns? Link to comment Share on other sites More sharing options...
Pavlos Posted April 8, 2006 Share Posted April 8, 2006 I wonder whether or not we are overloading the engine by spawning three NPCs at once... try using a separate script to spawn each of the NPCs, this may seem excessive but I don't see any reason for the scripts not to work. KotOR II seems to be a lot more forgiving when it comes to spawning things. void main() { if (GetLoadFromSaveGame()) { ExecuteScript("old_onenter", GetModule()); // So that if you are starting the module up from a saved game it doesn't run this script! } object oEntering = GetEnteringObject(); if ((oEntering == GetFirstPC())) { if (!GetIsObjectValid(GetObjectByTag("my_NPCtag"))) { // Insert one of your NPC tags here because // unless you plan on killing them if one is there then all should be there. vector MyVec1 = Vector(50.3, 67.1, 3.0); //Use the whereami cheat to get these. object oNPC1; // We have already checked to see if the object is valid. oNPC1 = CreateObject(OBJECT_TYPE_CREATURE, "myNPC_resref1", Location(MyVec1, r)); // Replace "r" with the orientation in degrees, please. DelayCommand(0.1, ExecuteScript("Spawn_other", GetModule())); } } } Just make the adjustments to this so you have three different scripts and link them all together... it seems excessive as I said but, I am at a loss as to why none of the others work. Link to comment Share on other sites More sharing options...
Miltiades Posted April 8, 2006 Author Share Posted April 8, 2006 How do I link them together? Edit: I can't make three seperate scripts, can I? Because they should all have the same name (name of the Onenter script of that module). Link to comment Share on other sites More sharing options...
Pavlos Posted April 8, 2006 Share Posted April 8, 2006 The first script is the name of the old OnEnter script. Then the others can be called anything you like! . Link them together with "ExecuteScript()" Link to comment Share on other sites More sharing options...
Miltiades Posted April 8, 2006 Author Share Posted April 8, 2006 Oh, so in the field where there's written "spawn_other", I have to put the names of the other spawn scripts? But before doing this, something strange's happening. I removed my spawn script and the old script from my override file, but my first NPC is still there!! How's this possible? I tried moving in and out of the module, but he stays. Link to comment Share on other sites More sharing options...
Pavlos Posted April 8, 2006 Share Posted April 8, 2006 Go to a save before you entered the module... this could have been the problem with the other scripts not working. Try putting one of the original scripts back in and loading from a save before you entered? Link to comment Share on other sites More sharing options...
Miltiades Posted April 8, 2006 Author Share Posted April 8, 2006 Oh boy... better not've saved :s You got any suggestions with what script of these forums I should begin? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.