summaryrefslogblamecommitdiff
path: root/npc/other/Global_Functions.txt
blob: d726210749e5f4aef6f435414b0ad47e00b3ed84 (plain) (tree)
1
2
3
4
5
6




                                                               
        
























                                                                                     

                                                                            
                                                                          
                                                                  
                                                                                     























                                                                                  
                                                      























                                                         















                                                                                  
                                                             















































                                                                                                          
                                                                                              





















































                                                                                                                                           
                                                                                  



























































                                                                                                                             
                                  







































                                                                                  
 
//===== eAthena Script ======================================= 
//= Global Functions
//===== By: ================================================== 
//= Lupus, kobra_k88
//===== Current Version: ===================================== 
//= 2.11
//===== Compatible With: ===================================== 
//= eAthena 1.0
//===== Description: ========================================= 
//= <Description>
//===== Additional Comments: ================================= 
//= Added F_ClearJobVar - on getting a new job it clears all Job Quest variables
//= Removed individual job check functions as they were redundant [kobra_k88]
//= 1.3 Added Job Change Function for Baby/Normal Classes
//= 1.3b a fix, due to const.txt change [Lupus]
//= 1.4 Added Is_Taekwon_Class: Taekwondo, Star Knight(Gladiator),Soul Linker [Lupus]
//= 1.5 Added clear of Bard Quest variables. 1.5a updated [Lupus]
//= 1.6 Added F_RandMes, F_SexMes, F_Hi, F_Bye functions [Lupus]
//= Moved here useful function 'getJobName'
//= 1.7 Added "F_ItemName" function, added a great sample for "F_ItemName"
//= 1.8 Added Job Vars clear for Extended classes: TK,SL,SG [Lupus]
//= 1.9 Added "F_ClearGarbage" func that clears outdated, wasted variables [Lupus]
//= 1.91 Added "F_SaveQuestSkills","F_Load?Skills" functions [Lupus]
//= 2.0 Fixed F_Save/LoadQuestSkills functions. Had to split in into 2 vars [Lupus]
//= 2.01 Added $talk to F_ClearGarbage [Evera]
//= 2.02 Added $dtsglobalelig and $dts|(1<<6) to F_ClearGarbage [Evera]
//= 2.03 Added Gunslinger vars to F_ClearJobVar [Lupus]
//= 2.04 Added dtseligible 2 (becomes MISC_QUEST|128) to F_ClearGarbage [Evera]
//= 2.05 Book of Devil -> MISC_QUEST|256, clear other Niflheim garbage vars [Lupus]
//=	+more garbage clean
//= 2.06 Pass to Bio-Lab -> MISC_QUEST|512 [Lupus]
//= 2.07 Added TK_Q variable clear. 2.08 Added NINJ_Q variable clear [Lupus]
//= 2.09 Cleared F_ClearGarbage [Lupus]
//= 2.10 Added F_CheckMaxCount to check count of carrid items. [L0ne_w0lf]
//= 2.10a Removed fuction F_CheckMaxCount. Not needed. [L0ne_W0lf]
//= 2.11 Updated function Job_Change to jobchange based on Upper value. [Paradox924X]
//============================================================ 


//////////////////////////////////////////////////////////////////////////////////
// Function that clears job quest variables
//////////////////////////////////////////////////////////////////////////////////

function	script	F_ClearJobVar	{
	// Misc ---------------------------------
	set JBLVL,0;
	set FIRSTAID,0;
	set PLAYDEAD,0;
	set got_bandage,0;
	set got_novnametag,0;
	// First Class Jobs ---------------------
	set job_acolyte_q,0; set job_acolyte_q2,0;
	set job_archer_q,0;
	set job_magician_q,0;
	set job_merchant_q,0; set job_merchant_q2,0; set job_merchant_q3,0;
	set job_sword_q,0; set SWTEST, 0;
	set job_thief_q,0;
	// Super Novice
	set SUPNOV_Q,0;
	// 2-1 Jobs ------------------------------
	set ASSIN_Q,0; set ASSIN_Q2,0; set ASSIN_Q3,0;
	set BSMITH_Q,0; set BSMITH_Q2,0;
	set HNTR_Q,0; set HNTR_Q2,0;
	set KNIGHT_Q,0; set KNIGHT_Q2,0;
	set PRIEST_Q,0; set PRIEST_Q2,0; set PRIEST_Q3,0;
	set WIZ_Q,0; set WIZ_Q2,0;
	// 2-2 Jobs ------------------------------
	set ROGUE_Q,0; set ROGUE_Q2,0;
	set ALCH_Q,0; set ALCH_Q2,0;
	set CRUS_Q,0;
	set MONK_Q,0; set JOB_MONK_C,0;
	set SAGE_Q,0; set SAGE_Q2,0;
	set DANC_Q,0;
	set BARD_Q,0;
	// Extended Classes
	set TAEK_Q,0; set TK_Q,0;
	set STGL_Q,0;
	set SOUL_Q,0;
	set GUNS_Q,0;
	set NINJ_Q,0;
	return;
}

