Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old April 18, 2011, 22:08   #1
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,582
PowerWyrm is on a distinguished road
Multiple pvals

This is something I wanted to see implemented for a long time now... Nice to see it's gonna make it to 3.3...

I've checked the current source code, and something is bugging me though. It seems that the current implementation simply adds the pvals from base item and ego item (if the item is an ego).

For example: an Elven Cloak (+2 to stealth) can become "of the Magi" (+2 to int/stealth)

For what I've understood, this would become an Elven Cloak of the Magi (+4 to int/stealth). This is probably a bit overpowered...

A better item would be an Elven Cloak of the Magi <+2, +2> (+2 to int, +4 to stealth) where the ego pval is affected to the object's second pval slot, leaving the base item pval unaffected.

This would work for item/ego with single pval... No idea what to do with multiple pvals items/egos with the current system. For multiplayer Angband (MAngband), a new field "bpval" has been added on the object to keep track of the "base" pval given by the object kind. When an ego item is generated, the ego pval is affected to the object pval, leaving the base pval untouched. Of course, this would add another level of complexity...
__________________
PWMAngband variant maintainer - check http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old April 18, 2011, 22:56   #2
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by PowerWyrm View Post
This is something I wanted to see implemented for a long time now... Nice to see it's gonna make it to 3.3...

I've checked the current source code, and something is bugging me though. It seems that the current implementation simply adds the pvals from base item and ego item (if the item is an ego).

For example: an Elven Cloak (+2 to stealth) can become "of the Magi" (+2 to int/stealth)

For what I've understood, this would become an Elven Cloak of the Magi (+4 to int/stealth). This is probably a bit overpowered...

A better item would be an Elven Cloak of the Magi <+2, +2> (+2 to int, +4 to stealth) where the ego pval is affected to the object's second pval slot, leaving the base item pval unaffected.

This would work for item/ego with single pval... No idea what to do with multiple pvals items/egos with the current system. For multiplayer Angband (MAngband), a new field "bpval" has been added on the object to keep track of the "base" pval given by the object kind. When an ego item is generated, the ego pval is affected to the object pval, leaving the base pval untouched. Of course, this would add another level of complexity...
Er, if you've described the current functionality correctly, then it's not what I intended. I intended it to work exactly as you suggested: that a base item with +2 of something, when combined with an ego template giving +2 of the same and one other thing, would end up with <+2, +4>, not +4 to both.

This is probably because I didn't pay sufficient attention to the generation of ego items - but since this is an area ripe for development at some point (see tickets #1080, #1179, #1394, #1395), I'm confident it will get fixed eventually.
Magnate is offline   Reply With Quote
Old April 19, 2011, 12:46   #3
PowerWyrm
Prophet
 
PowerWyrm's Avatar
 
Join Date: Apr 2008
Posts: 2,582
PowerWyrm is on a distinguished road
Here's the current code from obj_make:

/* Apply pvals */
for (i = 0; i < o_ptr->ego->num_pvals; i++)
{
if (!o_ptr->pval[i]) o_ptr->num_pvals++;
o_ptr->pval[i] += randcalc(o_ptr->ego->pval[i], level, RANDOMISE);
}

So base and ego pvals are added.

In object_pval_flags(), the flags on which the pvals are applied are ORed using of_union(). Let's examine the Elven Cloak of the Magi example again, using the latest txt files...

Base item: an Elven Cloak (L:2:STEALTH, L:1:SPEED)
Ego item: of the Magi (L:d2:1:INT, L:d3:1:STEALTH)

In object_prep(), the base pvals are assigned to the object pvals:
- pval 1: +2 to stealth
- pval 2: +1 to speed

In ego_apply_magic(), the ego pvals are assigned and added to the object pvals:
- pval 1: +1/+2 to int, making it +3/+4 to stealth/int
- pval 2: +1/+3 to stealth, making it +2/+4 to speed/stealth

The result:
an Elven Cloak of the Magi <+3/+4,+2/+4>
- +3/+4 to int
- +2/+4 to speed
- +5/+8 to stealth

If I'm correct, this is a hell of an ego item!

Sounds like a check must me made on the pval_flags when assigning the ego pvals to the object pvals:
- loop on ego pvals
- for each ego pval, get pval_flags
- for each pval_flag, check if it's already present on the object
- if yes, add the pval to the corresponding object pval
- if no, increase the number of object pvals and assign the pval to the new object pval

Some change must probably be made in object_pval_flags() to reflect this...

This means that object pvals must be an array of 2*MAX_PVALS, in case base item and ego item have a completely separate set of pval_flags...
__________________
PWMAngband variant maintainer - check http://powerwyrm.monsite-orange.fr (or http://www.mangband.org/forum/viewforum.php?f=9) to learn more about this new variant!
PowerWyrm is offline   Reply With Quote
Old April 19, 2011, 17:48   #4
PowerDiver
Prophet
 
Join Date: Mar 2008
Posts: 2,712
PowerDiver is on a distinguished road
Don't confuse pvals with values for flags. You can have 7 different flag non-zero values with 3 pvals.

A different approach is to give most items pvals <+1, +2, +4>. Compute what values you want for all flags, however you want to do it. So long as they are between 0 and 7, express them the obvious way. In special cases you might want something else, but this works for every standard item I can think of except rings or boots of speed, which are easily done with a single pval.
PowerDiver is offline   Reply With Quote
Old April 19, 2011, 22:28   #5
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by PowerWyrm View Post
Here's the current code from obj_make:

/* Apply pvals */
for (i = 0; i < o_ptr->ego->num_pvals; i++)
{
if (!o_ptr->pval[i]) o_ptr->num_pvals++;
o_ptr->pval[i] += randcalc(o_ptr->ego->pval[i], level, RANDOMISE);
}

