Habilis

[AutoEvent] Trivia

5 posts in this topic

Hello, as promised here is a Trivia auto event.

This script is originally way back from eA, it was adjusted on rA. (All credits in the header)

And now, I decided to Enhance it.

P888Zdq.jpg

- An enhanced version of facts auto event. The Event is announced. The NPC asks 10 random 
- questions from a question bank. Players have to write the answer to the main chat.
- Players don't need to worry about CAPITAL letters.
- 1) Question is asked by the NPC.

l33tzjF.jpg
- 2) If there is no answer after 15 seconds NPC will give a hint.

ahaNusT.jpg
- 3) IF there is still no answer after a hint, the question is skipped.

ZB5wgGq.jpg
- 4) If the right answer is given, the player is announced and the reward is given

2k8BuqW.jpg

 

Side notes:

1) Control

If you have some kind of AutoEbent Controller, I've included the event control methods

OnEventStart:

OnStop:

OnEventTimeOut:

 

If you don't have a controller and just want to test this event, just setup the timers, when this event will run ex:

OnMinute33:

 

2) Rewards

I have special Event points, that I'm giving to the winners.

If you like to give Items or Zeny, I Included the examples in the code

// Winner gets reward in Zeny
//Zeny += 1000000; // Alotta bax ;)

 

3) Questions definition

To define more questions you need to follow this pattern

DefineQuestion("<question>", "<answer>", "<hint>");

 

4) Cheating

I'm aware that this event can be cheated/Automated by players.

Therefore only a modest reward is given :blush:

 

//===== Hercules Script ====================================================================
// Automatic Trivia Event
//===== Originally initiated By: ===========================================================
// Capuche http://rathena.org/board/user/5984-capuche/
//===== Changed By: ========================================================================
// Habilis
//===== Current Version: ===================================================================
// 1.5
//===== Compatible With: ===================================================================
// Hercules
//===== Description: =======================================================================
//- Enhanced version of facts auto event. The Event is announced. The NPC asks 10 random 
//- questions from a question bank. Players have to write the answer to the main chat.
//- Players don't need to worry about CAPITAL letters.
//- 1) Question is asked by the NPC.
//- 2) If there is no answer after 15 seconds NPC will give a hint.
//- 3) IF there is still no answer after a hint, the question is skipped.
//- 4) If the right answer is given, player is announced and reward is given
//==========================================================================================
//=====From eAthena to rAthena to Hercules==================================================
//==========Without this original author, this script will never exist======================
//========Original author Credits===========================================================
//=====================================================DONT=================================
// ToastOfDoom ================================================REMOVE=======================
// RxChris	   =========================================================THIS================
// Hellflaem   ================================================================CREDIT=======
//==========================================================================================
//==========================================================================================


-	script	Trivia_Auto_Event	FAKE_NPC ,{
	
	OnMinute18:
	//OnEventStart:
		// Make the NPC appear so that players can begin to gather around
		// and perhaps read the rules
		enablenpc "Trivia#main";
		.@nbAnnounce = 3; // How many times announce event with minute intervals
		while( .@nbAnnounce > 0 ) {
			announce "The Trivia Event will begin south of Prontera in " + .@nbAnnounce + " minute(s).",bc_all | bc_blue;
			.@nbAnnounce--;
			sleep 60000;
		}
	    announce "The Trivia Event has begun!",bc_all | bc_blue;
		donpcevent "Trivia#main::OnEventBegin";
		end;
		
	OnStop:	
	OnEventTimeOut:
		disablenpc "Trivia#main";
		end;
	
	OnInit:
		disablenpc "Trivia#main";
		end;
}


prt_fild08,137,365,6	script	Trivia#main	4_F_JOB_ASSASSIN,{

