Steal An EggDocumentation← Portfolio

#Fusion

#What fusion does

Fusion consumes three identical pets and returns one pet: usually the same species with inherited weight, sometimes an upgrade to a stronger species of the same biome.

FusionService.fuse(player, uids) is the only entry point. It is reached through the Fusion machine in the world (the fusion action on the remote) and gated by three checks before anything is consumed.

#Inputs

RequirementValue
Pets per fusion3 (Config.Fusion.INPUT_COUNT)
SpeciesAll three must share a catalogId
OwnershipAll three must exist in profile.pets
PlacementNone may be placed in the base
StateNone may already be reserved by another fusion
Cooldown1.5 seconds between fusions (Config.Fusion.COOLDOWN)
ConcurrencyOne fusion at a time per player (busy flag)

Every failure path returns a chat message instead of silently dropping items, and the whole roll runs inside pcall — if anything errors, the pets are restored to inventory and the player is told nothing was lost.

#The upgrade roll

chance = Config.Fusion.UPGRADE_CHANCE[rarity] or 0
Input rarityUpgrade chance
Common0.55
Uncommon0.50
Rare0.45
Epic0.38
Legendary0.30
Mythic0.24
Cosmic0.18
Secret0.12
Eternal0.08
Divine0 (no upgrade possible)

When the roll succeeds, upgradeCandidates builds the candidate list from the same biome and the same source, keeping only rarer pets, and weights each by 1 / (rankDifference). That makes the next rarity tier far more likely than a jump of several tiers.

#Weight and mutation inheritance

SettingValueEffect
WEIGHT_INHERIT0.85Average input multiplier is scaled down before the result is built
WEIGHT_BONUS1.35Then scaled back up — the net effect is that fusing beats selling
MUTATION_INHERIT_CHANCE0.550% chance to inherit the best input mutation, otherwise a fresh natural roll
avgMul  = mean(pet.weight / pet.baseWeight)
newMul  = avgMul × 0.85 × 1.35
mutation = bestMutation(inputs)   -- with probability 0.5
         | rollNaturalMutation()  -- otherwise

The result is created through MutationService.createPet, so its income is recomputed from weight, size bucket and mutation exactly like a hatched pet. stats.totalFused is incremented, stats.bestIncome is updated if the result is a personal best, and IndexService.register runs so an upgraded species counts as a new discovery.

#Reading a fusion result

The client receives fusionResult with uid, catalogId, name, rarity, mutation, weight, income and an upgraded flag. upgraded is simply newPet.catalogId ~= catalogId — it is what distinguishes "same pet, stronger" from "you rolled the upgrade".

#Practical notes

  • Because the upgrade pool is restricted to the same biome and the same source, a fusion can never leap into another biome's pet list.
  • Divine inputs cannot upgrade; fusing them is only worth it for weight and mutation inheritance.
  • Placed pets must be picked up before they can be fused — the UI rejects the action with "Pick the pet up from your base before fusing."
  • FusionService.cleanup(player) clears the busy flag and cooldown on leave so a disconnect mid-fusion cannot lock the player out.