Fruit Tree
Forest special encounter where you find a ripe fruit tree and automatically eat the fruit. Random tree type: Peach (50%), Pear (25%), or Apple (25%). 60% chance of outcome: Gain 10% current HP but two annoying fly buffs follow you (Fruit Fly: defmod 0.9 × 40 rounds, Annoying Fly: atkmod 0.9 × 50 rounds). 40% chance: Gain 10% current HP with no downside. No choices, automatic trigger. Simple passive forest event with risk/reward balance. Where you stumble upon a wonderful-looking fruit tree, can't resist temptation, eat several fruits, and then discover that a 60% chance of flies buzzing around you for the next 40-50 combat rounds is nature's way of saying "there's no such thing as a free lunch, even when it's literally free fruit."
Encounter Location
Where:
- Forest special event
- Triggers during forest fights (forest.php)
- Random encounter (no specific forest location)
Encounter Chance:
- Event weight: 100
- Very rare encounter (competes with other forest events)
- No VE scaling (static weight)
- No daily limit (can encounter multiple times per day)
The Encounter
Initial Scene:
- "You come upon a wonderful looking [Peach/Pear/Apple] tree."
- ".which has fruit that is ready for picking!"
- Tree type: Random (50% Peach, 25% Pear, 25% Apple)
- Fruit is ripe and tempting
- No choice offered - automatic outcome
Your Response:
- "Not resisting temptation."
- ".you pick and eat several [fruit type]s for yourself."
- Automatic action (can't refuse)
- Eat multiple fruits (not just one)
Outcome 1: HP + Annoying Flies (60% chance)
What Happens:
- "You feel refreshed."
- ".however you notice some annoying flies which have taken a liking to you."
- "You try to swat away the annoying flies."
- ".`b`i but now they follow you! `i`b"
- Two fly buffs applied simultaneously
HP Gain:
- Gain 10% of current HP (rounded)
- Formula: $gain = $session['user']['hitpoints'] * 0.1
- Example: 100 HP → gain 10 HP = 110 HP
- Example: 50 HP → gain 5 HP = 55 HP
- Scales with current HP (not max HP)
- Can exceed max HP temporarily
Fruit Fly Buff (Defensive Penalty):
- Name: "`#Fruit Fly"
- Duration: 40 combat rounds
- Effect: defmod 0.9 (10% defense reduction)
- atkmod: 1.0 (no attack change)
- Round message: "`7A `#Fruit Fly `7is hovering around while you try to fight."
- Wearoff: "The Fruit Fly is no longer bothering you."
- Schema: module-fruittree
Annoying Fly Buff (Offensive Penalty):
- Name: "`@Annoying Fly"
- Duration: 50 combat rounds
- Effect: atkmod 0.9 (10% attack reduction)
- defmod: 1.0 (no defense change)
- Round message: "`7An `@Annoying Fly `7is buzzzzing around, making your fight less effective."
- Wearoff: "You swat the Annoying Fly to the ground and step on it!"
- Schema: module-fruittree
Combined Effect:
- Both buffs active simultaneously
- 10% attack reduction (atkmod 0.9)
- 10% defense reduction (defmod 0.9)
- Duration: 40 rounds (Fruit Fly) and 50 rounds (Annoying Fly)
- After 40 rounds: Only Annoying Fly remains (atkmod 0.9)
- After 50 rounds: All flies gone
- Significant combat penalty for extended period
Outcome 2: HP Only, No Flies (40% chance)
What Happens:
- "You feel really refreshed!"
- No mention of flies
- No buffs applied
- Pure positive outcome
HP Gain:
- Conditional: Only if below max HP
- If hitpoints < maxhitpoints: Gain 10% current HP
- Same formula: 10% of current HP (not max HP)
- Message: "`6 You gain a few hitpoints!"
- No penalty, no downside
If Already at Max HP:
- No HP gain (already full)
- Just feel refreshed (flavor only)
- Still no flies (lucky outcome)
Probability Analysis
Outcome Distribution:
- Code: $rand = e_rand(1,100); if ($rand <= $chance) where $chance = 60
- 60% chance: HP + Fly buffs (rolls 1-60)
- 40% chance: HP only, no flies (rolls 61-100)
Expected Value:
- HP gain: Always 10% current HP (both outcomes, mostly)
- 60% chance: Combat penalty (atkmod 0.9, defmod 0.9 × 40-50 rounds)
- 40% chance: No penalty
- Net: You always get HP, but 60% chance you pay for it with flies
Combat Penalty Impact:
- atkmod 0.9 = 10% less damage dealt (longer fights)
- defmod 0.9 = 10% less damage mitigated (take more damage)
- Over 40 rounds: Significant HP/resource loss from weaker combat
- Example: If you do 100 damage normally, now do 90 damage (10 extra rounds to kill same enemy over 100 fights)
- Example: If enemy does 50 damage to you, now does ~55 damage (5 extra HP loss per fight)
- Penalty can easily exceed the 10% HP gain if you fight 40+ times before flies wear off
Strategic Value
Positive Aspects:
- Immediate HP gain (10% current HP)
- No cost (free healing)
- 40% chance of pure positive outcome
- Can push above max HP temporarily
Negative Aspects:
- 60% chance of fly buffs (combat penalty)
- 10% attack reduction for 50 rounds
- 10% defense reduction for 40 rounds
- Combined 20% combat effectiveness reduction for 40 rounds
- Penalty lasts long enough to affect many fights
- Can't refuse or avoid (automatic trigger)
Is It Worth It?:
- Probably not at 60% fly chance
- 10% HP gain is modest (worth ~10-20 gold in healing)
- 40-50 rounds of combat penalty likely exceeds HP value
- Each weakened fight takes more HP/time/resources
- Over 40+ fights, 10% effectiveness loss >> 10% HP gain
When It's Good:
- You're critically low on HP and need immediate healing
- You're about to leave forest (won't fight many more rounds)
- You get lucky 40% outcome (HP with no flies)
- You roll low on fight count before flies wear off naturally
Fruit Tree Types
Tree Type Distribution:
- Code: $randx=e_rand(1,4); if ($randx==1 or 4){ $tree=$a;} (Peach)
- Note: "or 4" in PHP always evaluates to true, so this is a bug
- Actual distribution:
- Case 1: Peach (25%)
- Case 2: Pear (25%)
- Case 3: Apple (25%)
- Case 4: Defaults to Peach due to bug (25%)
- Result: 50% Peach, 25% Pear, 25% Apple
Fruit Type Effects:
- Peach ("`qPeach"): 50% chance
- Pear ("`6Pear"): 25% chance
- Apple ("`@Apple"): 25% chance
- No mechanical difference: Only flavor text varies
- Outcome (HP + flies vs HP only) independent of fruit type
Why Fruit Type Doesn't Matter:
- Fruit type rolled separately from outcome
- $randx (fruit type) and $rand (outcome) independent variables
- Peach, Pear, Apple all have same 60/40 split for flies vs no flies
- Purely cosmetic variation
Buff Duration & Combat Impact
Rounds Calculation:
- 40-50 rounds = 40-50 forest fights
- Typical forest session: 10-20 fights per day (varies by player)
- Flies last 2-5 days of normal forest activity
- Or single long session if you chain many fights
Cumulative Damage:
- Example: 40 fights at 10% reduced effectiveness
- Assume normal fight: 100 damage dealt, 50 damage taken
- With flies: 90 damage dealt (-10), 55 damage taken (+5)
- Per fight: -10 damage output, +5 damage input
- Over 40 fights: 400 less damage dealt, 200 more damage taken
- Net: Significantly worse combat performance
- Original gain: ~10 HP (one-time)
- Cumulative loss: 200 extra HP taken + longer fights (resource drain)
Why Buffs Are Punishing:
- Long duration (40-50 rounds) affects many fights
- Dual penalty (attack AND defense) compounds problem
- Can't remove buffs early (must wait for wearoff)
- Small HP gain doesn't offset extended combat weakness
No Player Agency
Automatic Trigger:
- Event fires → automatically eat fruit
- No "Do you want to eat the fruit?" choice
- No "Walk away" option
- Outcome immediate and unavoidable
Why This Matters:
- Can't optimize based on current situation
- Can't refuse if you're full HP (wasted healing)
- Can't avoid if you're about to dragon fight (penalty during boss)
- Can't choose "only eat if no flies" outcome
- Pure RNG with no player skill/decision factor
Design Implication:
- Simple random event (low complexity)
- Passive forest flavor (not strategic choice)
- Fits "stumble upon something" forest event pattern
- Trade-off: Simplicity vs player control
Comparison to Other HP Sources
Fruit Tree vs Healer:
- Fruit Tree: Free, 10% current HP, 60% chance of 40-50 round combat penalty
- Healer: Costs 1 gold per HP, guaranteed healing, no penalty
- At 100 HP: Fruit tree = ~10 HP (worth ~10 gold), 60% chance of flies
- Healer more reliable and penalty-free
- Fruit tree only valuable if you get lucky 40% outcome
Fruit Tree vs Other Forest Events:
- Most forest events offer choices (this one doesn't)
- Most events balanced risk/reward (this one heavily penalizes 60% of outcomes)
- Fruit Tree one of less desirable random forest events
Lore & Flavor
The Temptation:
- "Not resisting temptation" - you can't help yourself
- Ripe fruit too appealing to ignore
- Eat "several" fruits (greedy consumption)
- Immediate gratification (HP gain)
- Delayed consequence (flies follow you)
The Flies:
- Fruit attracts fruit flies (realistic detail)
- You tried to swat them away (failed)
- "but now they follow you!" (consequence of eating fruit)
- Two types: Fruit Fly (defensive penalty) and Annoying Fly (offensive penalty)
- Buzzzzzing sound (annoying atmosphere)
- Eventually you step on Annoying Fly (satisfying conclusion)
Environmental Realism:
- Fruit in forest attracts insects (nature logic)
- Eating sugary fruit makes you smell sweet (attracts more flies)
- Flies buzzing around during combat = distraction
- Can't concentrate on fighting when swatting flies
- Realistic consequence of free food in wilderness
Technical Details
Event Integration:
- module_addeventhook("forest","return 100;")
- Weight: 100 (standard forest event weight)
- No test function (always 100 when event fires)
Buff Implementation:
- apply_buff('ffly', $ffly) for Fruit Fly
- apply_buff('afly', $afly) for Annoying Fly
- Both buffs applied in same event trigger
- Schema: "module-fruittree" for both
HP Calculation Bug/Feature:
- Formula: $gain = $session['user']['hitpoints'] * 0.1
- Uses current HP, not max HP
- If you're at 50% HP: Gain 5% max HP (not 10% max HP)
- Reward scales DOWN as you get more injured
- Counterintuitive: Less healing when you need it most
- Likely intended to use maxhitpoints instead
Probability Bug:
- Code: if ($randx==1 or 4)
- "or 4" evaluates to true (PHP interprets as "or TRUE")
- Should be: if ($randx==1 || $randx==4)
- Result: Peach appears 50% instead of 25%
- Doesn't affect gameplay (cosmetic only)
Limitations & Issues
- No player choice: Automatic trigger, can't refuse fruit
- Unfavorable odds: 60% chance of extended combat penalty
- Punishment > Reward: 40-50 rounds of 10% effectiveness loss likely exceeds 10% HP gain value
- HP calculation: Uses current HP instead of max HP (scales down when injured)
- Long buff duration: 40-50 rounds affects multiple play sessions
- Code bug: Fruit type distribution (50% Peach instead of 25%, cosmetic only)
Fruit Tree: where you stumble upon a wonderful-looking fruit tree with ripe Peaches (50%), Pears (25%), or Apples (25%), can't resist temptation, automatically eat several fruits without any choice in the matter, gain 10% of your CURRENT HP (not max HP, which means if you're badly injured you get even less healing), and then there's a 60% chance that annoying flies have taken a liking to you and will follow you around for the next 40-50 combat rounds reducing your attack by 10% and defense by 10% simultaneously. The expected value is terrible: you gain ~10 HP one time but lose 10% combat effectiveness over 40+ fights which translates to hundreds of extra HP taken and longer fights, making this one of the worst "rewards" in the forest event pool. The 40% chance of getting HP with no flies is nice, but not enough to offset the 60% chance of spending the next 2-5 days of forest activity swatting at buzzing insects while trying to fight creatures. There's no player agency (you automatically eat the fruit, can't refuse), the HP calculation uses current HP instead of max HP (probably a bug, means you get less healing when you need it most), and the fruit type distribution is bugged so Peaches appear twice as often as intended due to a PHP conditional error. The flies are thematically appropriate (fruit attracts insects in nature) but mechanically punishing, and the satisfying conclusion where you finally step on the Annoying Fly after 50 rounds doesn't quite make up for 50 rounds of reduced combat effectiveness. If this event fires when you're about to fight the dragon or doing important combat, pray for the 40% no-flies outcome.