Help me make my new variant! (please!)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • will_asher
    DaJAngband Maintainer
    • Apr 2007
    • 1124

    Originally posted by backwardsEric
    There was the problem you reported with flasks of oil multiplying, I believe that was addressed in https://github.com/angband/angband/pull/4671 . It's taken several sets of changes to get the handling of thrown weapons in the quiver to its current state. In order from first to last they were (the key files are obj-gear.c and player-calcs.c (for calc_inventory()):
    1. https://github.com/angband/angband/c...0afb42d95943f2
    2. https://github.com/angband/angband/pull/4613
    3. https://github.com/angband/angband/c...d95d01d83141e2
    4. https://github.com/angband/angband/c...d95d01d83141e2
    5. https://github.com/angband/angband/c...d95d01d83141e2
    6. https://github.com/angband/angband/pull/4671
    7. https://github.com/angband/angband/c...d95d01d83141e2
    8. https://github.com/angband/angband/pull/4769
    Thanks that'll help
    Will_Asher
    aka LibraryAdventurer

    My old variant DaJAngband:
    http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

    Comment

    • will_asher
      DaJAngband Maintainer
      • Apr 2007
      • 1124

      I'm looking at calc_bonuses() and I'm a little confused about which stat array holds the actual stat number shown on the status line. Is it state->stat_use[] or state->stat_ind[] ?
      And under "/* Calculate the various stat values */",
      why does "ind = (use - 3);"? (Why is 3 subtracted from it?)
      Will_Asher
      aka LibraryAdventurer

      My old variant DaJAngband:
      http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

      Comment

      • backwardsEric
        Knight
        • Aug 2019
        • 531

        Originally posted by will_asher
        I'm looking at calc_bonuses() and I'm a little confused about which stat array holds the actual stat number shown on the status line. Is it state->stat_use[] or state->stat_ind[] ?
        And under "/* Calculate the various stat values */",
        why does "ind = (use - 3);"? (Why is 3 subtracted from it?)
        It's stat_use (code in ui-display.c displays the panel next to the map with the stats; code in ui-player.c displays the character sheet). stat_ind has a converted range: rather than the 3 - 18/220 range (encoded as 3 - 18 for 3 to 18 and 18 plus the excess for an over 18 stat) it uses a range of 0 (thus the subtraction of 3) to 37 for easier lookup into tables for things that depend on a stat (weight allowance, adjustment to device skill, ...).

        Comment

        • will_asher
          DaJAngband Maintainer
          • Apr 2007
          • 1124

          cool, thanks
          Will_Asher
          aka LibraryAdventurer

          My old variant DaJAngband:
          http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

          Comment

          • will_asher
            DaJAngband Maintainer
            • Apr 2007
            • 1124

            trying to add a heaviness curse, but I can't find where it actually applies the curse effect to an object.
            I have this in object-init.c
            Code:
            static enum parser_error parse_curse_combat(struct parser *p) {
            	struct curse *curse = parser_priv(p);
            	assert(curse);
            
            	curse->obj->to_h = parser_getint(p, "to-h");
            	curse->obj->to_d = parser_getint(p, "to-d");
            	curse->obj->to_a = parser_getint(p, "to-a");
            	curse->obj->weight = parser_getint(p, "weight");
            
            	return PARSE_ERROR_NONE;
            }
            but curse->obj->to_a, to_h and to_d don't seem to be used anywhere else in the code.
            I looked through obj-curse.c, but it never seems to look at the curse->obj->to_h(etc). The curse struct declared in object.h doesn't even have a place for to_h/to_d/to_a. Where does the code apply these things to an object?
            Will_Asher
            aka LibraryAdventurer

            My old variant DaJAngband:
            http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

            Comment

            • Nick
              Vanilla maintainer
              • Apr 2007
              • 9647

              Originally posted by will_asher
              The curse struct declared in object.h doesn't even have a place for to_h/to_d/to_a. Where does the code apply these things to an object?
              The trick is that struct curse has a field
              Code:
              struct object *obj;
              which holds all that information. This is then applied in calc_bonuses(), in the loop starting with
              Code:
              	/* Analyze equipment */
              	for (i = 0; i < p->body.count; i++) {
              		int index = 0;
              		struct object *obj = slot_object(p, i);
              		struct curse_data *curse = obj ? obj->curses : NULL;
              
              		while (obj) {
              with combat bonuses being applied here:
              Code:
              			/* Apply combat bonuses */
              			state->ac += obj->ac;
              			if (!known_only || obj->known->to_a)
              				state->to_a += obj->to_a;
              			if (!slot_type_is(p, i, EQUIP_WEAPON)
              					&& !slot_type_is(p, i, EQUIP_BOW)) {
              				if (!known_only || obj->known->to_h) {
              					state->to_h += obj->to_h;
              				}
              				if (!known_only || obj->known->to_d) {
              					state->to_d += obj->to_d;
              				}
              			}
              The original object is handled first, then any curse objects, with the iteration through them being handled here:
              Code:
              			/* Move to any unprocessed curse object */
              			if (curse) {
              				index++;
              				obj = NULL;
              				while (index < z_info->curse_max) {
              					if (curse[index].power) {
              						obj = curses[index].obj;
              						break;
              					} else {
              						index++;
              					}
              				}
              			} else {
              				obj = NULL;
              			}
              So in addition to your change in obj-init.c, you need to handle weight in that combat bonuses section.

              Heaviness curse is a nice idea, BTW, I will probably steal it back from you
              One for the Dark Lord on his dark throne
              In the Land of Mordor where the Shadows lie.

              Comment

              • will_asher
                DaJAngband Maintainer
                • Apr 2007
                • 1124

                Originally posted by Nick
                So in addition to your change in obj-init.c, you need to handle weight in that combat bonuses section.

                Heaviness curse is a nice idea, BTW, I will probably steal it back from you
                Thanks, but I can't tell how I would add object weight in calc_bonuses(). I guess I would I need to add a weight field in the player_state struct?

                EDIT: So the curses don't modify the object at all. They just modify the player while the object is being worm/wielded. That's going to make it hard to do a heaviness curse, especially for thrown weapons...

                PS: here's the entry for curse.txt:

                name:heaviness
                combat:-4:4:0:100 (the 4th spot here is for weight, so it adds up to 10lbs)
                values: DEX[-2]
                type:hafted
                type: polearm
                type:sword
                type:bow
                type:throwing weapon
                type:boots
                type:shield
                type:hard armor
                type:dragon armor
                desc:weighs you down

                I also added a lightness ego.
                Last edited by will_asher; August 21, 2021, 04:52.
                Will_Asher
                aka LibraryAdventurer

                My old variant DaJAngband:
                http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

                Comment

                • Nick
                  Vanilla maintainer
                  • Apr 2007
                  • 9647

                  Originally posted by will_asher
                  Thanks, but I can't tell how I would add object weight in calc_bonuses(). I guess I would I need to add a weight field in the player_state struct?
                  You're correct, putting it in calc_bonuses() was bad advice

                  It looks like this is actually a bit of work. The way I would do it is:
                  1. Add a function (probably in obj-util.c) called something like object_weight(). This should take a struct object * argument, and should take the object's actual weight and then run through all the curses on the object add weight whenever a curse has weight, and return the total.
                  2. Then search though for all uses of object weight in calculations or display, and replace obj->weight with object_weight(obj).
                  Alternatively, you could file it as an issue for Vanilla and hope someone else does it...
                  One for the Dark Lord on his dark throne
                  In the Land of Mordor where the Shadows lie.

                  Comment

                  • will_asher
                    DaJAngband Maintainer
                    • Apr 2007
                    • 1124

                    In this line:
                    int player_noise = 1 << (30 - stealth);
                    what does the "<<" mean?
                    Will_Asher
                    aka LibraryAdventurer

                    My old variant DaJAngband:
                    http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

                    Comment

                    • Nick
                      Vanilla maintainer
                      • Apr 2007
                      • 9647

                      Originally posted by will_asher
                      In this line:
                      int player_noise = 1 << (30 - stealth);
                      what does the "<<" mean?
                      It's the left shift operator - it shifts all the bits to the left, which is effectively multiplying by a power of 2. So 1 << 1 is 2, 1 << 2 is 4, 1 << 3 is 8, etc.
                      One for the Dark Lord on his dark throne
                      In the Land of Mordor where the Shadows lie.

                      Comment

                      • Pete Mack
                        Prophet
                        • Apr 2007
                        • 6883

                        Note that STL 30 (legendary) gives perfect stealth where you can stroll past Huan without risk. I once walked between him and Tarrasque, at about 3 squares away for each.

                        Comment

                        • will_asher
                          DaJAngband Maintainer
                          • Apr 2007
                          • 1124

                          Originally posted by Nick
                          It's the left shift operator - it shifts all the bits to the left, which is effectively multiplying by a power of 2. So 1 << 1 is 2, 1 << 2 is 4, 1 << 3 is 8, etc.
                          Sorry, it's been a long time since I had any math(s) class. "by a power of 2" sounds to me like "squared" but 1 squared is still 1 so how does 1 << 1 = 2?, and I don't know what you mean by "shifting bits to the left" (unless it's multiplying by 10 which it obviously isn't). I still don't get it...
                          Will_Asher
                          aka LibraryAdventurer

                          My old variant DaJAngband:
                          http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

                          Comment

                          • Nick
                            Vanilla maintainer
                            • Apr 2007
                            • 9647

                            Originally posted by will_asher
                            Sorry, it's been a long time since I had any math(s) class. "by a power of 2" sounds to me like "squared" but 1 squared is still 1 so how does 1 << 1 = 2?, and I don't know what you mean by "shifting bits to the left" (unless it's multiplying by 10 which it obviously isn't). I still don't get it...
                            Power of 2 means 2 multiplied by itself a number of times. Computer arithmetic is base 2 or binary (bit = binary digit), so shifting to the left multiplies by 2 (in normal base 10, shifting to the left would indeed multiply by 10). I can go on about this stuff forever, but I won't
                            One for the Dark Lord on his dark throne
                            In the Land of Mordor where the Shadows lie.

                            Comment

                            • backwardsEric
                              Knight
                              • Aug 2019
                              • 531

                              Originally posted by will_asher
                              Sorry, it's been a long time since I had any math(s) class. "by a power of 2" sounds to me like "squared" but 1 squared is still 1 so how does 1 << 1 = 2?, and I don't know what you mean by "shifting bits to the left" (unless it's multiplying by 10 which it obviously isn't). I still don't get it...
                              1 << n is equivalent to multiplying by 2, n times in a row. So, for n = 1, it multiplies by 2; for n = 2, it multiplies by 4.

                              An example with 8 bits (most significant (biggest) first):

                              00000101 = 1 * 2^2 + 1 * 2^0 = 4 + 1 = 5

                              Shifted by 1 bit to the left:

                              00001010 = 1 * 2^3 + 1 * 2^1 = 8 + 2 = 10 = 5 * 2

                              Shifted by 2 bits to the left:

                              00010100 = 1 * 2^4 + 1 * 2^2 = 16 + 4 = 20 = 5 * 4

                              This is analogous to multiplying by 10 when a number is written in decimal notation. However, for binary each digit represents a power of 2 rather than a power of 10, so shifting multiplies (or divides) by 2 rather than by 10.

                              Comment

                              • will_asher
                                DaJAngband Maintainer
                                • Apr 2007
                                • 1124

                                Okay, I see.
                                Now, I'm wondering why the stealth code uses this weird formula...
                                Will_Asher
                                aka LibraryAdventurer

                                My old variant DaJAngband:
                                http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

                                Comment

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