Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Temporary bonuses from attributes

Temporary bonuses from attributes

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1 2  

Posted by Tseris   (98 posts)  Bio
Date Fri 19 Oct 2007 08:40 PM (UTC)
Message
Heres what I want: Player puts on +1 CON helmet, his max hps increase by 20. He takes it off, his max hps go down by 20. Similiarly with +2 CON, -6 CON, or whatever.

What I have:

void temp_stat_bonus ( CHAR_DATA * ch )
{
int temp_hp;
temp_hp = [get_curr_con( ch )].hitp

ch->max_hit += temp_hp

};

I know this isnt right, this seems like it would just add the hp bonus ive defined in con_app_type in const.c to the character's maxhit regardless of whether or not they are wearing the item. So someone could repeatedly take the item on and off and end up with infinite max hitpoints. But Im not sure how to write this the right way, nor where I should put the code.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #1 on Fri 19 Oct 2007 09:30 PM (UTC)
Message
Isn't this already possible without adding new code? (Use oset)

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #2 on Fri 19 Oct 2007 09:41 PM (UTC)
Message
What I would do is remove all references to "max_hit", and add a new function named something like "getEffectiveMaxHP" that takes the max_hit value and adds on appropriate bonuses. Of course, to do that would require a fair bit of redesign which might not be what you had in mind... :-)

In the meantime I'd go with Zeno's solution; if you want to add to somebody's HP, then have the object give an HP bonus. If you want the Con bonus as well, have it give that too. It's not as elegant, and not quite what you wanted probably, but it would work at least.



To implement something like what you have, you would have to carefully track every time a bonus is added [i]and removed[/i], and adjust the hit points accordingly. It would work a lot like how the effect system works now. (Incidentally, that system is very fragile and prone to doing weird things if things don't happen in precise and expected sequence.)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Conner   USA  (381 posts)  Bio
Date Reply #3 on Fri 19 Oct 2007 10:32 PM (UTC)
Message
But it's a good idea, it's how most graphical games handle item based stat bonuses (and item based other bonuses as well) and it makes sense.. is the best solution really just to make it all based on wear/remove progs though?

-=Conner=-
--
Come test your mettle in the Land of Legends at telnet://tcdbbs.zapto.org:4000
or, for a little family oriented medieval fun, come join us at The Castle's Dungeon BBS at telnet://tcdbbs.zapto.org
or, if you just want information about either, check our web page at http://tcdbbs.zapto.org
Top

Posted by Tseris   (98 posts)  Bio
Date Reply #4 on Fri 19 Oct 2007 10:42 PM (UTC)
Message
Well actually heres my thought. The equipment part of it is really just a side-note. My real goal is to put a +current hp modifier into the const struct con_app table. I figure if a piece of equipment can give +current hitpoints as one of its modifiers, I should be able to use that same modifier in the table, no? Im gonna keep looking and see what I can find.
Top

Posted by Tseris   (98 posts)  Bio
Date Reply #5 on Sat 20 Oct 2007 12:59 AM (UTC)
Message
Okay so I decided to look to strength as a template for what I want to do. In const.c and mud.h str_app gives a modifier to hitroll and damroll, I figured if I can modify those I should be able to modify max hitpoints. Wrong. I cant find anywhere that the hitroll or damroll modifier is called on. The carry weight and wield weight are used, but the other modifiers arent as far as I can tell.
Top

Posted by Gohan_TheDragonball   USA  (183 posts)  Bio
Date Reply #6 on Sat 20 Oct 2007 02:25 AM (UTC)
Message
not sure if this is what you are talking about, but in my game i went through and added perm_hit to the character structure, so when i do bonus stuff i do the following:


void apply_hit_bonus( CHAR_DATA *ch )
{
    int mod;

    ...loop through all types of bonuses, add/subtract from mod accordingly

    ch->max_hit = ch->perm_hit + mod;
}
Top

Posted by Tseris   (98 posts)  Bio
Date Reply #7 on Sat 20 Oct 2007 09:25 PM (UTC)
Message
Okay, I think ive got something to work with, which is very similiar to what you're doing Dragonball, now my question is which source code file should I put this in? Seems like a dumnb question, but this is my first attempt at creating something new rather than modifying something already there.
Top

Posted by Tseris   (98 posts)  Bio
Date Reply #8 on Sat 20 Oct 2007 10:07 PM (UTC)
Message
So the simple code Im running is:

void attribute_bonuses ( CHAR_DATA * ch )
{
ch->max_hit += [get_curr_con( ch )].hpbonus
}

and heres the error I get:

handler.c:831: error: expected primary-expression before '[' token

Im not seeing what it is Im missing. I decided to try putting it in handler.c because I placed it right after the section that gets a character's str_app to calculate their carry weight. Ive already set the .hpbonus up in the attribute bonus structure in mud.h and the attribute bonus table in const.c
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #9 on Sun 21 Oct 2007 02:29 AM (UTC)
Message
I'm not sure, but why are you using [ ]?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Tseris   (98 posts)  Bio
Date Reply #10 on Sun 21 Oct 2007 03:27 AM (UTC)
Message
Well that is the format that is used for calling information from the attribute table in various other places so I thought it best to follow the same usage. However I did try replacing the [ ] with ( ) and this time I got the following:

handler.c: In function 'void abttribute_bonuses (CHAR_DATA*)':
handler.c:831: error: request for member 'hpbonus' in 'get_curr_con(ch)', which is of the non-class type 'short int'

now the hpbonus in mud.h is set as short, but the values only go from -200 to 200 so I dont think short was the wrong keyword, nonetheless i tried it again after changing 'short' to 'int' and got the same error
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #11 on Sun 21 Oct 2007 03:54 AM (UTC)
Message
But isn't get_curr_con a function?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Reply #12 on Sun 21 Oct 2007 04:08 AM (UTC)
Message
Quote:


ch->max_hit += [get_curr_con( ch )].hpbonus

...

Well that is the format that is used for calling information from the attribute table in various other places so I thought it best to follow the same usage.



I am not familiar with that syntax in C or C++. Can you give an example of where you saw that?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Tseris   (98 posts)  Bio
Date Reply #13 on Sun 21 Oct 2007 06:45 PM (UTC)
Message
in handler.c:

/*
* Retrieve a character's carry capacity.
*/

int can_carry_w( CHAR_DATA * ch )
{
if( !IS_NPC( ch ) && ch->level >= LEVEL_IMMORTAL )
return 1000000;

if(!IS_NPC( ch ) && xIS_SET( ch->act, ACT_IMMORTAL ) )
return 1000000;

return str_app[get_curr_str( ch )].carry;
}

Its actually right after this that I tried to put my code for the hp bonus. Ive seen several other examples of this in the stock code (which is SmaugFUSS 1.8). The only other one I can think of offhand was in update.c where the wis_app[get_curr_wis( ch )].practice is used to add the right amount of new practice sessions on level gain.
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #14 on Sun 21 Oct 2007 07:01 PM (UTC)
Message
That syntax and the one you tried aren't the same. The format is this:
table[location].type

Where location is a number.

This is what you did:
[location].type

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


82,039 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.