Wednesday, 27 May 2009

The script …

You know, I think I’ve finally — ish — cracked what I set out to do. I’ve finally managed to finish … the Character Generator!

So you know, this is a Character Generation script for 5th Edition “Tunnels and Trolls”, written in Applescript on on Script Utility version 2.2.1, on a Mac Mini using Mac OS X 10.5.7

Now I could’ve probably used OS X’s onboard version’s of Java or Python for this; except I don’t actually know either.

And I’ve a little — very little — familiarity with Applescript to put this together. I think I can probably refine, but …

Well, here’s the first part, used to generate the random numbers that you’ll need as the basis for your character’s statistics, height, and weight, and finds out what sex, and species you want to be.

display dialog "Would you like to generate a T & T character?" buttons {"No", "Yes"} default button 2

if the button returned of the result is "No" then

say "Ok, that’s cool." using "Vicki"

else

set numberslist to {3, 4, 4, 4, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17, 17, 17, 18}

set Strength1 to some item of numberslist

set Intelligence1 to some item of numberslist

set Luck1 to some item of numberslist

set Constitution1 to some item of numberslist

set Dexterity1 to some item of numberslist

set Charisma1 to some item of numberslist

set Height1 to some item of numberslist

set Weight1 to some item of numberslist

end if


display dialog "Would you like to be Human, Elf, or Dwarf?" default answer "Your Character’s Race"

set playerRace to the text returned of result



The next part actually manipulates those figures, based on what you’ve told it, to find out what your actual characteristics will be.

if playerRace is "Human" or "human" then set Strength2 to Strength1

if playerRace is "Human" or "human" then set Intelligence2 to Intelligence1

if playerRace is "Human" or "human" then set Luck2 to Luck1

if playerRace is "Human" or "human" then set Constitution2 to Constitution1

if playerRace is "Human" or "human" then set Dexterity2 to Dexterity1

if playerRace is "Human" or "human" then set Charisma2 to Charisma1

if playerRace is "Human" or "human" then set Height2 to Height1

if playerRace is "Human" or "human" then set Weight2 to Weight1


if playerRace is "Elf" or "elf" then set Strength2 to Strength1

if playerRace is "Elf" or "elf" then set Intelligence2 to round (Intelligence1 * (3 / 2)) rounding down

if playerRace is "Elf" or "elf" then set Luck2 to Luck1

if playerRace is "Elf" or "elf" then set Constitution2 to round (Constitution1 * (2 / 3)) rounding down

if playerRace is "Elf" or "elf" then set Dexterity2 to round (Dexterity1 * (3 / 2)) rounding down

if playerRace is "Elf" or "elf" then set Charisma2 to (Charisma1 * 2)

if playerRace is "Elf" or "elf" then set Height2 to (round Height1 * (11 / 10) rounding down)

if playerRace is "Elf" or "elf" then set Weight2 to round (Weight1 * (7 / 8)) rounding down


if playerRace is "Dwarf" or "dwarf" then set Strength2 to (Strength1 * 2)

if playerRace is "Dwarf" or "dwarf" then set Intelligence2 to Intelligence1

if playerRace is "Dwarf" or "dwarf" then set Luck2 to Luck1

if playerRace is "Dwarf" or "dwarf" then set Constitution2 to (Constitution1 * 2)

if playerRace is "Dwarf" or "dwarf" then set Dexterity2 to Dexterity1

if playerRace is "Dwarf" or "dwarf" then set Charisma2 to round (Charisma1 * (2 / 3)) rounding down

if playerRace is "Dwarf" or "dwarf" then set Height2 to round (Height1 * (2 / 3)) rounding down

if playerRace is "Dwarf" or "dwarf" then set Weight2 to round (Weight1 * (7 / 8)) rounding down


display dialog "Would you like to be male or female?" default answer "Male"

set playerSex to the text returned of result


set w to 0

set x to 0

set y to 0

set z to 0

if Strength2 is greater than 12 then set w to Strength2 - 12

if Strength2 is less than 9 then set w to 9 - Strength2

