Jump to content
  • 0
kaeyih

Modification over 100% Element resist behavior

Question

I have a Pre re server with 4 slotted cards. I would like to modify the Element DEF Formula in the source so that..

1) wearer of more than 100% Element resist will remained heal when get hit by Monster's damage. (negative damage)
2) wearer of more than 100% Element resist will not get healed in PVP, would prefer as a null or a miss. 



I have been searching around for answers.. Would appreciate it someone can help me on solving this. 
I know its somewhere in battle.c but i really dont know how to modify it. 

 

{{Previous are attack part, u can refer to map/battle.c 

@@ line 864  Affected by target DEF bonuses

	// Affected by target DEF bonuses
			else if( tsd && !nk[NK_IGNOREDEFCARD] && !(left&2) ) {
				if( !nk[NK_IGNOREELEMENT] ) { // Affected by Element modifier bonuses
					int ele_fix = tsd->subele[rh_ele] + tsd->subele[ELE_ALL] + tsd->subele_script[rh_ele] + tsd->subele_script[ELE_ALL];

					for (const auto &it : tsd->subele2) {
						if (it.ele != rh_ele)
							continue;
						if (!(((it.flag)&flag)&BF_WEAPONMASK &&
							((it.flag)&flag)&BF_RANGEMASK &&
							((it.flag)&flag)&BF_SKILLMASK))
							continue;
						ele_fix += it.rate;
					}
					cardfix = cardfix * (100 - ele_fix) / 100;

					if( left&1 && lh_ele != rh_ele ) {
						int ele_fix_lh = tsd->subele[lh_ele] + tsd->subele[ELE_ALL] + tsd->subele_script[lh_ele] + tsd->subele_script[ELE_ALL];

						for (const auto &it : tsd->subele2) {
							if (it.ele != lh_ele)
								continue;
							if (!(((it.flag)&flag)&BF_WEAPONMASK &&
								((it.flag)&flag)&BF_RANGEMASK &&
								((it.flag)&flag)&BF_SKILLMASK))
								continue;
							ele_fix_lh += it.rate;
						}
						cardfix = cardfix * (100 - ele_fix_lh) / 100;
					}

					cardfix = cardfix * (100 - tsd->subdefele[s_defele] - tsd->subdefele[ELE_ALL]) / 100;
				}
				cardfix = cardfix * (100 - tsd->subsize[sstatus->size] - tsd->subsize[SZ_ALL]) / 100;
				cardfix = cardfix * (100 - tsd->subrace2[s_race2]) / 100;
				cardfix = cardfix * (100 - tsd->subrace[sstatus->race] - tsd->subrace[RC_ALL]) / 100;
				cardfix = cardfix * (100 - tsd->subclass[sstatus->class_] - tsd->subclass[CLASS_ALL]) / 100;
				for (const auto &it : tsd->add_def) {
					if (it.id == s_class) {
						cardfix = cardfix * (100 - it.val) / 100;
						break;
					}
				}
				if( flag&BF_SHORT )
					cardfix = cardfix * (100 - tsd->bonus.near_attack_def_rate) / 100;
				else	// BF_LONG (there's no other choice)
					cardfix = cardfix * (100 - tsd->bonus.long_attack_def_rate) / 100;
				if( tsd->sc.data[SC_DEF_RATE] )
					cardfix = cardfix * (100 - tsd->sc.data[SC_DEF_RATE]->val1) / 100;
				APPLY_CARDFIX(damage, cardfix);
			}
			break;

		case BF_MISC:
			// Affected by target DEF bonuses
			if( tsd && !nk[NK_IGNOREDEFCARD] ) {
				if( !nk[NK_IGNOREELEMENT] ) { // Affected by Element modifier bonuses
					int ele_fix = tsd->subele[rh_ele] + tsd->subele[ELE_ALL] + tsd->subele_script[rh_ele] + tsd->subele_script[ELE_ALL];

					for (const auto &it : tsd->subele2) {
						if (it.ele != rh_ele)
							continue;
						if (!(((it.flag)&flag)&BF_WEAPONMASK &&
							((it.flag)&flag)&BF_RANGEMASK &&
							((it.flag)&flag)&BF_SKILLMASK))
							continue;
						ele_fix += it.rate;
					}
					if (s_defele != ELE_NONE)
						ele_fix += tsd->subdefele[s_defele] + tsd->subdefele[ELE_ALL];
					cardfix = cardfix * (100 - ele_fix) / 100;
				}
				cardfix = cardfix * (100 - tsd->subsize[sstatus->size] - tsd->subsize[SZ_ALL]) / 100;
				cardfix = cardfix * (100 - tsd->subrace2[s_race2]) / 100;
				cardfix = cardfix * (100 - tsd->subrace[sstatus->race] - tsd->subrace[RC_ALL]) / 100;
				cardfix = cardfix * (100 - tsd->subclass[sstatus->class_] - tsd->subclass[CLASS_ALL]) / 100;
				cardfix = cardfix * (100 - tsd->bonus.misc_def_rate) / 100;
				if( flag&BF_SHORT )
					cardfix = cardfix * (100 - tsd->bonus.near_attack_def_rate) / 100;
				else	// BF_LONG (there's no other choice)
					cardfix = cardfix * (100 - tsd->bonus.long_attack_def_rate) / 100;
				APPLY_CARDFIX(damage, cardfix);
			}
			break;
	}

#undef APPLY_CARDFIX

	return (int)cap_value(damage - original_damage, INT_MIN, INT_MAX);
}

 

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.