Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PatrickLerner/2814858 to your computer and use it in GitHub Desktop.
Save PatrickLerner/2814858 to your computer and use it in GitHub Desktop.
Mythic RPG
{ scopeName = 'mythic';
patterns = (
{ name = 'comment.block.mythic';
match = '^ (.+)';
captures = { 1 = { name = 'comment.block.mythic'; }; };
},
);
}
#!/usr/bin/ruby
# In TextMate set this up like this:
# Input: Entire Document
# Output: Replace Document
# Activation: Key Equivalent: Whatever Key you want, I use Option + Command + F
$ranks = {
'minuscule' => 1,
'weak' => 2,
'below average' => 4,
'low' => 3,
'above average' => 6,
'average' => 5,
'high' => 7,
'exceptional' => 8,
'incredible' => 9,
'awesome' => 10,
'superhuman' => 11
}
$odds = {
'impossible' => -4,
'no way' => -3,
'very unlikely' => -2,
'unlikely' => -1,
'50/50' => 0,
'somewhat likely' => 1,
'likely' => 2,
'very likely' => 3,
'near a sure thing' => 4,
'sure thing' => 5
}
$randomevent_meaning = [
"Attainment of goals.",
"The founding of a fellowship.",
"Neglect of the environment.",
"Blight.",
"The beginning of an enterprise which may harm others.",
"Ecstasy to the point of divorce from reality.",
"Conquest by force.",
"Macho excess.",
"Willpower.",
"The recruitment of allies.",
"The triumph of an evil cause.",
"Physical and emotional violation.",
"Weakness in the face of opposition.",
"Force applied with deliberate malice.",
"A declaration of war.",
"Persecution of the innocent.",
"Love.",
"Abandonment of the spiritual.",
"Instant gratification.",
"Intellectual inquiry.",
"Antagonism towards new ideas.",
"Joy and laughter.",
"Written messages.",
"Movement.",
"Wasteful dispersal of energies.",
"Truce.",
"Balance disturbed.",
"Tension released.",
"Disloyalty.",
"Friendship.",
"Physical attraction.",
"Love for the wrong reasons.",
"Passion which interferes with judgment.",
"A physical challenge.",
"Desertion of a project.",
"Domination.",
"Procrastination.",
"Acclaim.",
"A journey which causes temporary separation.",
"Loss.",
"A matter concluded in plenty.",
"Healing.",
"Excessive devotion to the pleasures of the senses.",
"Swiftness in bringing a matter to its conclusion.",
"Delay in obtaining material possessions.",
"Delay.",
"Prosperity.",
"Material difficulties.",
"Cessation of benefits.",
"Temporary companionship.",
"Loss due to the machinations of another.",
"Lies made public.",
"Spite.",
"A situation does not live up to expectations.",
"Defeat.",
"Return of an old friend.",
"New alliances.",
"Imitation of reality.",
"Confusion in legal matters.",
"Bureaucracy.",
"Unfairness in a business matter.",
"Journey by water.",
"A path away from difficulties.",
"A temporary respite in struggle.",
"Stalemate.",
"Publicity.",
"Public recognition for one's efforts.",
"Good news.",
"Bad news.",
"Indefinite postponement by another of a project.",
"Cause for anxiety due to exterior factors.",
"Delay in achieving one's goal.",
"Theft.",
"A journey by land.",
"Good advice from an expert.",
"The exposure and consequent failure of a plot.",
"A project about to reach completion.",
"Intellectual competition.",
"Haggling.",
"Imprisonment.",
"Illness.",
"Release.",
"Opposition collapses.",
"A matter believed to be of great importance is actually of small consequence.",
"Loss of interest.",
"Celebration of a success.",
"Rapid development of an undertaking.",
"Travel by air.",
"Non-arrival of an expected communication.",
"Jealousy.",
"Dispute among partners.",
"A project does not work out.",
"The possible loss of home.",
"An investment proves worthless.",
"Suffering.",
"Mental imprisonment.",
"Debasement.",
"Material desires are wholly fulfilled.",
"Overindulgence.",
"Wishes fall short.",
"Delaying tactics.",
"Stalemate leading to adjournment.",
"Adversity, but not insurmountable.",
"Gambling.",
"Lack of solidity.",
"Misfortune.",
"The death of a dream.",
"Disruption.",
"Temporary success.",
"Usurped power.",
"A balance is made, but it is temporary.",
"Failure of a partnership.",
"Possible loss of friendship.",
"Betrayal.",
"Abuse of power.",
"Becoming a burden to another.",
"Oppression of the few by the many.",
"Intrigues.",
"Resentment.",
"Fears realized.",
"A student.",
"Messages.",
"The bearer of bad news.",
"Fears proven unfounded.",
"A sentinel.",
"Inspection or scrutiny.",
"Ambush.",
"Spying.",
"Mutiny.",
"News.",
"Attachment to the point of obsession.",
"The affairs of the world.",
"Unexpected aid.",
"A bearer of intelligence.",
"Rumor.",
"Old wounds reopened.",
"Carelessness.",
"Friendship strained.",
"Guerrilla warfare.",
"Ruin.",
"Unwise extravagance.",
"Dirty tricks.",
"Arrival of a friend.",
"Propositions.",
"Fraud.",
"Rivalry.",
"A spiritual representative.",
"Triumph over adversities.",
"Travel by air.",
"Frustration.",
"Division.",
"The refusal to listen to views at variance to one's own.",
"Motherly figure.",
"Opulence.",
"Ill-natured gossip.",
"Mistrust of those near.",
"Liberty.",
"Deceit.",
"Cruelty from intolerance.",
"A person not to be trusted.",
"Excitement from activity.",
"Someone of assistance.",
"Father figure.",
"A dull individual.",
"Military.",
"A judge.",
"A wise counselor.",
"The mundane.",
"A teacher.",
"Trials overcome.",
"Frenzy.",
"Negligence.",
"Duality.",
"Passion",
"Hard work.",
"The control of masses.",
"Alliance as a formality, not sincere.",
"Attraction to an object or person.",
"Travel by vehicle.",
"Success in an artistic or spiritual pursuit.",
"Vengeance.",
"An unethical victory.",
"Judicial proceedings.",
"Dispute.",
"Legal punishment.",
"Guidance from an elder.",
"A journey.",
"Good fortune.",
"Too much of a good thing.",
"The spiritual over the material.",
"The material over the spiritual.",
"Transformation and change.",
"Disunion.",
"Amassment of riches.",
"Overthrow of the existing order.",
"Communication by technological means.",
"Oppression.",
"Hope.",
"Hope deceived, daydreams fail.",
"Change of place."
];
$randomevent_focus = {
1 => "Remote event",
8 => "Character Action",
23 => "Introduce a new character",
31 => "Thread related event",
43 => "Close or open a thread",
48 => "Player character negative",
56 => "Player character positive",
64 => "Neutral event",
89 => "NPC negative",
95 => "NPC positive"
}
$fatetable = {
-5 => [ 1, 5, 82],
-4 => [ 2, 9, 83],
-3 => [ 3, 15, 84],
-2 => [ 5, 24, 86],
-1 => [ 8, 37, 89],
0 => [10, 50, 91],
1 => [13, 63, 94],
2 => [15, 76, 96],
3 => [16, 85, 97],
4 => [17, 91, 99],
5 => [18, 95, 99]
}
lastline = ""
$chaoslevel = 0
chaosregex = Regexp.new('^ Chaos Level\: (\d+)$')
newlinecache = ""
ARGF.each do |line|
line = line.rstrip
if (line != "")
line.scan(/\%(\d+)d(\d+)\%/) {|s|
num = s[0].to_i
sides = s[1].to_i
if (num > 0 and sides > 0)
sum = 0
num.times { sum += 1 + rand(sides) }
line = line.sub("%"+num.to_s+"d"+sides.to_s+"%", sum.to_s)
end
}
puts newlinecache + line
newlinecache = ""
lastline = line
if (m = chaosregex.match(line))
$chaoslevel = m[1].to_i - 5
end
else
newlinecache += "\n"
end
end
def rankToNumber(rank)
rank = rank.downcase()
$ranks.each { |r, num|
rank = rank.sub(r, num.to_s)
}
return eval(rank)
end
def printResult(diff)
if (diff < -5)
diff = -5
elsif (diff > 5)
diff = 5
end
t = $fatetable[diff]
roll = 1 + rand(100)
if (roll <= t[0])
puts " Exceptional Yes [Fav Y " + (t[0] + 1 - roll).to_s +
" N " + (t[1] + 1 - roll).to_s +
" ExN " + (t[2] - roll).to_s + "]"
elsif (roll <= t[1])
puts " Yes [Fav ExY " + (roll - t[0]).to_s +
" N " + (t[1] + 1 - roll).to_s +
" ExN " + (t[2] - roll).to_s + "]"
elsif (roll < t[2])
puts " No [Fav ExY " + (roll - t[0]).to_s +
" Y " + (roll - t[1]).to_s +
" ExN " + (t[2] - roll).to_s + "]"
else
puts " Exceptional No [Fav ExY " + (roll - t[0]).to_s +
" Y " + (roll - t[1]).to_s +
" N " + (roll - t[2] + 1).to_s + "]"
end
if (roll % 11 == 0)
if (roll / 11 <= $chaoslevel + 5)
puts " Random event occurred!"
end
end
end
vsregex = Regexp.new('^ .* \((.*) vs\. (.*)\)$')
if (m = vsregex.match(lastline.downcase()))
AR = m[1]
DR = m[2]
begin
diff = rankToNumber(AR) - rankToNumber(DR)
printResult(diff)
rescue SyntaxError => nullPointer
end
else
oddsregex = Regexp.new('^ .* \((.*)\)$')
if (m = oddsregex.match(lastline.downcase()))
if ($odds.include?(m[1].downcase()))
odd = $odds[m[1].downcase()]
diff = odd.to_i + chaoslevel
printResult(diff)
end
elsif (lastline.downcase() == " random event:")
focus_roll = 1 + rand(100)
meaning_roll = 1 + rand(100)
meaning = $randomevent_meaning[meaning_roll];
focus = "";
$randomevent_focus.each { |mi, fo|
if (mi <= focus_roll)
focus = fo
end
}
puts " [Focus '" + focus + "', Meaning '" + meaning + "']"
elsif (lastline.downcase() == " roll for random event:")
roll = 1 + rand(10)
puts " Result: " + roll.to_s
if (roll <= $chaoslevel + 5)
focus_roll = 1 + rand(100)
meaning_roll = 1 + rand(100)
meaning = $randomevent_meaning[meaning_roll];
focus = "";
$randomevent_focus.each { |mi, fo|
if (mi <= focus_roll)
focus = fo
end
}
puts " Event: [Focus '" + focus + "', Meaning '" + meaning + "']"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment