User:Kroocsiogsi/Hero response formatting scripts

Introduction

 * 1) Install perl
 * 2) Put the subtitle files to be converted in a folder on your Desktop named "Responses", and make an empty folder called "NewResponses"
 * 3) Put the perl script on your Desktop
 * 4) Correct the folder paths in the perl script
 * 5) If the hero has a two-part name, like "dark_seer_dkseer", change that part of the script
 * 6) Run the perl script from the command line
 * 7) Fix link to main hero article at the top of the response page
 * 8) Fix sections titled "Other: Please Classify"

Heroes:
opendir(DIR, "C:\\Users\\USERNAME\\Desktop\\Responses") or die "can't opendir $dirname: $!"; while (defined($file = readdir(DIR))) {
 * 1) open directory containing response files

open(F1, "C:\\Users\\USERNAME\\Desktop\\Responses\\$file"); open(F2, ">C:\\Users\\USERNAME\\Desktop\\NewResponses\\$file");
 * 1) open original response file
 * 1) open formatted response file

print F2 "\n";
 * 1) print the beginning of the formatted response file

while ($line = ) { ## if $line is a response line, pull out mp3 name, response section, and subtitle if ($line =~ /^\s+"[a-z]+_([a-z]+_(\w+?)(_\d\d)?)"\s+"[\w ]+: (.+)"/) {
 * 1) read every line of the original response file

## For heroes with two part names, add an extra _[a-z]+ to the line above, hence: ## if ($line =~ /^\s+"[a-z]+_[a-z]+_([a-z]+_(\w+?)(_\d\d)?)"\s+"[\w ]+: (.+)"/) {

