Page 1 of 1
Need some help with thaumaturgy code...
Posted: Mon Apr 12, 2010 10:16 pm
by Lord Estraven
So I'm trying to modify the thaumaturgy code in 2.3.8 (in cmd7.c) to make thaumaturgy still useful in the late game without making it horribly overpowered early on. And I'm running into problems. Specifically, "->". There are "->"s all over the place, and I've no idea what they do. At first I thought they were like "=" in reverse, making the value of the right variable equal to that of the left one or somesuch, but the more I look the more their use seems ambiguous.
(Can you tell I've never done C before?

)
Also, the damage of spells is of course determined by a damroll of dam_dice and dam_sides. Only, those two values don't seem to be derived from anything I can see. Where do they come from?
Re: Need some help with thaumaturgy code...
Posted: Mon Apr 12, 2010 10:21 pm
by bigfoot
Disclaimer: I know very little, almost nothing, about C.
I think that they are references.
Re: Need some help with thaumaturgy code...
Posted: Tue Apr 13, 2010 12:44 am
by budswell
-> Is a quick syntax for getting a field from a pointer to a struct.
i.e. ptr->fld is shorthand for (*ptr).fld
Code: Select all
typedef struct { int id; char* name } RecType;
RecType rec;
RecType* recPtr = &rec;
/* To get a value from a record*/
int id1 = rec.id;
/* To get a value from a record pointer...*/
int id2 = (*recPtr).id;
/* ... or use the shorthand -> notation. Another way opf writing the same thing as above */
int id3 = recPtr->id;
Hope that makes sense
Re: Need some help with thaumaturgy code...
Posted: Tue Apr 13, 2010 3:15 am
by Shoob
those dam_dice and dam_sides are part of the spell passed to it (hence the s_ptr, short for spell pointer or something, just like csp is short for current spell points)
but yeah bigfoot is right.
Re: Need some help with thaumaturgy code...
Posted: Tue Apr 13, 2010 4:45 am
by bigfoot
Haha! About the only thing I know.

