There are a lot of comments throughout the code, it's written for tintin++ 1.99.6, but it should be fairly portable. I've commented out all the logging that I do by default as you may not want that (it doesn't slow down performance, but your filesystem or data gathering may be different.
If you have questions feel free to ask, I'm probably going to clean up the code a bit as I just tossed this together last night.
Code: Select all
#nop Character Roller by Sservis. Copyright 2009. All rights reserved.
#nop
#nop You're able to specify things like, give me any character that can be
#nop increased to 3 perfects, 1 mighty. I prefer to do the swapping and
#nop boosting manually as the knowledge that a caster mighty int is at
#nop least 90 (as opposed to the generic assumption that mighty is at least
#nop 88). The code just pauses the rolling process and keeps the
#nop connection alive when a match is found, change the found_match alias
#nop if you want to do swaps and such yourself.
#nop
#nop This version has all logging disabled, find the #nop #log and
#nop #nop #line items and remove the #nop to enable.
#nop
#nop I also have not implemented auto-reconnection. Change the
#nop start_roller alias if you connect with something other than #session
#nop Settings, you shouldn't need to change anything outside this area
#nop The selection variables are defined at the end of this file. The
#nop choices at the various prompts will be made automatically. See the
#nop definitions to clarify what to put in.
#var race_selection grey;
#var class_selection inv;
#nop align_selection should be L, N, C, G, E if only one dimension is
#nop needed for the specific race/class. If both are needed it should be
#nop LG, NN, CE, etc.
#var align_selection L;
#var home_selection Waterdeep;
#var gender_selection male;
#var change the default password to something else.
#var password XXXXXX;
#nop stats_accept is a list of lists. Each one specifies a minimum stat
#nop acceptance level. If rolled stats match any of these, the character
#nop will be accepted.
#nop
#nop An item {{1}{0}{2}{0}{0}{0}{0}{0}} specifies that any character with
#nop at least one perfect or higher and two mighty or higher (includes the
#nop perfect counted on the perfect check)
#nop p h m g f a m b
#var stats_accept {
{{3}{3}{3}{3}{4}{0}{0}{0}}
{{2}{3}{3}{4}{0}{0}{0}{0}}
{{2}{2}{4}{0}{0}{0}{0}{0}}
{{1}{3}{4}{0}{0}{0}{0}{0}}
};
#nop nothing should need to be changed below here
#nop tintin++ specific settings, these may not be needed, but it's what I use.
#config log plain;
#config {command echo} off;
#config {packet patch} 1;
#config {wordwrap} off;
#split 1;
#nop actions to drive the rolling process, the work takes place in
#nop check_stats. Listed in order of encounter in rolling.
#act {^Please enter your term type (<CR> ansi, '?' help):} {#cr};
#act {^Do you wish to create a new character? Y/N} {Y};
#act {^Your selection} {${race_${race_selection}}};
#act {^Class selection menu} {${class_${class_selection}}};
#act {^Alignment Selection} {${align_${align_selection}}};
#act {^Hometown Selection} {${home_${home_selection}}};
#act {^Strength: %1 Power: %2} {register_stat str %1; register_stat pow %2};
#act {^Dexterity: %1 Intelligence: %2} {register_stat dex %1; register_stat int %2};
#act {^Agility: %1 Wisdom: %2} {register_stat agi %1; register_stat wis %2};
#act {^Constitution: %1 Charisma: %2} {register_stat con %1; register_stat cha %2};
#act {^To swap stats: enter the first stat name folowed by the second stat} {check_stats};
#act {^Is your character Male or Female} {$gender_${gender_selection}};
#act {^Do you understand and agree with these conventions} {Y};
#act {^You wish to be known as %1 (Y/N)} {#var name {%1};Y};
#act {^Please enter a password for} {$password};
#act {^Please retype password} {$password;Y};
#act {^*** PRESS RETURN:} {#cr;1;score;att;check str;check agi; check dex; check con; check pow; check int; check wis; check cha;quit;Yes;0};
#nop #act {^Score information for} {#log o {${race_selection}_${class_selection}_${name}}};
#nop variables that help make the selections at the various menus
#nop home_* is not a complete list.
#var race_human a;
#var race_barb b;
#var race_drow c;
#var race_grey d;
#var race_dwarf e;
#var race_duergar f;
#var race_halfling g;
#var race_gnome h;
#var race_ogre i;
#var race_troll j;
#var race_half k;
#var race_illithid p;
#var race_yuan q;
#var race_orc r;
#var class_war a;
#var class_ran b;
#var class_pal d;
#var class_a-p e;
#var class_cle f;
#var class_dru h;
#var class_sha i;
#var class_nec k;
#var class_ele l;
#var class_bar p;
#var class_psi q;
#var class_enc r;
#var class_inv s;
#var class_bat t;
#var class_rog u;
#var class_ill v;
#var class_bat w;
#var align_LG {L;G};
#var align_LN {L;N};
#var align_LE {L;E};
#var align_NG {N;G};
#var align_NN {N;N};
#var align_NE {N;E};
#var align_CG {C;G};
#var align_CN {C;N};
#var align_CE {C;E};
#var align_L {L};
#var align_N {N};
#var align_C {C};
#var align_G {G};
#var align_E {E};
#var home_Waterdeep 1;
#var home_Calimport 11;
#var home_BaldursGate 14;
#var gender_male M;
#var gender_female F;
#var some calculation variables to aid the decision process
#var bad_cnt 0;
#var mundane_cnt 0;
#var average_cnt 0;
#var fair_cnt 0;
#var good_cnt 0;
#var mighty_cnt 0;
#var heroic_cnt 0;
#var perfect_cnt 0;
#nop these track the actual stat levels, register stat sets these
#var str 0;
#var dex 0;
#var agi 0;
#var con 0;
#var pow 0;
#var int 0;
#var wis 0;
#var cha 0;
#var bad 0;
#var mundane 1;
#var average 2;
#var fair 3;
#var good 4;
#var mighty 5;
#var heroic 6;
#var perfect 7;
#nop loop internal variables, habit to declare everything.
#var should_accept 0;
#var comp_list nop;
#var name nop;
#nop start the roller
#ali start_roller #SESSION roller torilmud.org 9999;
#nop sets the stat and *_cnt variables.
#ali register_stat {#var %1 ${%2};#math {%2_cnt} {${%2_cnt} + 1}};
#nop handles the work of checking if the current stats are good enough.
#ali check_stats
{
#nop log the stats to stats_<class> to ensure that I can audit my
#nop rolling targets to ensure feasiblity.
#nop #line log {stats_${class_selection}} {${perfect_cnt}${heroic_cnt}${mighty_cnt}${good_cnt}${fair_cnt}${average_cnt}${mundane_cnt}${bad_cnt}};
#nop transform the counts from how many of exactly this stat to how many
#nop of this stat or higher.
#math {heroic_cnt} {${heroic_cnt} + ${perfect_cnt}};
#math {mighty_cnt} {${mighty_cnt} + ${heroic_cnt}};
#math {good_cnt} {${good_cnt} + ${mighty_cnt}};
#math {fair_cnt} {${fair_cnt} + ${good_cnt}};
#math {average_cnt} {${average_cnt} + ${fair_cnt}};
#math {mundane_cnt} {${mundane_cnt} + ${average_cnt}};
#math {bad_cnt} {${bad_cnt} + ${mundane_cnt}};
#nop create a list for comparison to the goal lists
#var comp_list {{$perfect_cnt}{$heroic_cnt}{$mighty_cnt}{$good_cnt}{$fair_cnt}{$average_cnt}{$mundane_cnt}{$bad_cnt}};
#nop loop over the acceptance cases
#forall {$stats_accept}
{
#var stats_tmp {&0};
#var current_accept 1;
#nop loop over the different stat levels (mighty or higher, etc)
#loop {1 8}
{
#if {$stats_tmp[&&0]>$comp_list[&&0]} {#var current_accept 0} {#nop}
};
#if {$current_accept==1}
{#var should_accept 1}
{#nop}
};
#if {$should_accept==1}
{found_match}
{#cr};
#nop reset for the next run
#var perfect_cnt 0;
#var heroic_cnt 0;
#var mighty_cnt 0;
#var good_cnt 0;
#var fair_cnt 0;
#var average_cnt 0;
#var mundane_cnt 0;
#var bad_cnt 0;
}
#nop handle that's called when a match is found, currently goes into
#nop zombie keepalive mode
#ali found_match {#ali check_stats #nop;#tick keepalive {\?} 60}
#nop used to stat the character so that I have a record of the exact stats
#ali check {checkpoints %1 100};
#nop start the roller
start_roller;