function	script	F_ClearGarbage	{
	// Clear outdated global VARS
	//Shinkskas Quest garbage
	if(Shinokas_Quest > 7){
		set ein_scientist,0;
		set ein_stuff,0;
	}
	return;
}

//////////////////////////////////////////////////////////////////////////////////
// Used in REBIRTH scripts
// Class = Internal Class ID
// BaseJob = Base Job (0..23)
// Upper : 0 - Default, 1 - Advanced, 2 - Baby
//////////////////////////////////////////////////////////////////////////////////

function	script	Job_Change	{
	jobchange getarg(0),Upper; //Jobchange based on Upper
	logmes "CLASS CHANGE: " +strcharinfo(0)+ " become a "+jobname(Class);
	return;
}


//////////////////////////////////////////////////////////////////////////////////
// FOT BACKWISE COMPATIBILITY: Functions used to check a players job class
// HOW TO USE:
// i.e. We need all holy classes but monks
// if ( callfunc("Is_Holy_Class") && callfunc("Is_Monk")==0 ) goto L_Start;
//////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////
// returns 1 if the player is either Aco,Monk,Priest,Aco High,High Priest,
// Champion, 0 otherwise
//////////////////////////////////////////////////////////////////////////////////

function	script	Is_Holy_Class	{
	return ( BaseJob==Job_Acolyte || BaseJob==Job_Priest || BaseJob==Job_Monk );
}


//////////////////////////////////////////////////////////////////////////////////
// returns 1 if the player is either Archer,Hunter,Bard,Dancer,Archer High,Sniper,
// Clown,Gypsy, 0 otherwise
//////////////////////////////////////////////////////////////////////////////////

function	script	Is_Bow_Class	{
	return ( BaseJob==Job_Archer || BaseJob==Job_Hunter || BaseJob==Job_Bard || BaseJob==Job_Dancer );
}


//////////////////////////////////////////////////////////////////////////////////
// returns 1 if the player is either Mage,Wizard,Sage,Mage High,High Wizard,
// Professor, 0 otherwise
//////////////////////////////////////////////////////////////////////////////////

function	script	Is_Magic_Class	{
	return ( BaseJob==Job_Mage || BaseJob==Job_Wizard || BaseJob==Job_Sage );
}


//////////////////////////////////////////////////////////////////////////////////
// returns 1 if the player is either Merc,Blacksmith,Alchemist,Merc High,
// Whitesmith,Creator, 0 otherwise
//////////////////////////////////////////////////////////////////////////////////

function	script	Is_Merc_Class	{
	return ( BaseJob==Job_Merchant || BaseJob==Job_Blacksmith || BaseJob==Job_Alchemist );
}


//////////////////////////////////////////////////////////////////////////////////
// returns 1 if the player is either Thief,Assassin,Rogue,Thief High, Assassin Cross
// Stalker, 0 otherwise
//////////////////////////////////////////////////////////////////////////////////

function	script	Is_Thief_Class	{
	return ( BaseJob==Job_Thief || BaseJob==Job_Assassin || BaseJob==Job_Rogue );
}


//////////////////////////////////////////////////////////////////////////////////
// returns 1 if the player is either Swordy,Knight,Crusader,Swordy High,
// Lord Knight,Paladin, 0 otherwise
//////////////////////////////////////////////////////////////////////////////////

function	script	Is_Sword_Class	{
	return ( BaseJob==Job_Swordman || BaseJob==Job_Knight || BaseJob==Job_Knight2 || BaseJob==Job_Crusader || BaseJob==Job_Crusader2 );
}


//////////////////////////////////////////////////////////////////////////////////
// returns 1 if the player is either Taekwon, Star Gladiator,Soul Linker, 0 otherwise
// these classes can't be adopted nor reborn ()
//////////////////////////////////////////////////////////////////////////////////

function	script	Is_Taekwon_Class	{
	return ( Class==Job_Taekwon || Class==Job_Star_Gladiator || Class==Job_Star_Gladiator2 || Class==Job_Soul_Linker );
}


