Welcome to the Builder Academy

Question Permanent racial spells using race snippet which posted by Liko

More
30 Apr 2014 17:44 - 08 May 2014 02:48 #4887 by Coffee

Attachment tbaMUD-Permanent-Racial-Spells.txt not found



- Open spells.h and change void mag_affects(int level, struct char_data *ch, struct char_data *victim, int spellnum, int savetype) to void mag_affects(int level, struct char_data *ch, struct char_data *victim, int spellnum, int savetype, int race);

- Open act.other.c, look for ACMD(do_save); add apply_racial_ability(ch); below save_char(ch); and above Crash_crashsave(ch);


- Open up your race.c and add the following at the end of race_menu and right above int parse_race(char arg).

/*
* Permanent racial spells; currently set to maximam of 4 per race.
* The example below gives zero racial spells to Humans, Detect Magic
* for Elves and Infravision for Dwarves. Modify them as you see fit
* accordance with your own tbaMUD.
*/
int race_innate[4][NUM_RACES] = {
/* Human Elf Dwarf */
{ 0, SPELL_DETECT_MAGIC, SPELL_INFRAVISION }, /* Racial 1 */
{ 0, 0, 0 }, /* Racial 2 */
{ 0, 0, 0 }, /* Racial 3 */
{ 0, 0, 0 } /* Racial 4 */
};

- Add the follow to the end of the file
/* call mag_affects from magic.c to apply permanent racial spells */
void apply_racial_ability(struct char_data *ch)
{
int rinnate = 0;

for (rinnate = 0; rinnate < 4; rinnate++) {
if (race_innate[rinnate][GET_RACE(ch)] != 0)
mag_affects(GET_LEVEL(ch), ch, ch, race_innate[rinnate][GET_RACE(ch)], CAST_SPELL, 1);
}

}

- Open up race.h and add the following code below int invalid_race(struct char_data *ch, struct obj_data *obj).
void apply_racial_ability(struct char_data *ch);