So base and ego pvals are added.

In object_pval_flags(), the flags on which the pvals are applied are ORed using of_union(). Let's examine the Elven Cloak of the Magi example again, using the latest txt files...

Base item: an Elven Cloak (L:2:STEALTH, L:1:SPEED)
Ego item: of the Magi (L:d2:1:INT, L:d3:1:STEALTH)

In object_prep(), the base pvals are assigned to the object pvals:
- pval 1: +2 to stealth
- pval 2: +1 to speed

In ego_apply_magic(), the ego pvals are assigned and added to the object pvals:
- pval 1: +1/+2 to int, making it +3/+4 to stealth/int
- pval 2: +1/+3 to stealth, making it +2/+4 to speed/stealth

The result:
an Elven Cloak of the Magi <+3/+4,+2/+4>
- +3/+4 to int
- +2/+4 to speed
- +5/+8 to stealth

If I'm correct, this is a hell of an ego item!

Sounds like a check must me made on the pval_flags when assigning the ego pvals to the object pvals:
- loop on ego pvals
- for each ego pval, get pval_flags
- for each pval_flag, check if it's already present on the object
- if yes, add the pval to the corresponding object pval
- if no, increase the number of object pvals and assign the pval to the new object pval

Some change must probably be made in object_pval_flags() to reflect this...

This means that object pvals must be an array of 2*MAX_PVALS, in case base item and ego item have a completely separate set of pval_flags...
Thank you for this analysis - I've had a niggling feeling for some time that something wasn't quite right here, and you've illustrated it very helpfully.

I agree with most of your prognosis, and will certainly check for existing pval flags during ego creation. I've opened ticket #1404 for this.

But on your last point, MAX_PVALS means exactly that. So once an object has all its pvals active (nonzero), any new flags will have to be attached to the pval closest to the desired outcome.

Let's take your Elven Cloak of the Magi example again: our base cloak has +2 stealth, +1 speed. First we add +1d2 INT as a third pval, then we add some more stealth to the first pval. Now let's say that the Magi ego has been given a third pval, +1d2 WIS. We have no more pvals to create, so we roll 1d2 and pick a pval closest to the result, and add the WIS flag to it.
Magnate is offline   Reply With Quote
Old April 19, 2011, 22:42   #6
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,772
Derakon is on a distinguished road
So we're currently limited to three pvals per item? What was the reasoning behind picking that particular number?
Derakon is offline   Reply With Quote
Old April 19, 2011, 23:52   #7
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by Derakon View Post
So we're currently limited to three pvals per item? What was the reasoning behind picking that particular number?
It's what Sangband has, and it seems to work perfectly well - I couldn't see a need for any more.

We're not actually limited though: if you change MAX_PVALS to 4 and recompile (and then add some fourth pvals to objects/egos/artifacts), it should work perfectly well. At least, that was the design intention ...
Magnate is offline   Reply With Quote
Old April 19, 2011, 23:53   #8
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 8,772
Derakon is on a distinguished road
Okay, fair enough. I generally don't see the need to use limits that we might conceivably reach at any time unless there are good technical reasons for those limits.
Derakon is offline   Reply With Quote
Old April 20, 2011, 00:02   #9
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by Derakon View Post
Okay, fair enough. I generally don't see the need to use limits that we might conceivably reach at any time unless there are good technical reasons for those limits.
Agreed. In this case I think the limits are not technical and are instead (i) space on a line for describing an object (+x, +y) [a, +b] <+c, +d, -e, -f, etc.> and (ii) space in our brains for retaining the concepts of so many numbers. So my idea was that we could set MAX_PVALS at whatever we liked and see what happened. So far I've only done the most cursory tweaks to items to actually use 2nd and 3rd pvals - just what I could see would make sense immediately without unbalancing anything (e.g. separating DEX/MIGHT/SHOTS on Buckland slings). I am shortly going to go through the edit files with a fine tooth comb and do this properly for 3.3 - doubtless to howls of outrage from Timo, Eddie and Pete Mack. But I figured it would be worth doing that before deciding whether we needed more than three pvals.

Oooh, it's late and I'm tired. You're referring to my "max is max" comment, about why we can't just add extra pvals whenever an ego template requires a value that isn't used yet. We could try that and see how it goes. I'll try it when I fix #1404 and if it breaks before 3.3 we can revert to max=3.
Magnate is offline   Reply With Quote
Old April 20, 2011, 00:09   #10
PowerDiver
Prophet
 
Join Date: Mar 2008
Posts: 2,712
PowerDiver is on a distinguished road
Quote:
Originally Posted by Magnate View Post
Agreed. In this case I think the limits are not technical and are instead (i) space on a line for describing an object (+x, +y) [a, +b] <+c, +d, -e, -f, etc.>
That's an entirely different problem, in that the pvals shouldn't simply be listed. Much better, if you want to add wis to magi, to describe as

an elven cloak of magi () Int+2 Wis+3 Stl+4 Spd+1
and this is trivial to accomplish with 3 pvals in the current data structures.
PowerDiver is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple blows Skeeblix Vanilla 5 February 22, 2011 19:12
Taking advantage of multiple pvals Derakon Vanilla 20 January 23, 2011 13:04
Multiple shots FUD Vanilla 11 September 16, 2009 21:49
SVN: pvals no longer displayed (bug!) Pete Mack Vanilla 1 January 24, 2009 19:01
weapons: multiple blows versus multiple slays vorondil Vanilla 24 December 24, 2008 19:13


All times are GMT +1. The time now is 10:41.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.