OnTalk:
	mes "[^0055FF ::: Trivia ::: ^000000]";
	mes " ";
	mes "Very simple event!";
	mes " ";
	mes "I will be asking random questions.";
	mes " ";
	mes "All you have to do is shout the answer in the main chat!";
	mes " ";
	mes "Do not worry about the capital letters, I can recognize the right answer, when I see one ;)";
	mes "Worry about the spelling though.";
	
	close2;
	end;

function DefineQuestion; function GetQuestion; function GetAnswer; function GetHint;

OnEventBegin:
L_loop:
	do {
		.@i = rand(.numQuestions); // Randomly picks a fact.
	} while(.already_asked[.@i]);
	
	.already_asked[.@i] = true;
	
	if( !.count ) {
		npctalk "Please answer all my questions:";
		sleep 2000;
		npctalk "If your answer is correct, you will obtain prizes!";
	}
	.count++;
	sleep 4000;
	npctalk "[" + .count + "/" + .max_questions + "] " + GetQuestion(.@i);
	defpattern 1, "([^:]+):.*\\s" + GetAnswer( .@i ) + "(.*)", "Right";
	.Ans$ = GetAnswer( .@i );
	.Hint$ = GetHint( .@i );;
	activatepset 1;
	initnpctimer;
	end;
	
OnTimer15000:
	npctalk "[Hint] : " + .Hint$;
	end;
OnTimer30000:
	npctalk "Sorry, You took too long to answer.";
	callsub L_continue;
	end;
	
Right:
	npctalk "Correct, " + strcharinfo(0) + "! The answer is  " + .Ans$ + ".";
	
	// Winner gets reward in Zeny
	//Zeny += 1000000; // Alotta bax ;)
	
	// Winner gets reward in Item
	//getitem 607, rand( 1,10 ); // Randomly picks from 1 to 10   607 --Ygg berry~ .
	
	// Winner gets reward in Points
	.@pointsWon = rand(.minPoints,.maxPoints);
	#LROEVENTPOINTS = #LROEVENTPOINTS + [email protected];
	dispbottom .ServerName$  + " : You won " + .@pointsWon + " event points.";
	
L_continue:
	deletepset 1;
	stopnpctimer;
	if( .count < .max_questions ) {
		callsub L_loop; // loop 10 questions
	}
	.count = 0; // end of event
	.Q_session = 0;
	npctalk "That's all for now. Thanks for participating in this event ^^";
	deletearray .already_asked, getarraysize(.already_asked);
	emotion e_thx;
	sleep 2000;
	disablenpc "Trivia#main";
	end;

function DefineQuestion {
	.@a = .numQuestions % 128;
	.@b = .numQuestions / 128;

	setd(".question_" + .@a + "$[" + .@b + "]", getarg(0));
	setd(".answer_" + .@a + "$[" + .@b + "]", getarg(1));
	setd(".hint_" + .@a + "$[" + .@b + "]", getarg(2));
	
	.numQuestions = .numQuestions + 1;
	return;
}
function GetQuestion {
	return getd(".question_" + (getarg(0) % 128) + "$[" + (getarg(0) / 128) + "]");
}
function GetAnswer {
	return getd(".answer_" + (getarg(0) % 128) + "$[" + (getarg(0) / 128) + "]");
}
function GetHint {
	return getd(".hint_" + (getarg(0) % 128) + "$[" + (getarg(0) / 128) + "]");
}