if Intelligence2 is greater than 12 then set x to Intelligence2 - 12

if Intelligence2 is less than 9 then set x to 9 - Intelligence2

if Luck2 is greater than 12 then set y to Luck2 - 12

if Luck2 is less than 9 then set y to 9 - Luck2

if Dexterity2 is greater than 12 then set z to Dexterity2 - 12

if Dexterity2 is less than 9 then set z to 9 - Dexterity2


set CombatAdds to w + x + y + z


if Height2 is 3 and playerSex is "Male" or "male" then set height to "4 foot"

if Height2 is 3 and playerSex is "Female" or "female" then set height to "3 foot 10"

if Height2 is 4 and playerSex is "Male" or "male" then set height to "4 foot 3"

if Height2 is 4 and playerSex is "Female" or "female" then set height to "4 foot 1"

if Height2 is 5 and playerSex is "Male" or "male" then set height to "4 foot 5"

if Height2 is 5 and playerSex is "Female" or "female" then set height to "4 foot 3"

if Height2 is 6 and playerSex is "Male" or "male" then set height to "4 foot 8"

if Height2 is 6 and playerSex is "Female" or "female" then set height to "4 foot 6"

if Height2 is 7 and playerSex is "Male" or "male" then set height to "4 foot 10"

if Height2 is 7 and playerSex is "Female" or "female" then set height to "4 foot 8"

if Height2 is 8 and playerSex is "Male" or "male" then set height to "5 foot 1"

if Height2 is 8 and playerSex is "Female" or "female" then set height to "4 foot 11"

if Height2 is 9 and playerSex is "Male" or "male" then set height to "5 foot 3"

if Height2 is 9 and playerSex is "Female" or "female" then set height to "5 foot 1"

if Height2 is 10 and playerSex is "Male" or "male" then set height to "5 foot 6"

if Height2 is 10 and playerSex is "Female" or "female" then set height to "5 foot 4"

if Height2 is 11 and playerSex is "Male" or "male" then set height to "5 foot 8"

if Height2 is 11 and playerSex is "Female" or "female" then set height to "5 foot 6"

if Height2 is 12 and playerSex is "Male" or "male" then set height to "5 foot 11"

if Height2 is 12 and playerSex is "Female" or "female" then set height to "5 foot 9"

if Height2 is 13 and playerSex is "Male" or "male" then set height to "6 foot 1"

if Height2 is 13 and playerSex is "Female" or "female" then set height to "5 foot 11"

if Height2 is 14 and playerSex is "Male" or "male" then set height to "6 foot 4"

if Height2 is 14 and playerSex is "Female" or "female" then set height to "6 foot 2"

if Height2 is 15 and playerSex is "Male" or "male" then set height to "6 foot 6"

if Height2 is 15 and playerSex is "Female" or "female" then set height to "6 foot 4"

if Height2 is 16 and playerSex is "Male" or "male" then set height to "6 foot 9"

if Height2 is 16 and playerSex is "Female" or "female" then set height to "6 foot 7"

if Height2 is 17 and playerSex is "Male" or "male" then set height to "6 foot 11"

if Height2 is 17 and playerSex is "Female" or "female" then set height to "6 foot 9"

if Height2 is 18 and playerSex is "Male" or "male" then set height to "7 foot 2"

if Height2 is 18 and playerSex is "Female" or "female" then set height to "7 foot"


if Weight2 is 3 and playerSex is "Male" or "male" then set weight to "75"

if Weight2 is 3 and playerSex is "Female" or "female" then set weight to "65"


if Weight2 is 4 and playerSex is "Male" or "male" then set weight to "90"

if Weight2 is 4 and playerSex is "Female" or "female" then set weight to "80"


if Weight2 is 5 and playerSex is "Male" or "male" then set weight to "105"

if Weight2 is 5 and playerSex is "Female" or "female" then set weight to "95"


if Weight2 is 6 and playerSex is "Male" or "male" then set weight to "120"

if Weight2 is 6 and playerSex is "Female" or "female" then set weight to "110"


if Weight2 is 7 and playerSex is "Male" or "male" then set weight to "135"

