Skip to content

Commit 3d11ff2

Browse files
committed
Revert "Miku: fix tainted miku not getting drops in vanilla rep+"
This reverts commit d803cb1.
1 parent 0be6441 commit 3d11ff2

2 files changed

Lines changed: 41 additions & 17 deletions

File tree

mod/metadata.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2+
<?xml-model href="https://wofsauge.github.io/isaac-xml-validator/xsd/metadata.xsd" ?>
23
<metadata>
3-
<id>3749427982</id>
44
<name>Hatsune Miku (+Tainted)</name>
55
<directory>isaac-miku</directory>
66
<description>A mod adding Hatsune Miku and more Vocaloid-inspired content to The Binding of Isaac.</description>

src/characters/Miku/MikuTaintedCharacter.ts

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
CollectibleType,
77
EffectVariant,
88
EntityCollisionClass,
9+
EntityFlag,
910
ModCallback,
1011
PickupVariant,
1112
PlayerVariant,
@@ -14,10 +15,11 @@ import {
1415
import type { PlayerIndex, SaveData } from "isaacscript-common";
1516
import {
1617
addCollectibleCostume,
17-
anyPlayerIs,
1818
Callback,
1919
CallbackCustom,
2020
getPlayerFromEntity,
21+
getPlayerFromIndex,
22+
getPlayerIndex,
2123
getPlayersOfType,
2224
getRandom,
2325
isActiveEnemy,
@@ -490,6 +492,10 @@ export class MikuTaintedCharacter extends Character {
490492
}
491493
}
492494

495+
if (!entity.HasEntityFlags(EntityFlag.NO_REWARD)) {
496+
this.npcLastHitPlayer.set(entity.InitSeed, getPlayerIndex(player));
497+
}
498+
493499
return true;
494500
}
495501

@@ -502,45 +508,58 @@ export class MikuTaintedCharacter extends Character {
502508
*/
503509
@Callback(ModCallback.POST_NPC_DEATH)
504510
override postNPCDeath(npc: EntityNPC): void {
505-
if (!anyPlayerIs(PlayerTypeCustom.MIKU_B) || !npc.IsEnemy()) {
511+
const lastHit = this.npcLastHitPlayer.get(npc.InitSeed);
512+
this.npcLastHitPlayer.delete(npc.InitSeed);
513+
514+
if (lastHit === undefined) {
506515
return;
507516
}
508517

509-
const unlocked = new Set<NotePickupSubType>();
510-
511-
for (const player of getPlayersOfType(PlayerTypeCustom.MIKU_B)) {
512-
const data = getData<TaintedMikuData>(player);
513-
for (const note of data.unlockedNotes ?? []) {
514-
unlocked.add(note);
515-
}
518+
const player = getPlayerFromIndex(lastHit);
519+
if (!player || !isMiku(player, true) || !npc.IsEnemy()) {
520+
return;
516521
}
517522

518-
const unlockedArray = [...unlocked];
519-
520-
print(unlockedArray);
523+
const playerData = getData<TaintedMikuData>(player);
524+
const unlocked = playerData.unlockedNotes ?? [];
521525

522526
const baseNotes = Object.values(NotePickupSubType).filter(
523527
(v): v is NotePickupSubType =>
524528
typeof v === "number" && NOTE_TYPE_DATA[v].weight > 0,
525529
);
526530

527-
const noteSubTypes = [
531+
const noteSubTypes: NotePickupSubType[] = [
528532
...baseNotes,
529-
...unlockedArray.filter((n) => !baseNotes.includes(n)),
533+
...unlocked.filter((n) => !baseNotes.includes(n)),
530534
];
531535

532536
const weights = noteSubTypes.map((s) =>
533-
unlockedArray.includes(s) ? 2 : NOTE_TYPE_DATA[s].weight,
537+
unlocked.includes(s) ? 2 : NOTE_TYPE_DATA[s].weight,
538+
);
539+
540+
print(
541+
`POOL: ${noteSubTypes.map((s) => NOTE_TYPE_DATA[s].name).join(", ")}`,
534542
);
535543

544+
print(`WEIGHTS: ${weights.join(", ")}`);
545+
536546
const note = rollWeighted(
537547
noteSubTypes,
538548
weights,
539549
npc.GetDropRNG(),
540550
NOTE_DROP_CHANCE,
541551
);
542552

543-
if (note !== undefined) {
553+
Debugger.rng(
554+
"NoteDrop",
555+
`Rolled note for NPC ${npc.Type}_${npc.Variant}: ${
556+
note === undefined ? "None" : NOTE_TYPE_DATA[note].name
557+
}`,
558+
);
559+
560+
if (note === undefined) {
561+
/* empty */
562+
} else {
544563
spawnNotePickup(note, npc.Position);
545564
}
546565
}
@@ -615,5 +634,10 @@ export class MikuTaintedCharacter extends Character {
615634
`${NAME} (Tainted)`,
616635
"Add description and birthright description.",
617636
);
637+
638+
/* eid.addCollectible(
639+
CollectibleType.BRIMSTONE,
640+
"↓ {{Tears}} x0.33 Fire rate multiplier#{{Chargeable}} Isaac's tears are replaced by a chargeable blood beam#{{Damage}} It deals 9x Isaac's damage over 0.63 seconds#{{ColorGray}}Tainted Miku:#{{Warning}} Brimstone Notes will now drop",
641+
); */
618642
}
619643
}

0 commit comments

Comments
 (0)