(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?
Moderator: Moderator
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;
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.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?
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;
}
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;
}