----- Original Message -----
From: "Torgny Bjers" <tb@sbbs.se>
> I am working on implementing 5 mana pools, or techniques (sort of like Ars
> Magica), and I just wanted to ask you guys which is the best way to do this
> in the magic system? Shall I just duplicate all the MANA and MAX_MANA
> checks and suchlikes to utilize the four new ones, or how? Can you give me
> any pointers on this? I am rather familiar with the code, I just don't know
> how to code. I have hand-patched in DG Scripts and made it work, so I am
> not a complete moron. :) But, speak in simple programming terms and try to
> avoid much to difficult code-lingo, please.. ;) I do NOT need information
> on how to add this to the player struct, or anything like that, I just want
> tips and pointers on how to make it effective in the already existing
> functions such as do_cast, leveling, and such... Shall I use like some sort
> of switch statement for them all, or just line them all up in a long row,
> how?
I'd suggest changing the struct spell_info_type (in spells.h) to allow five different
mana pools (I'm only suggesting the names mana1-5) to be used with each spell, rewriting
the spello() function to accept all five types of mana, and lastly write a new mana check function.
Mailer code(!) follows: (best put somewhere in spell_parser.c..)
int mana1_cost(int spell, int level){ /* and make copies called mana2_cost, mana3_cost etc.*/
return MAX(SINFO.mana1_max - (SINFO.mana1_change
* (GET_LEVEL(ch) - SINFO.min_level (int) GET_CLASS(ch)])),
SINFO.mana1_min);
}
This could be used instead of the standard mana check..
int have_mana_for_spell(struct char_data *ch, int spellnr) {
if (GET_MANA1(ch) < mana1_cost(spellnr, GET_LEVEL(ch))
|| (GET_MANA2(ch) < mana2_cost(spellnr, GET_LEVEL(ch))
|| (GET_MANA3(ch) < mana3_cost(spellnr, GET_LEVEL(ch))
|| ...
return 0; /*No, there was some mana missing somewhere..*/
else
return 1; /*All were higher or equal to*/
}
And this instead of the standard subtraction:
void use_mana_for_spell(struct char_data *ch, int spellnr, int divisor) {
if (divisor < 1)
divisor = 1;
GET_MANA1(ch) = MAX(GET_MANA1(ch)
- mana1_cost(spellnr, GET_LEVEL(ch)) / divisor, 0);
GET_MANA2(ch) = MAX(GET_MANA2(ch)
- mana2_cost(spellnr, GET_LEVEL(ch)) / divisor, 0);
GET_MANA3(ch) = MAX(GET_MANA3(ch)
- mana3_cost(spellnr, GET_LEVEL(ch)) / divisor, 0);
etc..
}
Which should be called with ie.
use_mana_for_spell(ch, SPELL_BLESS, 1); if the bless spell went through, and
use_mana_for_spell(ch, SPELL_BLESS, 2); if the bless spell failed..
Hope this helps - if not for anything else, then the gurus will have someone to
flame for bad coding technique :P (that's me..)
In the leveling part, I believe you can just copy the existing mana additions.
Welcor
- who actually thinks 5 mana pools is quite a fascinating idea, which will never
be put into Cruel World MUD, as long as he has anything to say about it...
+------------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
| http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
+------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/11/01 PDT