Re: Need some help with thaumaturgy code...
Posted: Wed Apr 21, 2010 10:34 am
by Sorgath
Lord Estraven wrote:So I'm trying to modify the thaumaturgy code in 2.3.8 (in cmd7.c) to make thaumaturgy still useful in the late game without making it horribly overpowered early on. And I'm running into problems. Specifically, "->". There are "->"s all over the place, and I've no idea what they do. At first I thought they were like "=" in reverse, making the value of the right variable equal to that of the left one or somesuch, but the more I look the more their use seems ambiguous.
(Can you tell I've never done C before?

)
Also, the damage of spells is of course determined by a damroll of dam_dice and dam_sides. Only, those two values don't seem to be derived from anything I can see. Where do they come from?
As has been said the -> are for accessing things via a pointer. You should be able to google "C pointers" to find a decent explanation that tells you all you need to know. What changes do you want to make? If they're small enough I might be willing to do them for you. But personally I think thaumaturgy is pretty broken in general and would need a complete re-write to fix it.
Re: Need some help with thaumaturgy code...
Posted: Mon Jun 28, 2010 10:17 am
by Lord Estraven
Okay, for future reference what I was looking for - limits on thaum damage, damage for different spell types, etc. - was in spells1.c.
(Of particular note is a typo that makes ball spells use sides for dice and 1 for sides. That is a very very old bug.)
Re: Need some help with thaumaturgy code...
Posted: Mon Jun 28, 2010 5:52 pm
by AnonymousHero
Do you happen to have a patch or could you point to the typo? I'd like to get it fixed.
Re: Need some help with thaumaturgy code...
Posted: Wed Jun 30, 2010 5:53 pm
by Lord Estraven
This in spells1.c, starting on line 9281:
Code: Select all
else if (chance < 76)
{
rspell->proj_flags |= PROJECT_STOP;
rspell->radius = dice;
rspell->dam_dice = sides;
rspell->dam_sides = 1;
ball_desc = TRUE;
}
Presumably dam_sides should be dice or some derivative thereof, not 1. Also radius should probably be changed to something more sane, like half or even a third of the dice.
Re: Need some help with thaumaturgy code...
Posted: Sun Jul 04, 2010 5:51 am
by AnonymousHero
Have you tried playing around with different values to see what works reasonably? I'd like to make a change, but I don't really have time for playtesting ATM.
Re: Need some help with thaumaturgy code...
Posted: Mon Jul 05, 2010 4:37 am
by Lord Estraven
This works for me so far... From the contents of generate_spell():
Code: Select all
random_spell* rspell;
int dice, sides, chance, mana, power;
bool destruc_gen = FALSE;
bool simple_gen = TRUE;
bool ball_desc = FALSE;
if (spell_num == MAX_SPELLS) return;
rspell = &random_spells[spell_num];
power = rand_int(15);
/* make spells weaker at start */
dice = plev / 5;
sides = plev;
mana = plev;
/* Make the spell more or less powerful. */
dice += power;
sides += power ;
/* seriously reduce the mana involved */
mana += (plev * power) / 15;
/* Stay within reasonable bounds. */
if (dice < 1) dice = 1;
if (sides < 5) sides = 5;
if (mana < 1) mana = 1;
rspell->level = plev;
rspell->mana = mana;
rspell->untried = TRUE;
/* Spells are always maximally destructive. */
rspell->proj_flags = PROJECT_KILL | PROJECT_ITEM | PROJECT_GRID;
chance = randint(100);
/* Hack -- Always start with Magic Missile or derivative at lev. 1 */
if (plev == 1 || chance < 25)
{
rspell->proj_flags |= PROJECT_STOP;
/* swap dice and sides for better damage */
rspell->dam_dice = sides;
rspell->dam_sides = dice;
rspell->radius = 0;
}
else if (chance < 50)
{
rspell->proj_flags |= PROJECT_BEAM;
rspell->dam_dice = dice;
rspell->dam_sides = sides;
rspell->radius = 0;
}
else if (chance < 76)
{
rspell->proj_flags |= PROJECT_STOP;
rspell->radius = dice / 3;
rspell->dam_dice = dice;
rspell->dam_sides = sides;
ball_desc = TRUE;
}
else if (chance < 83)
{
rspell->proj_flags |= PROJECT_BLAST;
rspell->radius = sides / 3;
rspell->dam_dice = dice;
rspell->dam_sides = sides;
destruc_gen = TRUE;
simple_gen = FALSE;
}
else if (chance < 90)
{
rspell->proj_flags |= PROJECT_METEOR_SHOWER;
/* okay we need to make these way less powerful */
rspell->dam_dice = dice / 5;
rspell->dam_sides = sides / 5;
rspell->radius = sides / 3;
if (rspell->radius < 4) rspell->radius = 4;
destruc_gen = TRUE;
}
else
{
rspell->proj_flags |= PROJECT_VIEWABLE;
rspell->dam_dice = dice;
/* view spells should do less damage */
rspell->dam_sides = sides / 2;
}
Basically it:
- Removes the upper damage limits so bolt, ball, and beam spells can be more useful
- Makes the spells scale better in terms of damage vs. mana and vs. school spell damage while still being reasonably weak at the start
- Makes bolt spells somewhat more powerful than ball and beam spells
- Severely nerfs Area spells and much less severely nerfs LoS ones
It may be imperfect and perhaps a little biased towards excess player power, but I've tested it a bit and it seems to do the job.
Re: Need some help with thaumaturgy code...
Posted: Tue Jul 06, 2010 3:45 am
by Lom
How would you say the bolt/beam thaum spells compare to Manathrust from 2.3.5 now? Just so I can sort of get a comparison in my mind.

Re: Need some help with thaumaturgy code...
Posted: Thu Jul 08, 2010 1:35 am
by Lord Estraven
Probably roughly the same, maybe a bit weaker at high levels.
Re: Need some help with thaumaturgy code...
Posted: Thu Jul 15, 2010 6:50 am
by AnonymousHero
After a little playtesting (not at high level though), I have applied and pushed your changes to the ToME 2 git repo. Thanks.
Re: Need some help with thaumaturgy code...
Posted: Fri Jul 16, 2010 11:41 pm
by Lord Estraven
Yay! Thanks.