//////////////////////////////////////////////////////////////////////////////////
// Functions used to spiff up dialoges [Lupus]
//////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_RandMes"
//////////////////////////////////////////////////////////////////////////////////
//returns random string
// Example: check F_Bye or F_Hi functions
// READ AND THINK: You can use it to pick a random number form list:
// set @itemIDfromList, callfunc("F_RandMes",8,1129,1222,1163,1357,1360,1522,1811,1410);

function	script	F_RandMes	{
	return getarg(rand(1,getarg(0)));
}


//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_Sex"
//////////////////////////////////////////////////////////////////////////////////
//returns 1st string if female, 2nd string otherwise
// Example: mes callfunc("F_Sex","What a beautiful lady!","What a handsome man!");

function	script	F_SexMes	{
	return getarg(Sex);
}


//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_Hi"
//////////////////////////////////////////////////////////////////////////////////
//returns random HELLO message

function	script	F_Hi	{
	return callfunc("F_RandMes",5,"Hi!","Hello!","Good day!","How are you?","Hello there.");
}


//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_Bye"
//////////////////////////////////////////////////////////////////////////////////
//returns random BYE message

function	script	F_Bye	{
	return callfunc("F_RandMes",6,"Bye. See you again.","Later.","Goodbye.","Good luck!","Have a nice day!","Byebye!!!");
}


//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_ItemName"
//////////////////////////////////////////////////////////////////////////////////
// Returns expanded item name string
//Argumentss
// 0 - Item ID
// 1 - Element N (0=none,1=Ice,2=Earth,3=Fire,4=Wind)
// 2 - VVS meter 0..3
// 3 - Refine
// Example: mes "Show me your "+callfunc("F_ItemName",1201,1,2,5)+"...";
//  is equal to: mes "Show me your ^000090 +5 VVS Fire Knife ^000000..."

function	script	F_ItemName	{
	set @t$,"^000090";
	if(getarg(3)) set @t$,@t$+"+"+getarg(3)+" ";
	if(getarg(2)==1) set @t$,@t$+"VS ";
	if(getarg(2)==2) set @t$,@t$+"VVS ";
	if(getarg(2)==3) set @t$,@t$+"VVVS ";
	if(getarg(2)>3) set @t$,@t$+getarg(2)+"xVS ";
	if(getarg(1)==1) set @t$,@t$+"Ice ";
	if(getarg(1)==2) set @t$,@t$+"Earth ";
	if(getarg(1)==3) set @t$,@t$+"Fire ";
	if(getarg(1)==4) set @t$,@t$+"Wind ";
	if(getarg(1)>4) set @t$,@t$+"Strange ";
	return @t$+getitemname(getarg(0))+"^000000";
}


//////////////////////////////////////////////////////////////////////////////////
// *** Function "getJobName"							//
// [Usage] : callfunc("getJobName",Class);                                      //
//////////////////////////////////////////////////////////////////////////////////

function	script	getJobName	{
	return jobname(getarg(0));
}

//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_SaveQuestSkills": Store learnt quest skills 
//////////////////////////////////////////////////////////////////////////////////
function	script	F_SaveQuestSkills	{
	set ADV_QSK,0; set ADV_QSK2,0;
	//1st classes quest skills
	for(set @i, 0; @i < 14; set @i, @i + 1){
		if(getskilllv(144+@i)) set ADV_QSK,ADV_QSK|pow(2,@i);
	}
	//2nd classes quest skills
	for(set @i, 0; @i < 19; set @i, @i + 1){
		if(getskilllv(1001+@i)) set ADV_QSK2,ADV_QSK2|pow(2,@i);
	}
	return;
}

//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_Load1Skills": Restore learnt 1st class quest skills
//////////////////////////////////////////////////////////////////////////////////
function	script	F_Load1Skills	{
	//1st classes quest skills
	for(set @i, 0; @i < 14; set @i, @i + 1){
		if(ADV_QSK|pow(2,@i) == ADV_QSK) skill 144+@i,1,0;
	}
	set ADV_QSK,0; //Clear var
	return;
}

//////////////////////////////////////////////////////////////////////////////////
// *** Function "F_Load2Skills": Restore learnt 2nd class quest skills
//////////////////////////////////////////////////////////////////////////////////
function	script	F_Load2Skills	{
	//2nd classes quest skills
	for(set @i, 0; @i < 19; set @i, @i + 1){
		if(ADV_QSK2|pow(2,@i) == ADV_QSK2) skill 1001+@i,1,0;
	}
	set ADV_QSK2,0; //Clear var
	return;
}