Making NPCs drop custom commodities

  • Okay, first of all, hello everyone! This is my first time actually making a post on this particular forum, though I've been lurking around Lancersreactor for the modding tutorials on Freelancer for at least 5 or 6 years, off and on. If anyone is wondering why my username is Gmod4ever, it's because it was my first username (for a Garry's Mod [HL2 Mod] forum, Facepunch Studios) and I like to keep everything the same, so I don't forget things. Again, hello everyone!


    Now, back to my problem. I have tried and tried many a times, and I still can not get this to work. I am at my patience's end, now.


    What I'm trying to do is make a basic additional commodity mod, just to get started with modding Freelancer. I can make the commodity fine, put it on bases to sell and buy, do the description and all that jazz. This all works fine. But I can not, for the life of me, get NPCs to drop it as loot. I'm not sure what I'm doing wrong.


    Here's all my scripts (I prefer using XML files because I'm used to using them when modding STALKER: Shadow of Chernobyl), from beginning to end.


    script.xml:


    com_buysell.xml


    commodities.xml


    com_information.xml


    com_carriers.xml


    As you can see, In script.xml, I've appended two entries to lootprops.ini. The first of which is a [mLootProps], declaring my commodity (commodity_phenzine). As far as I can tell, from both inferences and searching the Internet, the drop_properties read as follows: Probability of dropping loot if ship holds it (from 0 to 100, in percent), Max rank points (with 0 being no max), Min rank points, Unknown, Unknown.


    The second appendage is a PhantomLoot, which from what I can tell is a simple random drop percentage, with the NPC in question not requiring to actually hold the item (hence the "phantom")


    Maybe I have the percentage too high, but nonetheless, I've done a mission or two against Rogues (on my own LAN server, where the commodity exists and is buying on Manhattan for my desired price of 360) and have killed about ten total. Absolutely none of these Rogues has dropped any Phenzine.


    Also, just to throw it in there, I'm assuming that the trade routes NPCs take are dynamically generated, so to make like, Cryer, transport Phenzine from Manhattan to somewhere else, I'd have to make Phenzine be sellable at some other station at a higher price than what it's buyable in Manhattan?


    I have no idea if this is a place to post this, since, looking around, this forum seems unfortunately dead. I'm hoping to get some responses, though. This has been irking me forever.


    Thanks to anyone who posts, even if you can't help me - just the support is nice :D

  • Great first post mate. Very detailed so I could get an idea of what your code is.


    First things first, a quick question for you... 100 bucks says you are testing for "loot drops" by doing missions? Instead of killing a random npc spawned by random encounters? If so that is your problem. I looked at the code and I don't see any coding for your RMLootInfo.ini in the Random Missions folder. I dont know your knowledge level, but it looks like you are somewhat handy with code.... but if you didnt know the RMLootInfo controls loot drops during Random Missions and the LootProps.ini controls loot drops during Random Encounters.


    Here is an example entry (based on your coding). It should fix your issue.


    [RMBonusLoot]
    archetype = commodity_phenzine
    num_to_drop = 6, 9
    faction = fc_lr_grp, co_be_grp, co_rs_grp, co_ss_grp, co_hsp_grp, fc_c_grp, fc_ou_grp, fc_j_grp, fc_x_grp, fc_lh_grp
    difficulty_range = 0, 100
    weight = 10


    Another thing I noticed, in your LootProps.ini entries you have a number of the factions wrong (the faction nickname). For example...



    It should be...
    [FactionGood]
    faction = fc_c_grp
    [FactionGood]
    faction = fc_ou_grp
    [FactionGood]
    faction = fc_x_grp
    [FactionGood]
    faction = fc_j_grp[/quote]


    And the correct code for the Lane Hackers is fc_lh_grp. From my quick skim over it... the rest of your code looks good to go. I hope this helps you out! :P Feel free to PM me if you have any questions.


  • And the correct code for the Lane Hackers is fc_lh_grp. From my quick skim over it... the rest of your code looks good to go. I hope this helps you out! :P Feel free to PM me if you have any questions.[/quote]


    Thanks mate. I'm gonna respond to your post respectively:


    Thanks. I like to be descriptive. Plus the main forum I'm from, Facepunch Studios, is reknowned for its Grammar Nazism, and the moderation is strict in that you use proper grammar (The motto to the rule is "This isn't AOL; we speak actual ENGLISH here.") and capitalization. I myself like being descriptive because then it means that people can help me faster, and it takes less post-spam clutter on the thread. :D


    And yes, I am only testing by missions. I haven't had the patience to run around and hope to get attacked. I had a suspicion that I needed to use the RMLootInfo, but I looked at how Discovery mod (my modding reference :)) did theirs, and as far as I recall (I did this yesterday; that's a long time to remember :lol: ) they didn't alter that. As for my knowledge in coding, I did an extensive mod for STALKER: Shadow of Chernobyl called Wrath of Chernobyl (You can find it by googling, it's the first few hits), which uses mostly ini files, Lua files, and XML files. In fact, Lua is the language I'm most fluent in, although STALKER got me pretty good at using both ini files and XML, so I'm not a total nub in the dark with these two languages. :P


    If this code snippet of yours fixes it, I will love you eternally. Out of curiosity, does the weight value hold any actual value, or is it just kinda thrown in there just cuz? I can't really think of anything it'd influence that would have any actual effect on how it works right off the top of my head...


    For the factions, I used Discovery Mod's IONCROSS Data files, since it had a complete list of how they are. Here's a snippet showcasing this from the text files.



    Also, looking at initialworld.ini also suggests that the criminal factions are prefixed with fc_, rather than co_ (which I infer means 'faction' and 'company', respectively):



    And thanks man. I hope this works, and if it does, then me love you long time :D

  • I'm pretty sure it'll work for you. Be sure to let me know what the result is. If it doesn't I'll take more time studying your code.


    Quote

    Out of curiosity, does the weight value hold any actual value, or is it just kinda thrown in there just cuz? I can't really think of anything it'd influence that would have any actual effect on how it works right off the top of my head...


    To be totally honest with you, I can't remember. I done some experiments a few years ago but I've all but brain dumped any data regarding my observations. Try experimenting and see what you get.


    Good Luck!

  • Yeah, that made it work. Out of curiosity, is the probability of the items dropping in RMLootInfo tied into the probability of dropping defined in the commodity's PhantomLoot? I did a mission to kill like four rogues, and the only loot I got was Phenzine, and 7 of it...


    Here's my code in com_missionloot.xml


    And the code in script.xml (again, for easier reference)


    I plan to test again with the percent_chance at 60, see how many I get, then lower it to like 1 and try again, but unfortunately I don't have enough time, and need to be heading out the door right now.


    Thanks so much for the help, man. Like I promised earlier, I now love you long time.

  • I am, too. I also answered my own question through experimentation. When adding the RMLootInfo block, the drop properties are borrowed from the PhantomLoot, such as how much to drop and the probabilities.


    I'm going to have so much fun making all these new commodities. I may even add other things later on to my mod... Who knows? :D

  • [PhantomLoot]
    nickname = commodity_phenzine
    toughness_range = 0, 100 <- NPC level
    percent_chance = 60 <- percent per kill that it will be dropped, averaged in with everything else they can drop
    num_to_drop = 6, 9 <- loot pods dropped (in this case 6 to 9 pods)