Welcome to the Builder Academy

Question Protection from Evil, lets have it do something!

More
09 Aug 2012 22:09 #618 by bakarus
Below is the snippet to make Protection from Evil a spell that actually does something, optionally you can add in the protection from good spell included, since stock tba comes with the flag for protection from good, but doesn't use it.
Code:
Snippet for Protection from Evil spell After noticing that in stock tba this spell is there, but does nothing I was inspired to make it actually affect something, with this snippet it makes Protection From Evil give the attacker a detriment to his thaco roll and a bonus to the victims ac if the victim is flagged with the AFF_PROTECT_EVIL. I did not add a check to the protection from evil spell to keep evil aligned players from casting it nor did I do the same to protection from good. This I would leave up to you. Optional: Since stock tba comes with an AFF_PROTECT_GOOD flag, you can add the protection from good spell at the bottom of this snippet. Disclaimer: as always if you've customized your code then the below might not be entirely cut/paste-able. in fight.c, inside the Hit() function look for these lines: /* Calculate chance of hit. Lower THAC0 is better for attacker. */ calc_thaco = compute_thaco(ch, victim); below that add: + // check to see if the victim has prot from evil on, and if the attacker is in fact evil + // and detriment the attackers thaco roll if both are true + if(AFF_FLAGGED(victim, AFF_PROTECT_EVIL) && (GET_ALIGNMENT(ch) < -350)) + { calc_thaco = calc_thaco + 2; } // this is optional if you decide to add the protection from good spell below + // check to see if victim has protection from good on, and if the attacker is in fact good + // add detriment to the attackers thaco roll if both are true + if(AFF_FLAGGED(victim, AFF_PROTECT_GOOD) && (GET_ALIGNMENT(ch) > 350)) + { calc_thaco = calc_thaco + 2; } just below that look for this line: /* Calculate the raw armor including magic armor. Lower AC is better for defender. */ victim_ac = compute_armor_class(victim) / 10; and below that add: + // check to see if victim is flagged with protection from evil, and if the attacker is evil + // and improve the victims armor if both are true + if(AFF_FLAGGED(victim, AFF_PROTECT_EVIL) && (GET_ALIGNMENT(ch) < -350)) + { victim_ac = victim_ac - 1; } // this is optional if you decide to add the protection from good spell below + // check to see if victim is flagged with protection from good, and if the attacker is good + // and improve the victims armor if both are true + if(AFF_FLAGGED(victim, AFF_PROTECT_GOOD) && (GET_ALIGNMENT(ch) > 350)) + { victim_ac = victim_ac - 1; } if you like to add a protection from good spell, since the flag AFF_PROTECT_GOOD already exists in stock tba keep going below here in spell_parser.c look for: spello(SPELL_PROT_FROM_EVIL, "protection from evil", 40, 10, 3, POS_STANDING, TAR_CHAR_ROOM | TAR_SELF_ONLY, FALSE, MAG_AFFECTS, "You feel less protected."); below that add: + spello(SPELL_PROT_FROM_GOOD, "protection from good", 40, 10, 3, POS_STANDING, + TAR_CHAR_ROOM | TAR_SELF_ONLY, FALSE, MAG_AFFECTS, + "You feel less protected."); in magic.c look for: case SPELL_PROT_FROM_EVIL: af[0].duration = 24; SET_BIT_AR(af[0].bitvector, AFF_PROTECT_EVIL); accum_duration = TRUE; to_vict = "You feel invulnerable!"; break; after that break, add this: +case SPELL_PROT_FROM_GOOD: + af[0].duration = 24; + SET_BIT_AR(af[0].bitvector, AFF_PROTECT_GOOD); + accum_duration = true; + to_vict = "You feel invulnerable!"; + break; in class.c look for: spell_level(SPELL_PROT_FROM_EVIL, CLASS_CLERIC, 8); below that add this: + spell_level(SPELL_PROT_FROM_GOOD, CLASS_CLERIC, 8); in spells.h look for: #define SPELL_FLY 53 /* Reserved Skill[] DO NOT CHANGE */ below that add this: + #define SPELL_PROT_FROM_GOOD 54 /* protection from good */ below that update your total spells from 53 to 54 -#define NUM_SPELLS 53 +#define NUM_SPELLS 54

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

More
10 Aug 2012 07:55 #625 by zusuk
Epic!! After like 9834 years of Circle's existence, finally someone fills the gap!

Kudos man

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

Time to create page: 0.185 seconds