- Open interpreter.c and scroll down to void nanny(struct descriptor_data *d, char *arg). Search for case '1': and you will see STATE(d) = CON_PLAYING; follow by MXPSendTag( d, "<VERSION>" ); and if statement of if (GET_LEVEL(d->character) == 0) {. At the end of that if statement, add apply_racial_ability(d->character);

- Open up spell_parser.c and find mag_affects(level, caster, cvict, spellnum, savetype); and change it to mag_affects(level, caster, cvict, spellnum, savetype, race);

- Open up magic.c and change mag_affects(level, ch, tch, SPELL_ARMOR, savetype); to mag_affects(level, ch, tch, SPELL_ARMOR, savetype, 0); at the function static void perform_mag_groups(int level, struct char_data *ch, struct char_data *tch, int spellnum, int savetype).

Change void mag_affects(int level, struct char_data *ch, struct char_data *victim,int spellnum, int savetype) to mag_affects(int level, struct char_data *ch, struct char_data *victim,int spellnum, int savetype, int race)

In the mag_affects function, we will have to change the durations and accum_durations values base on racial status. The following cases are the one I have modified on my copy of tbaMUD.

case SPELL_ARMOR:
af[0].location = APPLY_AC;
af[0].modifier = -20;
if (race == 1) {
af[0].duration = -1;
accum_duration = FALSE;
}
else {
af[0].duration = 24;
accum_duration = TRUE;
}

to_vict = "You feel someone protecting you.";
break;

case SPELL_BLESS:
af[0].location = APPLY_HITROLL;
af[0].modifier = 2;
if (race == 1)
af[0].duration = -1;
else
af[0].duration = 6;

af[1].location = APPLY_SAVING_SPELL;
af[1].modifier = -1;
if (race == 1)
af[1].duration = FALSE;
else
af[1].duration = 6;

if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
to_vict = "You feel righteous.";
break;

case SPELL_DETECT_ALIGN:
if (race == 1)
af[0].duration = -1;
else
af[0].duration = 12 + level;
SET_BIT_AR(af[0].bitvector, AFF_DETECT_ALIGN);
if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
to_vict = "Your eyes tingle.";
break;

case SPELL_DETECT_INVIS:
if (race == 1)
af[0].duration = -1;
else
af[0].duration = 12 + level;
SET_BIT_AR(af[0].bitvector, AFF_DETECT_INVIS);
if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
to_vict = "Your eyes tingle.";
break;

case SPELL_DETECT_MAGIC:
if (race == 1)
af[0].duration = -1;
else
af[0].duration = 12 + level;
SET_BIT_AR(af[0].bitvector, AFF_DETECT_MAGIC);
if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
to_vict = "Your eyes tingle.";
break;

case SPELL_FLY:
if (race == 1)
af[0].duration = -1;
else
af[0].duration = 24;
SET_BIT_AR(af[0].bitvector, AFF_FLYING);
if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
to_vict = "You float above the ground.";
break;

case SPELL_INFRAVISION:
if (race == 1)
af[0].duration = -1;
else
af[0].duration = 12 + level;
SET_BIT_AR(af[0].bitvector, AFF_INFRAVISION);
if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
to_vict = "Your eyes glow red.";
to_room = "$n's eyes glow red.";
break;

case SPELL_INVISIBLE:
if (!victim)
victim = ch;

if (race == 1)
af[0].duration = -1;
else
af[0].duration = 12 + (GET_LEVEL(ch) / 4);
af[0].modifier = -40;
af[0].location = APPLY_AC;
SET_BIT_AR(af[0].bitvector, AFF_INVISIBLE);
if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
to_vict = "You vanish.";
to_room = "$n slowly fades out of existence.";
break;

case SPELL_PROT_FROM_EVIL:
if (race == 1)
af[0].duration = -1;
else
af[0].duration = 24;
SET_BIT_AR(af[0].bitvector, AFF_PROTECT_EVIL);
if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
to_vict = "You feel invulnerable!";
break;

case SPELL_SENSE_LIFE:
to_vict = "Your feel your awareness improve.";
if (race == 1)
af[0].duration = -1;
else
af[0].duration = GET_LEVEL(ch);
SET_BIT_AR(af[0].bitvector, AFF_SENSE_LIFE);
if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
break;

case SPELL_WATERWALK:
if (race == 1)
af[0].duration = -1;
else
af[0].duration = 24;
SET_BIT_AR(af[0].bitvector, AFF_WATERWALK);
if (race == 1)
accum_duration = FALSE;
else
accum_duration = TRUE;
to_vict = "You feel webbing between your toes.";
break;

After adding these modification, when you login next time to your mud; your character should be affected by the spells based on race_innate table. Thank you Liko for the race code =).
Attachments:
Last edit: 08 May 2014 02:48 by Coffee.

Please Log in or Create an account to join the conversation.

More
08 May 2014 00:47 #4891 by Liko
You should add this to .txt file and upload it to the snippets part of the site. :) Great addition to the bare-bones race code. I didn't want to add to much because I felt that each much would use races differently.

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
11 May 2014 00:42 #4893 by Coffee
in the text file there is a section which looks like this
interpreter.c
- search for void nanny(struct descriptor_data *d, char *arg), within that function also search for
look_at_room(d->character, 0); which is a part of case '1': section. add apply_racial_ability(d->character);
right above apply_racial_ability(d->character);
- save and close interpreter.c

but, this is a correct one
interpreter.c
- search for void nanny(struct descriptor_data *d, char *arg), within that function also search for
look_at_room(d->character, 0); which is a part of case '1': section. add apply_racial_ability(d->character);
right above look_at_room(d->character, 0);
- save and close interpreter.c

Please Log in or Create an account to join the conversation.

Time to create page: 0.341 seconds