OnInit:
	.ServerName$ = "[Your boring server]";
	.minPoints = 10;
	.maxPoints = 25;
	.max_questions = 10;	// 10 questions if more than 10 questions are defined
	DefineQuestion("When you create a character in this game, how many primary stats are there?","6", "STR, AGI, VIT, INT, DEX, LUK");
	DefineQuestion("Wizard skill Water Ball can only be cast over deluge or ____?", "water", "It is liquid.");
	DefineQuestion("Which item is required to create a guild?", "emperium", "An Emperial item");
	DefineQuestion("which skill is beneficial to the living and damaging to the undead?", "heal", "It restores health.");
	DefineQuestion("In which town Thieves guild is located?", "morocc", "A town in the sorgat desert.");
	DefineQuestion("In which town Merchants guild is located?", "alberta", "It's a portuary town.");
	DefineQuestion("In which town Archers guild is located?", "payon", "");
	DefineQuestion("What property do Izlude dungeon monsters possess?", "water", "It is liquid.");
	DefineQuestion("What status can be inflicted with the Hammer Fall skill?", "stun", "Did I see the stars around your head?");
	DefineQuestion("How much Zeny one Jellopy is worth?", "3", "Just get it from a Poring.");
	DefineQuestion("Which town has the most Dancers?", "comodo", "An island in the warm waters.");
	DefineQuestion("How many different poring-like monsters you can meet near prontera, including mini bosses?", "9", "poring, drops, poporing, marin, santa poring, mastering, angeling, arcangeling, ghostring");
	DefineQuestion("What property counters best the water property?", "wind", "It's Blowing");
	DefineQuestion("What property counters best the undead property?", "holy", "Perhaps an acolyte or a priest can tell you?");
	DefineQuestion("What kind of food both Vanilmirth and Christmas Goblin like?", "scel", "Yellow jeloppy");
	DefineQuestion("How many cities are in Rune-Midgrad kingdom?", "11", "Prontera, Izlude, Jawaii, Geffen, Payon, Morocc, Alberta, Comodo, Umbala, Al De Baran, Lutie");
	DefineQuestion("What city is the capital of Rune-Midgrad kingdom?", "prontera", "The most central town of all.");
	DefineQuestion("Which food is able to fully restore health and mana? _________ _____", "yggdrasil berry", "A berry growing on the most majestic tree!");
	DefineQuestion("Which one of those is the fastest weapon type? Sword, Dagger, Staff, Mace", "dagger", "Something that has to do with the length of the blade.");
	DefineQuestion("Which one of those id the cheapest? Jellopy  Large Jellopy   Royal Jelly   Honey", "jellopy", "Dropped by Porings.");
	DefineQuestion("Which monster drops a pet taming item to tame Deviruchi?", "joker", "Why so serious?");
	
	if( .numQuestions < .max_questions ) .max_questions = .numQuestions;
	end;
}

Enjoy!

 

Edited by Mystery
Spoiler.

Share this post


Link to post
Share on other sites
function GetQuestion {
	return getd(".question_" + (getarg(0) % 128) + "$[" + (getarg(0) / 128) + "]");
}
function GetAnswer {
	return getd(".answer_" + (getarg(0) % 128) + "$[" + (getarg(0) / 128) + "]");
}
function GetHint {
	return getd(".hint_" + (getarg(0) % 128) + "$[" + (getarg(0) / 128) + "]");
}

I believe you made it opposite ?
assuming that you are still using eathena, when script engine was still 128 elements
it should be

return getd(".question_" + (getarg(0) / 128) + "$[" + (getarg(0) % 128) + "]");

although there is no need to do like this anymore because our script engine no longer has such limitation


2nd thing is ...

L_loop:
	do
		set [email protected], rand( .numQuestions ); // Randomly picks a fact.
	while( .Q_session & 1 << [email protected] && .Q_session && .count < .numQuestions );
	set .Q_session, .Q_session | 1 << [email protected];// max 32 questions

rather than using a loop, can use shuffle algorithm

 

EDIT: for below

Spoiler

http://upaste.me/a79d49943d1688aec
let you have fun fixing the script 1st :P

 

Edited by AnnieRuru

Share this post


Link to post
Share on other sites

Thanks Annie,

1 is not me, it is from way back ... eA days

2 will be redone, I will follow Dastgir`s advice and use an array instead of bit manipulation

(will make the script easier to understand for beginners)

 

 

I Already coded it, need to test it

Share this post


Link to post
Share on other sites

Edited the first post with the updated version of script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now