Locke4382 Posted April 26, 2005 Share Posted April 26, 2005 I downloaded some mods, such as one that gives a new batch of color crystals and one that gives a simple blue robe, but to use either of them you have to put in a cheat. I was wondering if I could make them appear randomly in certain containers. How would I go about doing that? I have all the editing software needed. On a particular side note, if I am merging two .2da files, do the row numbers matter, or does the new line just have to be somewhere on the list. Link to comment Share on other sites More sharing options...
Mav Posted April 26, 2005 Share Posted April 26, 2005 Originally posted by Locke4382 On a particular side note, if I am merging two .2da files, do the row numbers matter, or does the new line just have to be somewhere on the list. It depends which .2da you are merging, upcrystals.2da, itemcreate/mira.2da and upgrade.2da as well as some others, have row numbers that dont matter. However, appearence.2da, heads.2da, portraits.2da, baseitems.2da and spells.2da have row numbers that do matter so it all depends. Which are you merging? And as far as making custom items, appear at random like some of the games items I don't know how that works, sorry Link to comment Share on other sites More sharing options...
Locke4382 Posted April 26, 2005 Author Share Posted April 26, 2005 Heh, those first three you mentioned are the exact ones I had to merge. I think I did it right. Link to comment Share on other sites More sharing options...
Achilles Posted April 26, 2005 Share Posted April 26, 2005 I usually accomplish this by replaceing a default game item with the mod. For instance I replaced the Ubese Environmental Suit and the Armored Flight Suit (ugly models) with Drakonnen's armors. Now they appear randomly in-game, and I don't have tote around those ugly armors anymore Link to comment Share on other sites More sharing options...
ChAiNz.2da Posted April 26, 2005 Share Posted April 26, 2005 Originally posted by Achilles I usually accomplish this by replaceing a default game item with the mod. For instance I replaced the Ubese Environmental Suit and the Armored Flight Suit (ugly models) with Drakonnen's armors. Now they appear randomly in-game, and I don't have tote around those ugly armors anymore That's a pretty sweet trick there man! Did you just rename the mod items the same as to what you replaced, or did you do it via a script method? (seems renaming would be the easiest) I wonder if there's any other in-game "junk" that can be replaced in the same manner... Thanks for the tip Achilles! Link to comment Share on other sites More sharing options...
Achilles Posted April 26, 2005 Share Posted April 26, 2005 In the case of Drakonnens armors all I did was change the tag and templateresref to those of the game item that I was replacing. You can do it with just about any game item, and there's lots of fluff to work with. You have to be careful though...changing a bothan stun stick to a killblaster may also result in your weak opponents suddenly becoming impossible to beat Link to comment Share on other sites More sharing options...
stoffe Posted April 26, 2005 Share Posted April 26, 2005 Since I have a tendency for making overkill solutions to problems, I did a slight modification to the Random Loot system to allow it to use a "plugin script" that can be used to spawn specific items when random loot is generated by the game. It is triggered in most cases when random loot is generated. I currently use it to spawn a few custom made robes I've made as part of the game generated loot in containers and corpses. In order to avoid having to recompile the huge load of scripts that generates loot more than once, I made this a separate script from the random treasure include, so you only need to modify that single script to change what custom items will be spawned. If you are interested in trying it out, you can get the files here for now. The script called 000_custom_loot.nss is the one you modify and compile to add your own stuff to the random loot system. Put the scripts in the "compiled" folder into your Override folder. Those are the generic scripts that use the random loot system. They don't have to be changed in any way. I've put a whole bunch of comments in the 000_custom_loot.nss file so hopefully it will be understandable if you know a little bit of scripting. EDIT: Perhaps I should point out that if you want to try to use this, you should remove the call to the function ST_SpawnCustomRobes() in 000_custom_loot.nss since that's where I spawn my own custom robes. Since they are highly unlikely to be present in your game it would do nothing and result in no loot being spawned if the script triggers it. I only left it in there as an example. EDIT2: Also, remember that the Random loot often is generated when you first enter an area, since it is generated OnSpawn for creatures and in the first heartbeat of placeables/containers most of the time. EDIT3: Maybe I should also point out that if you are compiling your own custom OnSpawn scripts or such you'll need to use the "k_inc_treas_k2.nss" include file from the "Source" folder in the above archive, rather than the standard file coming with the game, if you want that creature/object to support the custom item spawn. Link to comment Share on other sites More sharing options...
Achilles Posted April 26, 2005 Share Posted April 26, 2005 So, when does your game come out? Excellent contribution as per usual. Thanks for download. Link to comment Share on other sites More sharing options...
tk102 Posted April 26, 2005 Share Posted April 26, 2005 Excellent! That's a very nice submission stoffe -mkb-. You just got me completely up to speed about how all the random treasure scripts work too. Link to comment Share on other sites More sharing options...
RedHawke Posted April 27, 2005 Share Posted April 27, 2005 Thanks as well stoffe, this rocks! I'll definately be fooling around with this one! Originally posted by Achilles So, when does your game come out? Agreed! Link to comment Share on other sites More sharing options...
lord_yig Posted April 27, 2005 Share Posted April 27, 2005 Originally posted by stoffe -mkb- EDIT2: Also, remember that the Random loot often is generated when you first enter an area, since it is generated OnSpawn for creatures and in the first heartbeat of placeables/containers most of the time. [/b]I'va always use this to my profit Saving just before entering areas where i know here is lots of containers like the small storage room in Koonda or the mandporian cache on Dxun... Your script is a great addition Stoffe ! Link to comment Share on other sites More sharing options...
ChAiNz.2da Posted April 27, 2005 Share Posted April 27, 2005 Originally posted by stoffe -mkb- Since I have a tendency for making overkill solutions to problems, Trust me my friend, your "overkill" solutions are very much appreciated... please don't ever stop! A script-tard such as myself have learned much about the scripting syntax due to you, tk, darth333, beancounter & envida's (and others I may have forgotten) posted examples... EDIT: I just opened the file and notice you included a compile all batch file for the sources! Thanks for the include. Should save alot of headaches for those that haven't already made one or dislike using the command line Link to comment Share on other sites More sharing options...
stoffe Posted April 28, 2005 Share Posted April 28, 2005 Originally posted by ChAiNz.2da EDIT: I just opened the file and notice you included a compile all batch file for the sources! Thanks for the include. Should save alot of headaches for those that haven't already made one or dislike using the command line Well, in this case it is a "compile almost all" batch file, since it just compiles the files using the Random Loot system but not the one script you need to change to add your own items to spawn to it. Unless you want to further modify the random loot system, you shouldn't need to touch the files in the Source folder. The point of the modification is that you'd only need to modify recompile the 000_custom_loot.nss plugin script, which needs no additional scripts to compile. Not much point in making a separate compile batch file for the 000_custom_loot.nss script though since it's only one file. Link to comment Share on other sites More sharing options...
The Source Posted April 28, 2005 Share Posted April 28, 2005 I am in the middle of recreating an old mod, which I posted earlier. My premise was to have the object spawn onto a placeable. However, I had problems where the placeable was attatched to a universal file, so it spawned onto every body that had used the same file. Now, what the hell am I getting at!? Instead of having the object spawn out of now where and into a body, I decided to make it spawn in a merchant shop, so people can buy the item. Therefore, you don't get that "Cheat" notice on your game saves. Just a random thought! Link to comment Share on other sites More sharing options...
Darth333 Posted April 28, 2005 Share Posted April 28, 2005 A bit off-topic but... Originally posted by MacLeodCorp I am in the middle of recreating an old mod, which I posted earlier. My premise was to have the object spawn onto a placeable. However, I had problems where the placeable was attatched to a universal file, so it spawned onto every body that had used the same file. This situation can be easily avoided by using the GetNearestObjectToLocation function where you can specify a location and then target the nearest object to that location: // 228: Get the nNth object nearest to lLocation that is of the specified type. // - nObjectType: OBJECT_TYPE_* // - lLocation // - nNth // * Return value on error: OBJECT_INVALID object GetNearestObjectToLocation (int nObjectType, location lLocation, int nNth=1); here is a sample script: [size=1] void main () { //the coordinates can be obtained with the [url=http://www.starwarsknights.com/tools.php]whereami armband[/url]. //Just stand the closest as you can from the container you want to use.. float x=0.00f; // x coordinate goes here float y=0.00f; // y coordinate goes here float z=0.00f; // zcoordinate goes here float r=0.0f; // orientation goes here (but it does not really matter here so leave it to 0.0 ) vector vecCont=Vector(x,y,z); location locCont=Location(vecCont, r); object oContainer= GetNearestObjectToLocation (OBJECT_TYPE_PLACEABLE, locCont); while(GetIsObjectValid(oContainer)) { if(GetTag(oContainer) == "my_object_tag") { CreateItemOnObject("item_template", oContainer); CreateItemOnObject("item_template", oContainer) } } } [/size] Link to comment Share on other sites More sharing options...
Achilles Posted April 28, 2005 Share Posted April 28, 2005 Originally posted by MacLeodCorp Now, what the hell am I getting at!? Instead of having the object spawn out of now where and into a body, I decided to make it spawn in a merchant shop, so people can buy the item. Therefore, you don't get that "Cheat" notice on your game saves. Just a random thought! Don't get too far ahead of yourself. Use FindRef to do a search for "kexsstore". Disheartening, I know, but better you hear it from me than find out the hard way Link to comment Share on other sites More sharing options...
stoffe Posted April 28, 2005 Share Posted April 28, 2005 Originally posted by Darth333 here is a sample script: [size=1] void main () { //the coordinates can be obtained with the [url=http://www.starwarsknights.com/tools.php]whereami armband[/url]. //Just stand the closest as you can from the container you want to use.. float x=0.00f; // x coordinate goes here float y=0.00f; // y coordinate goes here float z=0.00f; // zcoordinate goes here float r=0.0f; // orientation goes here (but it does not really matter here so leave it to 0.0 ) vector vecCont=Vector(x,y,z); location locCont=Location(vecCont, r); object oContainer= GetNearestObjectToLocation (OBJECT_TYPE_PLACEABLE, locCont); while(GetIsObjectValid(oContainer)) { if(GetTag(oContainer) == "my_object_tag") { CreateItemOnObject("item_template", oContainer); CreateItemOnObject("item_template", oContainer) } } } [/size] There's a slight mistake in that example script. Since the controlling condition in the while loop never changes, it would cause an infinite loop if a placeable was found, which I assume isn't the desired result. A corrected variant: void main () { //the coordinates can be obtained with the whereami armband. //Just stand the closest as you can from the container you want to use.. vector vecCont; vecCont.x = 0.0; // x coordinate goes here vecCont.y = 0.0; // y coordinate goes here vecCont.z = 0.0; // z coordinate goes here int nIdx = 1; location locCont = Location(vecCont, 0.0); object oContainer = GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, locCont, nIdx); while (GetIsObjectValid(oContainer)) { if (GetTag(oContainer) == "my_object_tag") { CreateItemOnObject("item_template", oContainer); CreateItemOnObject("item_template", oContainer); break; } oContainer = GetNearestObjectToLocation(OBJECT_TYPE_PLACEABLE, locCont, ++nIdx); } } Link to comment Share on other sites More sharing options...
Xcom Posted April 28, 2005 Share Posted April 28, 2005 Originally posted by stoffe -mkb- it would cause an infinite loop if a placeable was found, which I assume isn't the desired result. Ah! Infinite loops.. those can be fun. Fortunately, TSL doesn't crash when this happens. It will freeze for about 3-4 sec. and the loop will auto-break. Link to comment Share on other sites More sharing options...
stoffe Posted May 5, 2005 Share Posted May 5, 2005 Originally posted by VHKnight1 (in PM) hey thanks alot, that should work now, also is this a random respawn from creatures or what? and what is the random drop ratio? I apologize for posting this reply here, but your PM inbox is either disabled or full or something. The board wouldn't let me reply to your message whatever the reason. Look at line 164 in the modified 000_custom_loot.nss file, this is where the chance of dropping a custom item is currently set. It uses a simple random number condition which triggers when a 1-100 generated value is bigger than 90, in other words in about 10% chance. You can change this to anything you want, or add additional conditions on this line. This line also checks what type of spawn the item may appear for. Right now it only checks that the spawn type isn't 6, in other words it can spawn anywhere and on anything (creatures, containers etc) except on Peragus. Check the comments at the top of the script to see what those numbers mean if you want to add further restrictions. I should perhaps also mention that if you add more ST_SpawnItem() calls, make sure you only return TRUE in ST_SpawnCustomItems() if the ST_SpawnItem() call returned true like the current ones do, otherwise items defined on the lines below it would never spawn. (ST_SpawnItem() returns TRUE when an item was created.) Also, make sure you put function for spawning Unique items above spawning any non-unique ones, since the ST_SpawnCustomItems() function will stop as soon as it found some valid custom loot to spawn. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.