global $usingItem; $usingItem->generateInputFragments($charData, true); foreach ($usingItem->commands as $fragment) { $output .= "{$fragment->displayString}, "; } $output = rtrim($output, ", ") . "\n"; echo $output; StateManager::ChangeState($charData, GameStates::UsingItem); }); $combat->commands[] = new InputFragment("run", function ($charData, $mapData, $dynData) use($combat) { $chanceInSix = rand(1, 6); // 5+ to escape if ($chanceInSix < 5) { $room = $mapData->map->GetRoom($mapData->playerX, $mapData->playerY); $monster = $room->occupant; list($attackType, $damage) = $combat->monsterAttack($charData, $dynData, $monster, $output); if ($damage > 0) { echo "You get caught and {$attackType} for {$damage} damage!\n"; } else { echo "It swipes at you as you run, but it misses!\n"; } } else { echo "You scurry back to the last room!\n"; // Unlock once-per-combat abilities. clearAllAbilityLocks($charData); // Calm down the Barbarians. $dummyOutput = ""; reduceRage($charData, $dummyOutput, 0); // Decrease the streak. alterStreak($charData, $mapData, true); StateManager::ChangeState($charData, GameStates::Adventuring);