if Weight2 is 7 and playerSex is "Female" or "female" then set weight to "125"


if Weight2 is 8 and playerSex is "Male" or "male" then set weight to "150"

if Weight2 is 8 and playerSex is "Female" or "female" then set weight to "140"


if Weight2 is 9 and playerSex is "Male" or "male" then set weight to "160"

if Weight2 is 9 and playerSex is "Female" or "female" then set weight to "150"


if Weight2 is 10 and playerSex is "Male" or "male" then set weight to "170"

if Weight2 is 10 and playerSex is "Female" or "female" then set weight to "160"


if Weight2 is 11 and playerSex is "Male" or "male" then set weight to "180"

if Weight2 is 11 and playerSex is "Female" or "female" then set weight to "170"


if Weight2 is 12 and playerSex is "Male" or "male" then set height to "190"

if Weight2 is 12 and playerSex is "Female" or "female" then set weight to "180"


if Weight2 is 13 and playerSex is "Male" or "male" then set weight to "200"

if Weight2 is 13 and playerSex is "Female" or "female" then set weight to "190"


if Weight2 is 14 and playerSex is "Male" or "male" then set weight to "225"

if Weight2 is 14 and playerSex is "Female" or "female" then set weight to "215"


if Weight2 is 15 and playerSex is "Male" or "male" then set weight to "250"

if Weight2 is 15 and playerSex is "Female" or "female" then set weight to "240"


if Weight2 is 16 and playerSex is "Male" or "male" then set weight to "280"

if Weight2 is 16 and playerSex is "Female" or "female" then set weight to "270"


if Weight2 is 17 and playerSex is "Male" or "male" then set weight to "310"

if Weight2 is 17 and playerSex is "Female" or "female" then set weight to "300"


if Weight2 is 18 and playerSex is "Male" or "male" then set weight to "350"

if Weight2 is 18 and playerSex is "Female" or "female" then set weight to "340"


As you can see, I’ve also included the basic calculation of your character’s combat adds; that’s the bonus — or negative number — that’s added to the amount of hits you roll, for your weapon in combat. It also generates your height and weight.

say "Your Strength is" using "Vicki"

say Strength2 using "Vicki"

say "Your Inteligence is" using "Vicki"

say Intelligence2 using "Vicki"

say "Your Luck is" using "Vicki"

say Luck2 using "Vicki"

say "Your Constitution is" using "Vicki"

say Constitution2 using "Vicki"

say "Your Dexterity is" using "Vicki"

say Dexterity2 using "Vicki"

say "Your Charisma is" using "Vicki"

say Charisma2 using "Vicki"


if CombatAdds is greater than 0 then say "You have a combat bonus of plus" using "Vicki"

if CombatAdds is greater than 0 then say CombatAdds using "Vicki"


if CombatAdds is less than 0 then say "You have a combat modifier of minus" using "Vicki"

if CombatAdds is less than 0 then say CombatAdds


if CombatAdds is equal to 0 then say "You do not have a combat modifier" using "Vicki"



set Gold to (some item of numberslist) * 10


say "You have " using "Vicki"

say Gold using "Vicki"

say " gold pieces" using "Vicki"


say "You are a " using "Vicki"

say height using "Vicki"

say weight using "Vicki"

say "pound" using "Vicki"

say playerSex using "Vicki"

say playerRace using "Vicki"


say "Please enjoy your" using "Vicki"

if playerRace is "Human" or "human" then say "fantasy adventure" using "Vicki"

if playerRace is "Elf" or "elf" then say "Elven adventure" using "Vicki"

if playerRace is "Dwarf" or "dwarf" then say "dwarven adventure" using "Vicki"


That final part tells you what your stats are, as well as your height, weight and sex. And how much money you’ve got.

Phew!

Now I know I could probably have handled the height and weight section a little better; I think it’s throwing up some oddities.

Like a female elf, and a male dwarf the same height and weight!

But feel free to copy and paste, folks!!!!

And I’m sorry about the adverts, but I always think they’re fun …




No comments: