Skip to content

Allow inheritance of ability, item, and move conditions#11754

Open
andrebastosdias wants to merge 2 commits intosmogon:masterfrom
andrebastosdias:conditions-inheritance
Open

Allow inheritance of ability, item, and move conditions#11754
andrebastosdias wants to merge 2 commits intosmogon:masterfrom
andrebastosdias:conditions-inheritance

Conversation

@andrebastosdias
Copy link
Collaborator

@andrebastosdias andrebastosdias commented Feb 9, 2026

An extra fix I made was adding the minimize flag to moves that deal double damage to minimized targets, so the condition doesn't need to be overwritten every generation.

I removed Gen 3 implementation of basePowerCallback for moves that affect Minimize. In reality, they should be implemented in ModifyDamagePhase2 (very late), but Gen 2 doesn't even implement this event yet. For now, I've left them in ModifyDamage, since Generations 1–4 need a damage formula review anyway.


Note: one important thing to confirm is that all conditions with inherit: true must be attached to effects that also have inherit: true. Otherwise, it is redundant.

Note 2: In the second commit, I went through all the effects that didn't have inherit: true, meaning they were essentially reimplementing the ability from scratch inside the mod. For some of them, there was literally no reason not to inherit. For others, while it could go either way, I switched to inheritance because it makes it easier to understand why the ability is being overridden in the mod.

It is probably easier to review the two commits separably.

@Slayer95
Copy link
Collaborator

Slayer95 commented Feb 20, 2026

I was worried about (yet another) delete in the loader, but measurements seem to show that the uglier delete-less alternative doesn't result in that much better load time (nb. I haven't really run statistical analysis on this data - if interested, average = average time per entry with inherit:true ; total = sum of all loadData() operations; all times are in μs).
loader-times-no-delete.log
loader-times-delete.log

no-delete alternative
loadInheritedEntryNew(entryId: string, parentTypedData: DexTable<any>, childTypedData: DexTable<any>) {
		// {inherit: true} can be used to modify only parts of the parent data,
		// instead of overwriting entirely
		const rawChild = childTypedData[entryId];
		const childEntry = { ...parentTypedData[entryId] };

		// Merge parent and child's entry, with child overwriting parent.
		for (const key in rawChild) {
			if (key === 'inherit') continue;
			if (key === 'condition' && rawChild['condition']?.inherit) {
				// 2026 - {inherit: true} can now also be used to inherit parts of conditions
				const rawCondition = { ...parentTypedData[entryId].condition };
				for (const conditionKey in rawChild['condition']) {
					if (conditionKey === 'inherit') continue;
					rawCondition[conditionKey] = rawChild['condition'][conditionKey];
				}
				childEntry['condition'] = rawCondition;
			} else {
				childEntry[key] = rawChild[key];
			}
		}

		childTypedData[entryId] = childEntry;
	}

@urkerab
Copy link
Contributor

urkerab commented Feb 20, 2026

(FWIW I've been using some somewhat more generic code on ROM for a similar effect: urkerab@6d16206#diff-f54c25b24aeda6549b5d0ab7749fa5f925e1ab3bf9e23404eee1a7ff09fe49f6L532)

@andrebastosdias
Copy link
Collaborator Author

@Slayer95 Did you skim through all the changes?

@Slayer95
Copy link
Collaborator

@Slayer95 Did you skim through all the changes?

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants