Changing item degradation/destruction odds?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Infinitum
    Swordsman
    • Oct 2013
    • 319

    Changing item degradation/destruction odds?

    Hi, I'm in need of some help deciphering C over here. =)
    I'm currently trying my hand at modding Sil to fit my preferences since I've burnt out a bit on 1.2.1 yet got the urge to slay some V (and don't want to wait for a potential january release - half's spawn might have well devoured him by now for all I know).

    Basically, I want to change some monster flavor around, redefine "Staffs" as "Words" (of command, because Tolkien etc) and remove item degradation and destruction.
    The kicker, of course, being that I've never written a line of code since.. RPGmaker 2000? When I was 12?

    Now, this isn't much of a problem for the monster stuff since it's all easily available in monster.txt.

    Same goes for most of the staff fluff, however it seems like I cannot actually rename "Staff" itself within object or flavor.txt since it references the item code itself. After downloading and extracting the code and looking at the auspicious-sounding "object1.c" file, this is what I've got:

    Code:
    		/* Staffs */
    		case TV_STAFF:
    		{
    			/* Color the object */
    			modstr = flavor_text + flavor_info[k_ptr->flavor].text;
    			if (aware) append_name = TRUE;
    			basenm = (flavor ? "& # Staff~" : "& Staff~");
    
    			break;
    		}
    Which I promptly changed into:

    Code:
    		/* Staffs */
    		case TV_STAFF:
    		{
    			/* Color the object */
    			modstr = flavor_text + flavor_info[k_ptr->flavor].text;
    			if (aware) append_name = TRUE;
    			basenm = (flavor ? "& # Word~" : "& Word~");
    
    			break;
    		}
    In the hope that this will make the game display the item type formerly known as "Staff" as "Word" instead in the game and inventory windows. Am I right in this assumption? If not, any pointers where to look?

    As for item destruction and degradation, I went ahead and put the IGNORE_ALL flag on pretty much every item type in object.txt, which should work in a charmingly bruteforce sort of way. Except that this will flood my message prompt whilst playing the game.

    SO, I had the brilliant idea of going through the spell code and changing the percentage chance of item destruction affecting equipment/inventory items to 0% for ice, fire and acid respectively, hoping for some sort of IF->randomnumber[1-100]>X THEN->badsshithappens ELSE->peaches on being exposed to elemental attacks.

    No such luck however - opened up spells1.c, scrolled past the definition code for what items are eligible to be affected by stuff and am currently looking at:

    Code:
    /*
     * This seems like a pretty standard "typedef"
     */
    typedef int (*inven_func)(const object_type *);
    
    /*
     * Destroys a type of item on a given percent chance
     * Note that missiles are no longer necessarily all destroyed
     *
     * Returns number of items destroyed.
     */
    static int inven_damage(inven_func typ, int perc, int resistance)
    {
    	int i, j, k, amt;
    
    	object_type *o_ptr;
    
    	char o_name[80];
    Which looks like it should contain the value I'm looking to modify, except I'm pretty sure it doesn't? Is it the number in brackets? Google tells me it defines an array, which confuses me to no end since I don't really see the code following it reference it in any way. Can I change this number to 100 and call it a day? Is the percentage chance applied as the code scans through the backpack for eligible items? Help?

    BONUS QUESTION: The game already floods "x isn't affected" messages when stuff is hit by fireballs or whatever on the floor, so I'm assuming there isn't any variable to change the odds of stuff on the floor not burning to 0%, is this correct though?
    Last edited by Infinitum; July 22, 2015, 17:10.
  • mixer
    Scout
    • Dec 2011
    • 25

    #2
    C arrays

    The declaration of
    char ???[80];

    is declaring and array of char (characters) so this is just place to put a string in.

    If you are looking for percentages I would look for either double or int or long declarations.

    Looking at the fragment of the code supplied I would follow perc declared in the function header. This is likely to be short for percentage!

    Comment

    • Infinitum
      Swordsman
      • Oct 2013
      • 319

      #3
      Thank you! I.. have no idea what that just meant. I think I did manage to solve my issue at hand though:

      Code:
      /*
       * Does a given class of objects (usually) hate acid?
       * Note that acid can either melt or corrode something.
       */
      bool hates_acid(const object_type *o_ptr)
      {
      	/* Analyze the type */
      	switch (o_ptr->tval)
      	{
      		/* Useless */
      		case TV_USELESS:
      		{
      			return (TRUE);
      		}
      	}
      
      	return (FALSE);
      }
      Which reduces the amount of corrodable item types down to skeletons or whatnot? I reproduced this in the fire and cold item recognition codes. This should also prevent breath attacks from destroying items on the floor, right?

      Comment

      • Derakon
        Prophet
        • Dec 2009
        • 9022

        #4
        Originally posted by Infinitum
        Which reduces the amount of corrodable item types down to skeletons or whatnot? I reproduced this in the fire and cold item recognition codes. This should also prevent breath attacks from destroying items on the floor, right?
        That sounds about right. The item destruction code is all shared; it uses the same routines for destroying inventory items as it does for destroying items on the floor.

        I hope, incidentally, that you're planning to make elemental attacks painful in other ways to compensate for the fact that the player need no longer fear damage to their gear or items.

        Comment

        • Infinitum
          Swordsman
          • Oct 2013
          • 319

          #5
          Actually, I'm pondering whether elemental attacks are needed at all -- especially in Sil which omits most of them anyway and where grinding for elemental coverage takes a back seat to raw damage in/output, light level and resistance to status ailments. I'd much rather it continue to explore monsters being dangerous to engage because they alter the normal rules rather than casue a buttload of damage because one lacks a particular flag on the character sheet.

          There is of course dragonfire to attend to. But then again I'm personally ok with a variant where one does simply not go up against an adult dragon and live.

          Comment

          • debo
            Veteran
            • Oct 2011
            • 2402

            #6
            Ancient serpents are pretty awful if you are lacking corresponding resists.
            Glaurung, Father of the Dragons says, 'You cannot avoid the ballyhack.'

            Comment

            Working...
            😀
            😂
            🥰
            😘
            🤢
            😎
            😞
            😡
            👍
            👎