## check if a new reponse section should be printed unless ( $2 eq $currentsection) { unless ( $currentsection eq "") { print F2 "\n" }			$currentsection = $2; if ( $currentsection eq "spawn") { $prettysection = "Spawning" } elsif ( $currentsection eq "battlebegins") { $prettysection = "Beginning the Battle" } elsif ( $currentsection eq "begin") { $prettysection = "Beginning the Battle" } elsif ( $currentsection eq "begins") { $prettysection = "Beginning the Battle" } elsif ( $currentsection eq "firstblood") { $prettysection = "Drawing First Blood" } elsif ( $currentsection eq "first") { $prettysection = "Drawing First Blood" } elsif ( $currentsection eq "move") { $prettysection = "Moving" } elsif ( $currentsection eq "attack") { $prettysection = "Attacking" } elsif ( $currentsection eq "cast") { $prettysection = "Casting a Spell" } elsif ( $currentsection eq "level") { $prettysection = "Gaining a Level" } elsif ( $currentsection eq "levelup") { $prettysection = "Gaining a Level" } elsif ( $currentsection eq "kill") { $prettysection = "Killing a Hero" } elsif ( $currentsection eq "ability_failure") { $prettysection = "Failing to Kill a Hero" } elsif ( $currentsection eq "failure") { $prettysection = "Failing to Kill a Hero" } elsif ( $currentsection eq "magicuser") { $prettysection = "Killing a Caster Hero" } elsif ( $currentsection eq "killspecial") { $prettysection = "Killing in a Special Way" } elsif ( $currentsection eq "rival") { $prettysection = "Killing a Rival" } elsif ( $currentsection eq "rivals") { $prettysection = "Killing a Rival" } elsif ( $currentsection eq "rivals_general") { $prettysection = "Killing a Rival" } elsif ( $currentsection eq "ally") { $prettysection = "Meeting an Ally" } elsif ( $currentsection eq "lasthit") { $prettysection = "Last Hitting" } elsif ( $currentsection eq "death") { $prettysection = "Dying" } elsif ( $currentsection eq "cough") { $prettysection = "Coughing" } elsif ( $currentsection eq "fastres") { $prettysection = "Respawning Quickly" } elsif ( $currentsection eq "respawn") { $prettysection = "Respawning" } elsif ( $currentsection eq "rare") { $prettysection = "Rare" } elsif ( $currentsection eq "tf2") { $prettysection = "Lines from Team Fortress 2" } elsif ( $currentsection eq "purch") { $prettysection = "Purchasing an Item" } elsif ( $currentsection eq "blink") { $prettysection = "Purchasing Blink Dagger" } elsif ( $currentsection eq "manta") { $prettysection = "Purchasing Manta Style" } elsif ( $currentsection eq "scepter") { $prettysection = "Purchasing Aghanim's Scepter" } elsif ( $currentsection eq "rapier") { $prettysection = "Purchasing Divine Rapier" } elsif ( $currentsection eq "heart") { $prettysection = "Purchasing Heart of Tarrasque" } elsif ( $currentsection eq "bfury") { $prettysection = "Purchasing Battlefury" } elsif ( $currentsection eq "armlet") { $prettysection = "Purchasing Armlet" } elsif ( $currentsection eq "travel") { $prettysection = "Purchasing Boots of Travel" } elsif ( $currentsection eq "refresh") { $prettysection = "Purchasing Refresher Orb" } elsif ( $currentsection eq "desolator") { $prettysection = "Purchasing Desolator" } elsif ( $currentsection eq "item") { $prettysection = "Purchasing a Specific Item" } elsif ( $currentsection eq "items") { $prettysection = "Purchasing a Specific Item" } elsif ( $currentsection eq "relic") { $prettysection = "Purchasing a Specific Item" } elsif ( $currentsection eq "sheepstick") { $prettysection = "Getting Hexed" } elsif ( $currentsection eq "bottle") { $prettysection = "Bottling a Rune" } elsif ( $currentsection eq "deny") { $prettysection = "Denying" } elsif ( $currentsection eq "lose") { $prettysection = "Losing" } elsif ( $currentsection eq "defeat") { $prettysection = "Losing" } elsif ( $currentsection eq "win") { $prettysection = "Winning" } elsif ( $currentsection eq "victory") { $prettysection = "Winning" } elsif ( $currentsection eq "immort") { $prettysection = "Taking Aegis of the Immortal" } elsif ( $currentsection eq "haste") { $prettysection = "Activating Haste" } elsif ( $currentsection eq "doubdam") { $prettysection = "Activating Double Damage" } elsif ( $currentsection eq "regen") { $prettysection = "Activating Regeneration" } elsif ( $currentsection eq "illus") { $prettysection = "Activating Illusion" } elsif ( $currentsection eq "invis") { $prettysection = "Activating Invisibility" } elsif ( $currentsection eq "notyet") { $prettysection = "Attempting to Use an Ability on Cooldown" } elsif ( $currentsection eq "nomana") { $prettysection = "Attempting to Use an Ability without Mana" } elsif ( $currentsection eq "thanks") { $prettysection = "Thanking" } elsif ( $currentsection eq "underattack") { $prettysection = "Coming Under Attack" } elsif ( $currentsection eq "taunt") { $prettysection = "Taunting" } elsif ( $currentsection eq "inthebag") { $prettysection = "Taunting" } elsif ( $currentsection eq "shitwiz") { $prettysection = "Shitty Wizard" } elsif ( $currentsection eq "crumwiz") { $prettysection = "Crummy Wizard" } elsif ( $currentsection eq "pain") { $prettysection = "Pain" } elsif ( $currentsection eq "anger") { $prettysection = "Anger" } elsif ( $currentsection eq "happy") { $prettysection = "Happiness" } elsif ( $currentsection eq "laugh") { $prettysection = "Laughter" } elsif ( $currentsection eq "sfx") { $prettysection = "Noises" } elsif ( $currentsection eq "acknow") { $prettysection = "Acknowledgment" } elsif ( $currentsection eq "lane_missing") { $prettysection = "Calling a Missing Hero" } elsif ( $currentsection eq "missing_lane") { $prettysection = "Calling a Missing Hero" } elsif ( $currentsection eq "missing") { $prettysection = "Calling a Missing Hero" } elsif ( $currentsection eq "drop_common") { $prettysection = "Finding a Common Cosmetic Item" } elsif ( $currentsection eq "drop_medium") { $prettysection = "Finding a Medium Cosmetic Item" } elsif ( $currentsection eq "drop_rare") { $prettysection = "Finding a Rare Cosmetic Item" } elsif ( $currentsection eq "view_victory") { $prettysection = "Viewing a Victory" } elsif ( $currentsection eq "view_defeat") { $prettysection = "Viewing a Defeat" } elsif ( $currentsection eq "set_complete") { $prettysection = "Completing a Set of Cosmetic Items" } elsif ( $currentsection eq "equipping") { $prettysection = "Equipping a Cosmetic Item" } else { $prettysection = "Other: Please Classify" };			print F2 "==$prettysection==\n" };		## print the new response line print F2 "* $1.mp3 $4\n"; }; };

print F2 "\n";
 * 1) print the end of the formatted response file

close(F1); close(F2);
 * 1) close original response file
 * 1) close formatted response file

$currentsection = "";

}; closedir(DIR);
 * 1) close directory

Weird things, like the Shopkeeper:
opendir(DIR, "C:\\Users\\USERNAME\\Desktop\\Responses") or die "can't opendir $dirname: $!"; while (defined($file = readdir(DIR))) {
 * 1) open directory containing response files

open(F1, "C:\\Users\\USERNAME\\Desktop\\Responses\\$file"); open(F2, ">C:\\Users\\USERNAME\\Desktop\\NewResponses\\$file");
 * 1) open original response file
 * 1) open formatted response file

print F2 "\n"; print F2 "==Other==\n";
 * 1) print the beginning of the formatted response file

while ($line = ) { ## if $line is a response line, pull out mp3 name and subtitle if ($line =~ /^\s+"[a-z]+_([a-z]+_(\w+)(_\d)?(\d)?)"\s+"[\w ]+: (.+)"/) { ## print the new response line print F2 "* $1.mp3 $5\n"; }; };
 * 1) read every line of the original response file

print F2 "\n";
 * 1) print the end of the formatted response file

close(F1); close(F2);
 * 1) close original response file
 * 1) close formatted response file

}; closedir(DIR);
 * 1) close directory