$include $lib/alynna $include $lib/rp $def COLOR "^RED^(^PURPLE^" "(" subst "^RED^)^ ^" ")" subst $def COLOR2 "^BLUE^[^PURPLE^" "[" subst "^BLUE^]^ ^" "]" subst $def BANNER "^BLUE^<^YELLOW^Timecube^BLUE^>^ ^ " lvar param : tc.load[ -- dict:init ] { me @ location "/@rp/tc#/" array_get_propvals foreach var! turn var! tc tc @ toint { turn @ "|" explode_array var! tmp "target" tmp @ 0 [] todbref "name" tmp @ 1 [] "raw" tmp @ 2 [] toint "stat" tmp @ 3 [] toint "total" tmp @ 4 [] toint "recall" tmp @ 5 [] toint "luck" tmp @ 6 [] toint "subtotal" tmp @ 7 [] toint me @ location "sac/" tc @ tostr strcat getstat dup if "sac" swap else pop then me @ location "dec/" tc @ tostr strcat getstat dup if "dec" swap else pop then }dict repeat }dict ; : tc.save[ dict:init1 -- ] var turn var tc me @ location "/@rp/tc#/" { init1 @ foreach turn ! tc ! tc @ intostr { turn @ "target" [] turn @ "name" [] turn @ "raw" [] turn @ "stat" [] turn @ "total" [] turn @ "recall" [] turn @ "luck" [] turn @ "subtotal" [] }array "|" array_join repeat }dict dup array_count var! x array_put_propvals me @ location "/@rp/tc#" x @ setprop ; : tc.display[ i:turnnum dict:init2 ] var turn var tc init2 @ foreach turn ! tc ! { tc @ turnnum @ = if "^BRED^^YELLOW^" then "^PURPLE^" tc @ intostr 2 rj ") " "^WHITE^" turn @ "name" [] 16 lj "^ ^" "^YELLOW^" { "Init(" turn @ "subtotal" [] "[" turn @ "target" [] "initiative" getraw "+" turn @ "target" [] "@/initiative" getraw "+" turn @ "raw" [] "]" ")" }cat 20 lj COLOR COLOR2 turn @ "sac" [] not if turn @ "dec" [] not if "^GREEN^" { "Luck[" turn @ "reroll" [] "](" turn @ "luck" [] ")" }cat 20 lj COLOR COLOR2 "^CYAN^" { "Total(" turn @ "total" [] ")" }cat 20 lj COLOR else "^GREEN^" turn @ "dec" [] then else "^RED^Sacrificed: " turn @ "sac" [] then }atell repeat ; : tc.next tc.load var! init1 me @ location "tc" getstat var! turn init1 @ turn @ ++ [] array? not if me @ location "tc" turn @ ++ dup turn ! setstat { BANNER "End of round. Take free actions then begin a new round with +init." }atell else me @ location "tc" turn @ ++ dup turn ! setstat init1 @ turn @ [] "sac" [] if { BANNER "(^RED^Action " turn @ "^ ^): ^RED^" init1 @ turn @ [] "target" [] "'s action sacrificed: " init1 @ turn @ [] "sac" [] }atell tc.next else init1 @ turn @ [] "dec" [] not if { BANNER "(^GREEN^Action " turn @ "^ ^): ^GREEN^It is now " init1 @ turn @ [] "target" [] "'s action." }atell else { BANNER "(^GREEN^Action " turn @ "^ ^): ^GREEN^" init1 @ turn @ [] "target" [] ": " init1 @ turn @ [] "dec" [] }atell then then then ; : tc.new[ -- dict:init2 ] 0 array_make_dict var! init1 0 array_make_dict var! init2 var turn var target var stat var raw var total var luck (init round counters) me @ location "tc" 0 setstat me @ location "/@rp/tc#" remove_prop me @ location "/@rp/sac" remove_prop me @ location "/@rp/dec" remove_prop { 0 turn ! me @ location contents_array foreach target ! pop target @ "~status" getpropstr "IIC" smatch not if continue then target @ init dup stat ! random 12 % ++ dup raw ! + total ! begin total @ 0 > if turn @ dup ++ turn ! { target @ stat @ raw @ total @ dup 10 - total ! }array else break then repeat repeat }dict var! actors actors @ foreach array_vals pop total ! raw ! stat ! target ! pop target @ player? target @ thing? target @ "Z" flag? and or if target @ awake? if { "name" target @ name "target" target @ "stat" stat @ "raw" raw @ "subtotal" total @ 0 var! reroll begin "luck" random 12 luck @ + % ++ luck ! init1 @ total @ luck @ + toint [] not if luck @ break else pop reroll ++ then repeat "total" total @ luck @ + toint dup var! order "reroll" reroll @ }dict init1 @ order @ toint ->[] init1 ! then then repeat init1 @ array_count var! tc init1 @ foreach swap pop init2 @ tc @ toint ->[] init2 ! tc -- repeat init2 @ ; : cmd.+init "Initiative! Rolling for turn order ([init+1d12]+[1d12])..." header tellhere tc.new var! tc 1 tc @ tc.display "Timecube v2.0" footer tellhere tc @ tc.save tc.next ; SELFCALL cmd.+init : cmd.+next tc.next ; SELFCALL cmd.+next : cmd.+act me @ location "tc" param @ toint setstat { BANNER "^YELLOW^" me @ " has manually set the current action number to " param @ toint "." }atell me @ location "tc" param @ toint -- 0 inf limit setstat tc.next ; SELFCALL cmd.+act : cmd.+tc "Initiative! Recalling last turn order..." header tellhere tc.load var! tc me @ location "tc" getstat tc @ tc.display "Timecube v2.0" footer tellhere ; SELFCALL cmd.+tc : cmd.+atc me @ "@/initiative" param @ toint setstat { BANNER me @ " has adjusted their initiative bonus to " param @ toint "." }atell ; SELFCALL cmd.+atc : cmd.+sac param @ "=" explode_array var! arg arg @ 0 [] toint var! turn arg @ 1 [] var! msg turn @ not if { BANNER "Don't know what action you are trying to sacrifice." }tell exit then tc.load var! tc tc @ turn @ [] "target" [] me @ dbcmp not if me @ mlevel 5 >= if { BANNER "Staff override: " me @ " has sacrificed " tc @ turn @ [] "target" [] "'s action #" turn @ ": " msg @ }atell me @ location "sac/" turn @ tostr strcat msg @ setstat me @ location "tc" getstat turn @ = if tc.next then else { BANNER "^RED^That is not your action to override." }atell then else { BANNER me @ " has sacrificed their action #" turn @ ": " msg @ }atell me @ location "sac/" turn @ tostr strcat msg @ setstat me @ location "tc" getstat turn @ = if tc.next then then ; SELFCALL cmd.+sac : cmd.+dec param @ "=" explode_array var! arg arg @ 0 [] toint var! turn arg @ 1 [] var! msg turn @ not if { BANNER "Don't know what action you are trying to sacrifice." }tell exit then tc.load var! tc tc @ turn @ [] "target" [] me @ dbcmp not if me @ mlevel 5 >= if { BANNER "Staff override: " me @ " has declared " tc @ turn @ [] "target" [] "'s action #" turn @ ": " msg @ }atell me @ location "dec/" turn @ tostr strcat msg @ setstat else { BANNER "^RED^That is not your action to declare." }atell then else { BANNER me @ " has declared their action #" turn @ ": " msg @ }atell me @ location "dec/" turn @ tostr strcat msg @ setstat then ; SELFCALL cmd.+dec : cmd.+tc/help { "TimeCube 2.0 advance (C) 2007 Alynna Trypnotk - GPLv2" "Syntax" " +init Start a new round" " +tc Display the status of the current round" " +sac #= Sacrifice an action for " " +dec #= Declare an action in advance" " +atc Adjusts your initiative by " " +next Finish your turn and go onto the next person" " +act <#> Manually set to that action number" " " "The roll is (init)+(init bonus)+(1d12) to count your actions, you get 1 action" "per 10 init points you score. Every action is then rolled again with an additional" "1d12 to see where your actions will fall in the time cube. Ties are resolved by" "rerolling. Each action is rolled with 10 less init than the last until you are out" "of init." }array me @ 1 array_make array_ansi_notify ; SELFCALL cmd.+tc/help : cmd.+init/help cmd.+tc/help ; SELFCALL cmd.+init/help : main param ! prog "cmd." command @ strcat call ;