# # Cosmoquiz Epic v1.2 beta # # by Cosmos (cosmos_42@yahoo.com.au) # # Last modified 13/07/02 # # Default options follow - change these variables to customise @ cq.toggle.scoreboard = [TRUE] @ cq.toggle.random = [TRUE] @ cq.toggle.moderate = [FALSE] @ cq.toggle.autoreset = [TRUE] @ cq.toggle.warnreset = [TRUE] @ cq.toggle.qvalue = [FALSE] @ cq.toggle.notify = [FALSE] @ cq.qvalue = 1 @ cq.penalty = 0 @ cq.target = 10 # End user customisable variables - do not touch the ones below :-) @ cq.togglelist = [scoreboard random moderate autoreset warnreset qvalue notify] @ cq.variablelist = [qvalue penalty target] @ cq.previewed = [FALSE] @ cq.question_asked = [FALSE] window double on ^set status_no_repeat on ^set status_format1 Cosmoquiz Epic v1.2 beta has loaded... ^set status_format2 Press ESC-L to load a file bind meta1-+ parse_command { parsekey erase_line type /cq.player_add ?^H ^set status_format1 Player ADD facility ^set status_format2 Usage: /cq.player_add [] } bind meta1-- parse_command { parsekey erase_line type /cq.player_subtract ?^H ^set status_format1 Player SUBTRACT facility ^set status_format2 Usage: /cq.player_subtract [] } bind meta1-* parse_command { parsekey erase_line type /cq.player_delete ?^H ^set status_format1 Player DELETE facility ^set status_format2 Usage: /cq.player_delete } bind meta1-a parse_command { parsekey erase_line type /cq.ans ?^H } bind meta1-e parse_command { cq.warn_reset } bind meta1-q parse_command { if ([$cq.question_asked] == [TRUE]) { cq.repeat } { cq.generate cq.preview parsekey erase_line if ([$cq.file_empty] != [TRUE]) {type /cq.ask} } } bind meta1-f parse_command { cq.scores_final } bind meta1-h parse_command { parsekey erase_line type /cq.hint ?^H } bind meta1-j parse_command { ^set status_format1 JUMP to question facility ^set status_format2 Usage: /cq.jump parsekey erase_line type /cq.jump ?^H } bind meta1-l parse_command { ^set status_format1 File LOAD facility ^set status_format2 Usage: /cq.loadfile parsekey erase_line type /cq.loadfile ?^H } bind meta1-r parse_command { parsekey erase_line @ cq.alist = [$shift(cq.answerlist)] push cq.answerlist $cq.alist xtype -l /cq.ans $decode($cq.alist) } bind meta1-s parse_command { cq.scores } bind meta1-t parse_command { @ cq.totoggle = [$shift(cq.togglelist)] push cq.togglelist $cq.totoggle ^set status_user8 $cq.toggle[$cq.totoggle] switch ($cq.totoggle) { (scoreboard) { ^set status_format1 SCOREBOARD display is %8 ^set status_format2 Press ENTER to toggle... parsekey erase_line type /cq.toggle scoreboard } (random) { ^set status_format1 RANDOM question generation is %8 ^set status_format2 Press ENTER to toggle... parsekey erase_line type /cq.toggle random } (moderate) { ^set status_format1 MODERATE channel on final scores is %8 ^set status_format2 Press ENTER to toggle... parsekey erase_line type /cq.toggle moderate } (autoreset) { ^set status_format1 AUTORESET of scores on final scoreboard is %8 ^set status_format2 Press ENTER to toggle... parsekey erase_line type /cq.toggle autoreset } (warnreset) { ^set status_format1 WARN before scores are reset is %8 ^set status_format2 Press ENTER to toggle... parsekey erase_line type /cq.toggle warnreset } (qvalue) { ^set status_format1 DISPLAY question value is %8 ^set status_format2 Press ENTER to toggle... parsekey erase_line type /cq.toggle qvalue } (notify) { ^set status_format1 NOTIFY when player has reached target is %8 ^set status_format2 Press ENTER to toggle... parsekey erase_line type /cq.toggle notify } } } bind meta1-u parse_command { ^set status_format1 Do you really want to unload Cosmoquiz Epic? ^set status_format2 Press ENTER to unload parsekey erase_line type /cq.unload } bind meta1-v parse_command { @ cq.tochange = [$shift(cq.variablelist)] push cq.variablelist $cq.tochange switch ($cq.tochange) { (qvalue) { ^set status_user8 $cq.qvalue ^set status_format1 VALUE of questions is currently %8 ^set status_format2 USAGE: /@ cq.qvalue = parsekey erase_line type /@ cq.qvalue = ?^H } (penalty) { ^set status_user8 $cq.penalty ^set status_format1 PENALTY for giving hints is currently %8 ^set status_format2 USAGE: /@ cq.penalty = parsekey erase_line type /@ cq.penalty = ?^H } (target) { ^set status_user8 $cq.target ^set status_format1 TARGET score is currently %8 ^set status_format2 USAGE: /@ cq.target = parsekey erase_line type /@ cq.target = ?^H } } } bind meta1-x parse_command { cq.skip } on #-nickname 666 * { timer 1 { userhost $1 -cmd { @ cq.new_nick = [$pattern($0 $onchannel())] @ cq.new_host = [$encode($4)] } if (cq.hostid[$cq.new_host] != []) { @ cq.player[$cq.hostid[$cq.new_host]][nick] = [$cq.new_nick] @ cq.nickid[$encode($toupper($cq.new_nick))] = cq.hostid[$cq.new_host] ^assign -cq.nickid[$encode($toupper($0))] } } } on #-public 667 * { if ([$cq.question_asked] == [TRUE]) { if ([$pattern($0 $cq.answerlist)] == []) { push cq.answerlist $encode($0) } } } alias cq.toggle { if ([$cq.toggle[$0]] == [TRUE]) { @ cq.toggle[$0] = [FALSE] } { @ cq.toggle[$0] = [TRUE] } ^set status_user8 $0 ^set status_user9 $cq.toggle[$0] ^set status_format1 %8 is now %9 ^set status_format2 %{6}0 } alias cq.unload { ^bind meta1-+ NOTHING ^bind meta1-- NOTHING ^bind meta1-* NOTHING ^bind meta1-a NOTHING ^bind meta1-e SCROLL_END ^bind meta1-f FORWARD_WORD ^bind meta1-h DELETE_PREVIOUS_WORD ^bind meta1-l NOTHING ^bind meta1-q NOTHING ^bind meta1-r NOTHING ^bind meta1-s NOTHING ^bind meta1-t NOTHING ^bind meta1-u NOTHING ^bind meta1-v NOTHING ^bind meta1-x NOTHING ^on #-nickname 666 - ^on #-public 667 - cq.scores_reset ^set status_format1 Now unloading Cosmoquiz ^set status_format2 Please wait.... foreach cq xx { ^assign -cq[$xx] foreach cq.${xx} yy { ^assign -cq[$xx][$yy] } } foreach -cq zz { ^alias -cq[$zz] } ^window double off ^set status_format %T [%R] %*%=%@%N%#%S%H%B%Q%A%C%+%I%O%M%F%L %D %U %W echo *** Cosmoepic unloaded! } alias cq.warn_reset { ^set status_format1 WARNING - Do you want to reset all scores? ^set status_format2 Press ENTER to reset scores parsekey erase_line type /cq.scores_reset } alias cq.scores_reset { @ cq.total_players = 0 foreach cq.player xx { foreach cq.player.${xx} yy { ^assign -cq.player[$xx][$yy] } } foreach cq.hostid xx { ^assign -cq.hostid[$xx] } foreach cq.nickid xx { ^assign -cq.nickid[$xx] } ^set status_format1 Scores reset... ^set status_format2 Press ESC-Q to preview next question } alias cq.loadfile { if ( [$fexist($0)] == [1]) { ^set status_format1 Now checking file format ^set status_format2 Please wait... @ cq.file_handle = [$open($0 R)] @ cq.file_newlines = -1 while ( [$eof($cq.file_handle)] == 0) { @ cq.temp = [$read($cq.file_handle)] @ cq.file_newlines++ } @ cq.temp = [$close($cq.file_handle)] @ cq.file_modulus = cq.file_newlines % 2 if ( cq.file_modulus == 0 ) { @ cq.file_name = [$0] @ cq.file_lines = cq.file_newlines @ cq.file_questions = cq.file_lines / 2 @ cq.asked_total = 0 @ cq.pointer = 0 @ cq.previewed = [FALSE] @ cq.file_empty = [FALSE] foreach cq.asked xx { ^assign -cq.asked[$xx] } foreach cq.q xx { ^assign -cq.q[$xx] } foreach cq.a xx { ^assign -cq.a[$xx] } ^set status_format1 File format OK - reading questions to memory @ cq.file_handle = [$open($0 R)] @ cq.loop = 1 while (cq.loop <= cq.file_questions) { if ((cq.loop % 100) == 0) { ^set status_user8 $cq.loop ^set status_user9 $cq.file_questions ^set status_format2 Please wait... Read in %8 of %9 questions } @ cq.q[$cq.loop] = [$read($cq.file_handle)] @ cq.a[$cq.loop] = [$read($cq.file_handle)] @ cq.loop++ } @ cq.temp = [$close($cq.file_handle)] ^set status_user8 $cq.file_name ^set status_user9 $cq.file_questions ^set status_format1 File %8 has %9 questions ^set status_format2 Press ESC-Q to preview next question } { ^set status_format1 Sorry, file has an uneven number of lines! ^set status_format2 Press ESC-L to load another file @ cq.temp = [$close($cq.file_handle)] } } { echo *** Sorry, that file does not exist } } alias cq.check_showvalue { if ([$cq.toggle.qvalue] == [TRUE]) { if (cq.qvalue_current == 1) { @ cq.points = [< 1 Pt > ] } { @ cq.points = [< $cq.qvalue_current Pts > ] } } { ^assign -cq.points } } alias cq.generate { if (( cq.asked_total >= cq.file_questions) || ([$cq.file_name] == [])) { echo *** Sorry, you are out of questions! @ cq.file_empty = [TRUE] ^set status_user3 $cq.pointer ^set status_user4 $cq.asked_total ^set status_user5 $cq.file_questions } { if ([$cq.toggle.random] == [TRUE]) { @ cq.pointer = [$rand($cq.file_questions)] + 1 while ( [$cq.asked[$cq.pointer]] == [TRUE] ) { @ cq.pointer = [$rand($cq.file_questions)] + 1 } } { if ((cq.pointer < 1) || (cq.pointer >= cq.file_questions)) { @ cq.pointer = 1 } while ([$cq.asked[$cq.pointer]] == [TRUE]) { @ cq.pointer++ } } @ cq.question_preview = [$cq.q[$cq.pointer]] @ cq.answer_preview = [$cq.a[$cq.pointer]] @ cq.previewed = [TRUE] } } alias cq.preview { if ([$cq.file_empty] != [TRUE]) { ^set status_user3 $cq.pointer ^set status_user4 $cq.asked_total ^set status_user5 $cq.file_questions ^set status_format1 Q: $left(68 $cq.question_preview) %> #%3 ^set status_format2 A: $left(63 $cq.answer_preview) %> (%4/%5) } } alias cq.jump { if (([$0] >= 1) && ([$0] <= cq.file_questions) && ([$cq.file_name] != "")) { if ([$cq.asked[$0]] != [TRUE]) { @ cq.pointer = [$0] @ cq.question_preview = [$cq.q[$cq.pointer]] @ cq.answer_preview = [$cq.a[$cq.pointer]] @ cq.previewed = [TRUE] cq.preview } { ^set status_user9 $0 ^set status_format1 Sorry, question %9 has already been asked ^set status_format2 Please enter another number to jump to... parsekey erase_line type /cq.jump ?^H } } { ^set status_user9 that ^set status_user9 $0 ^set status_format1 Sorry, %9 is an invalid question ^set status_format2 Please enter another number to jump to... parsekey erase_line type /cq.jump ?^H } } alias cq.skip { if (([$cq.pointer] != "") && (cq.asked_total < cq.file_questions)) { echo *** Question skipped! @ cq.asked[$cq.pointer] = [TRUE] @ cq.asked_total++ @ cq.previewed = [FALSE] cq.generate cq.preview } { echo *** No question to skip } } alias cq.ask { @ cq.qvalue_current = cq.qvalue if ([$numwords($*)] == 0) { if ([$cq.previewed] == [FALSE]) { cq.generate cq.preview } @ cq.question = [$cq.question_preview] @ cq.answer = [$cq.answer_preview] if ([$cq.file_empty] != [TRUE]) { cq.check_showvalue me Q: ${cq.points}$cq.question @ cq.asked[$cq.pointer] = [TRUE] @ cq.asked_total++ @ cq.previewed = [FALSE] @ cq.question_asked = [TRUE] ^assign -cq.answerlist } } { @ cq.question = [$*] ^assign -cq.answer me Q: $* @ cq.question_asked = [TRUE] ^assign -cq.answerlist } ^set status_user3 $cq.pointer ^set status_user4 $cq.asked_total ^set status_user5 $cq.file_questions } alias cq.repeat { cq.check_showvalue me Q: ${cq.points}$cq.question } alias cq.hint { @ cq.qvalue_current = cq.qvalue_current - cq.penalty if (cq.qvalue_current <= 0) { @ cq.qvalue_current = 1 } cq.check_showvalue me ${cq.points}HINT: $* } alias cq.lookup { ^assign -cq.current_host ^assign -cq.current_nick if ([$0] != []) { userhost $0 -cmd { @ cq.current_nick = [$pattern($0 $onchannel())] @ cq.current_host = [$encode($4)] } } } alias cq.ans { if ([$numwords($*)] == 0) { me The correct answer was: $cq.answer if ([$cq.toggle.scoreboard] == [TRUE]) {cq.scores} @ cq.question_asked = [FALSE] cq.generate cq.preview parsekey erase_line if ([$cq.file_empty] != [TRUE]) {type /cq.ask} } { if ([$1] == []) { @ cq.answer_to_give = [$cq.answer] } { @ cq.answer_to_give = [$1-] } if ([$pattern($0 $onchannel())] == []) { echo *** Sorry, $0 is not in $C } { @ cq.question_asked = [FALSE] cq.lookup $0 me < $cq.current_nick > !!!!!!! ${cq.points}Answer: $cq.answer_to_give if ([$cq.hostid[$cq.current_host]] == []) { @ cq.total_players++ @ cq.player[$cq.total_players][host] = [$cq.current_host] @ cq.player[$cq.total_players][nick] = [$cq.current_nick] @ cq.player[$cq.total_players][score] = [$cq.qvalue_current] @ cq.hostid[$cq.current_host] = [$cq.total_players] @ cq.nickid[$encode($toupper($cq.current_nick))] = [$cq.total_players] } { @ cq.player[$cq.hostid[$cq.current_host]][score]+= cq.qvalue_current @ cq.player[$cq.hostid[$cq.current_host]][nick] = [$cq.current_nick] @ cq.nickid[$encode($toupper($cq.current_nick))] = [$cq.hostid[$cq.current_host]] } if ([$cq.toggle.scoreboard] == [TRUE]) {cq.scores} cq.generate cq.preview parsekey erase_line if ([$cq.file_empty] != [TRUE]) {type /cq.ask} cq.check_target } } } alias cq.check_target { cq.sort if ((cq.player.1.score >= cq.target) && ([$cq.toggle.notify] == [TRUE]) && ([$cq.player_target] != [TRUE])) { @ cq.player_target = [TRUE] ^set status_user8 $cq.player.1.nick ^set status_user9 $cq.target ^set status_format1 %8 has reached target score of %9 ^set status_format2 Press ENTER to show final scores parsekey erase_line type /cq.scores_final } } alias cq.sort { @ cq.swapflag = [TRUE] @ cq.loop2 = 0 while ([$cq.swapflag] == [TRUE]) { @ cq.swapflag = [FALSE] @ cq.loop = 1 @ cq.loop2++ while (cq.loop <= (cq.total_players - cq.loop2)) { if ( cq.player[$cq.loop].score < cq.player[${cq.loop + 1}].score) { @ cq.tempnick1 = [$cq.player[$cq.loop][nick]] @ cq.temphost1 = [$cq.player[$cq.loop][host]] @ cq.tempscore1 = [$cq.player[$cq.loop][score]] @ cq.tempid1 = [$cq.hostid[$cq.temphost1]] @ cq.tempnickid1 = [$cq.nickid[$encode($toupper($cq.tempnick1))]] @ cq.tempnick2 = [$cq.player[${cq.loop + 1}][nick]] @ cq.temphost2 = [$cq.player[${cq.loop + 1}][host]] @ cq.tempscore2 = [$cq.player[${cq.loop + 1}][score]] @ cq.tempid2 = [$cq.hostid[$cq.temphost2]] @ cq.tempnickid2 = [$cq.nickid[$encode($toupper($cq.tempnick2))]] @ cq.player[$cq.loop][nick] = [$cq.tempnick2] @ cq.player[$cq.loop][host] = [$cq.temphost2] @ cq.player[$cq.loop][score] = [$cq.tempscore2] @ cq.hostid[$cq.temphost1] = [$cq.tempid2] @ cq.nickid[$encode($toupper($cq.tempnick1))] = [$cq.tempnickid2] @ cq.player[${cq.loop + 1}][nick] = [$cq.tempnick1] @ cq.player[${cq.loop + 1}][host] = [$cq.temphost1] @ cq.player[${cq.loop + 1}][score] = [$cq.tempscore1] @ cq.hostid[$cq.temphost2] = [$cq.tempid1] @ cq.nickid[$encode($toupper($cq.tempnick2))] = [$cq.tempnickid1] @ cq.swapflag = [TRUE] } @ cq.loop++ } } } alias cq.scores { if (cq.total_players > 0 ) { cq.sort @ cq.loop = 1 @ cq.scorestring = [Scores:] while (cq.loop <= cq.total_players) { @ cq.scorestring #= [ $cq.player[$cq.loop][nick]] @ cq.scorestring #= [\(] @ cq.scorestring #= [$cq.player[$cq.loop][score]] @ cq.scorestring #= [\),] @ cq.loop++ } me $chop(1 $cq.scorestring). } { echo *** The scoreboard is empty! } } alias cq.scores_final { if (cq.total_players > 0) { if (([$ischanop($N $C)] == [1]) && ([$cq.toggle.moderate] == [TRUE])) { mode $C +m @ cq.mod_delay = 1 } { @ cq.mod_delay = 0 } timer $cq.mod_delay me ---- FINAL SCORES ---- cq.sort @ cq.loop = 0 @ cq.place_marker = 0 while (cq.loop < cq.total_players) { @ cq.loop++ @ cq.place_marker++ switch ($right(1 $cq.place_marker)) { (1) { @ cq.placeid = [st] } (2) { @ cq.placeid = [nd] } (3) { @ cq.placeid = [rd] } (*) { @ cq.placeid = [th] } } if (cq.player[$cq.loop][score] < 10) { @ cq.leadingzero = [0] } { @ cq.leadingzero = [] } @ cq.scorestring = [${cq.place_marker}$cq.placeid - ${cq.leadingzero}$cq.player[$cq.loop][score] pts - $cq.player[$cq.loop][nick]] while (cq.player[$cq.loop][score] == cq.player[${cq.loop+1}][score]) { @ cq.loop++ @ cq.scorestring #= [, $cq.player[$cq.loop][nick]] } timer ${cq.place_marker + cq.mod_delay} me $cq.scorestring } if (([$ischanop($N $C)] == [1]) && ([$cq.toggle.moderate] == [TRUE])) { timer ${cq.place_marker + 2} mode $C -m } if ([$cq.toggle.autoreset] == [TRUE]) { if ([$cq.toggle.warnreset] == [TRUE]) { cq.warn_reset } { cq.scores_reset } } } { echo *** The scoreboard is empty! } } alias cq.player_add { if ([$isdigit($1)] == [1]) { @ cq.toadd = [$1] } { @ cq.toadd = 1 } cq.lookup $0 if ([$cq.hostid[$cq.current_host]] != []) { @ cq.player[$cq.hostid[$cq.current_host]][score]+= cq.toadd @ cq.player[$cq.hostid[$cq.current_host]][nick] = [$cq.current_nick] @ cq.nickid[$encode($toupper($cq.current_nick))] = [$cq.hostid[$cq.current_host]] ^set status_user8 $cq.toadd ^set status_user9 $pattern($0 $onchannel()) ^set status_format1 Success! ^set status_format2 %8 point(s) added to %9 } { if ([$cq.nickid[$encode($toupper($0))]] != []) { @ cq.player[$cq.nickid[$encode($toupper($0))]][score]+= 1 ^set status_user8 $cq.toadd ^set status_user9 $pattern($0 $onchannel()) ^set status_format1 Success! ^set status_format2 %8 point(s) added to %9 } { if ([$pattern($0 $onchannel())] != []) { @ cq.total_players++ @ cq.player[$cq.total_players][host] = [$cq.current_host] @ cq.player[$cq.total_players][nick] = [$cq.current_nick] @ cq.player[$cq.total_players][score] = cq.toadd @ cq.hostid[$cq.current_host] = [$cq.total_players] @ cq.nickid[$encode($toupper($cq.current_nick))] = [$cq.total_players] ^set status_user8 $cq.toadd ^set status_user9 $pattern($0 $onchannel()) ^set status_format1 Success! ^set status_format2 %8 point(s) added to %9 } { ^set status_user8 $0 ^set status_user9 $C ^set status_format1 ERROR! ^set status_format2 %8 is not in %9 } } } cq.check_target } alias cq.player_subtract { if ([$isdigit($1)] == [1]) { @ cq.tosub = [$1] } { @ cq.tosub = 1 } if ([$cq.nickid[$encode($toupper($0))]] != []) { @ cq.player[$cq.nickid[$encode($toupper($0))]][score]-= cq.tosub ^set status_user8 $cq.tosub ^set status_user9 $pattern($0 $onchannel()) ^set status_format1 Success! ^set status_format2 %8 point(s) subtracted from %9 if (cq.player[$cq.nickid[$encode($toupper($0))]][score] <= 0) { cq.player_delete $0 } } { ^set status_user8 $pattern($0 $onchannel()) ^set status_format1 ERROR! ^set status_format2 %8 is not on the scoreboard } } alias cq.player_delete { if ([$cq.nickid[$encode($toupper($0))]] != []) { @ cq.player[$cq.nickid[$encode($toupper($0))]] = -1000 cq.sort ^assign -cq.hostid[$cq.player[$cq.total_players][host]] ^assign -cq.nickid[$encode($toupper($0))] foreach cq.player[$cq.total_players] xx { ^assign -cq.player[$cq.total_players][$xx] } @ cq.total_players-- ^set status_user8 $pattern($0 $onchannel()) ^set status_format1 Success! ^set status_format2 %8 deleted from scoreboard } { ^set status_user8 $0 ^set status_format1 ERROR! ^set status_format2 %8 is not on the scoreboard } }