summaryrefslogblamecommitdiff
path: root/npc/custom/eAAC_Scripts/kafraExpress/ke_broadcast.txt
blob: 73b8c4e20fe531d9366bf5c5fac32350f5d22654 (plain) (tree)






























































































































































































































                                                                                                                                                                                                 
 
//===== eAthena Script ======================================= 
//= Kafra Express - Broadcasting Module
//===== By: ================================================== 
//= Skotlex 
//===== Current Version: ===================================== 
//= 3.0
//===== Compatible With: ===================================== 
//= eAthena SVN3424+
//===== Description: ========================================= 
//= Part of the Kafra Express Script Package.
//= Offers broadcasting for party requests, pvp, general
//= and anonymous. Broadcasts can be to the current map 
//= or server-wide
//===== Additional Comments: ================================= 
//= See config.txt for configuration.
//= For the PVP broadcasts, variables from the Pvp Warping
//= Module are used.
//============================================================ 

-	script	keInit_broadcast	-1,{
OnInit:	//Load Config
	donpcevent "keConfig::OnLoadBroadcast";
	end;
}

//Function F_keBroadcast(String currentMapName)
function	script	F_keBroadcast	{

	function	SF_calcPrice;
	function	SF_broadcasts;
	function	SF_bcPvp;
	function	SF_doBroadcast;

	if ($@kebc_showOnline) {
		set @kmenu, select(
			"- Return",
			"- Map Broadcasts ("+getarg(0)+"/"+getmapusers(getarg(0))+" "+$@ked_users$+")",
			"- Global Broadcasts ("+getusers(1)+" "+$@ked_users$+")"
		);
	} else {
		set @kmenu, select(
			"- Return",
			"- Map Broadcasts ("+getarg(0)+")",
			"- Global Broadcasts"
		);
	}
	switch(@kmenu) {
	case 2:
		SF_calcPrice(0);
		set @map$,getarg(0);
		SF_broadcasts("Map ("+getarg(0)+")");
		break;
	case 3:
		SF_calcPrice(1);
		set @map$,"";
		SF_broadcasts("Global");
		break;
	}
return;

//Sub Function SF_broadcasts: Handles main broadcast menu. 
function	SF_broadcasts	{

	do {
		switch (select (
			"- Cancel "+getarg(0)+" Broadcast",
			"- Party request Broadcast ("+@partycost+"z)",
			"- PvP challenge Broadcast ("+@pvpcost+"z)",
			"- General Broadcast ("+@cost+"z)",
			"- General Anonymous Broadcast ("+@anoncost+"z)"
		)) {
		case 2:	//Party
			SF_doBroadcast $@kebc_partyCost,@map$,"The "+callfunc("GF_getJobName",class)+" "+strcharinfo(0)+" (levels "+baselevel+"/"+joblevel+") is looking for a party to join.",0;
			break;
		case 3:	//Pvp
			if ($@kewp_advanced == 0)
				SF_bcPvp $@kebc_pvpCost,@map$,0,0;
			else {
				do {
					set @kmenu, select (
						"- Cancel",
						"- advertise all levels rooms",
						"- advertise levels "+($@kewp_baseLv1-$@kewp_range)+"-"+($@kewp_baseLv1+$@kewp_range)+" rooms",
						"- advertise levels "+($@kewp_baseLv2-$@kewp_range)+"-"+($@kewp_baseLv2+$@kewp_range)+" rooms",
						"- advertise levels "+($@kewp_baseLv3-$@kewp_range)+"-"+($@kewp_baseLv3+$@kewp_range)+" rooms",
						"- advertise levels "+($@kewp_baseLv4-$@kewp_range)+"-"+($@kewp_baseLv4+$@kewp_range)+" rooms",
						"- advertise levels "+($@kewp_baseLv5-$@kewp_range)+"-"+($@kewp_baseLv5+$@kewp_range)+" rooms",
						"- advertise levels "+($@kewp_baseLv6-$@kewp_range)+"-"+($@kewp_baseLv6+$@kewp_range)+" rooms",
						"- advertise levels "+($@kewp_baseLv7-$@kewp_range)+"-"+($@kewp_baseLv7+$@kewp_range)+" rooms"
					);
					switch (@kmenu) {
					case 2: //All levels
						SF_bcPvp $@kebc_pvpCost,@map$,0,0;
						break;
					case 3: //Lv1
						SF_bcPvp $@kebc_pvpCost,@map$,$@kewp_baseLv1-$@kewp_range,$@kewp_baseLv1+$@kewp_range;
						break;
					case 4: //Lv2
						SF_bcPvp $@kebc_pvpCost,@map$,$@kewp_baseLv2-$@kewp_range,$@kewp_baseLv2+$@kewp_range;
						break;
					case 5: //Lv3
						SF_bcPvp $@kebc_pvpCost,@map$,$@kewp_baseLv3-$@kewp_range,$@kewp_baseLv3+$@kewp_range;
						break;
					case 6: //Lv4
						SF_bcPvp $@kebc_pvpCost,@map$,$@kewp_baseLv4-$@kewp_range,$@kewp_baseLv4+$@kewp_range;
						break;
					case 7: //Lv5
						SF_bcPvp $@kebc_pvpCost,@map$,$@kewp_baseLv5-$@kewp_range,$@kewp_baseLv5+$@kewp_range;
						break;
					case 8: //Lv6
						SF_bcPvp $@kebc_pvpCost,@map$,$@kewp_baseLv6-$@kewp_range,$@kewp_baseLv6+$@kewp_range;
						break;
					case 9: //Lv7
						SF_bcPvp $@kebc_pvpCost,@map$,$@kewp_baseLv7-$@kewp_range,$@kewp_baseLv7+$@kewp_range;
						break;
					default:
						break;
					}
				} while (@kmenu > 1);
			}
			break;
		case 4:	//General
			SF_doBroadcast $@kebc_cost,@map$,"(From "+strcharinfo(0)+") ",1;
			break;
		case 5:	//Anonymous
			SF_doBroadcast $@kebc_anonCost,@map$,"(Anonymous) ",1;
			break;
		default:
			return;
		}
	} while (1);
}	//SF_ end

//SubFunction: Calculates prices for Broadcast services (argument 0 == 1 for global bc, 0 for map bc
function	SF_calcPrice {
	set @partycost,callfunc("F_keCost",$@kebc_partyCost,$@kebc_discount);
	set @pvpcost,callfunc("F_keCost",$@kebc_pvpCost,$@kebc_discount);
	set @cost,callfunc("F_keCost",$@kebc_cost,$@kebc_discount);
	set @anoncost,callfunc("F_keCost",$@kebc_anonCost,$@kebc_discount);
	if (getarg(0)) {	//Global fix
		set @partycost,@partycost*$@kebc_globalFactor/100;
		set @pvpcost,@pvpcost*$@kebc_globalFactor/100;
		set @cost,@cost*$@kebc_globalFactor/100;
		set @anoncost,@anoncost*$@kebc_globalFactor/100;
	}
}	//SF_ end

//SubFunction SF_doBroadcast(int cost, String map, String message, int input)
//If map is "", do a global broadcast
//If input is 1, concat a user string to message.
function	SF_doBroadcast {
	set @cost, getarg(0);
	if (getarg(1)=="")
		set @cost, @cost*$@kebc_globalFactor/100;
	if (getarg(3)) { //Input message
		input @msg$;
		set @msg$,getarg(2)+@msg$;
	} else
		set @msg$,getarg(2);

	mes "Broadcast '"+@msg$+"'?";
	switch (select(
		"- Cancel Broadcast",
		"- Broadcast Message"
	)) {
	case 2:
		if (!(callfunc("F_keCharge",@cost,$@kebc_discount,1))) {
			callfunc "F_keIntro", e_pif, "You don't have enough Zeny...";
			return;
		}

		callfunc "F_keIntro", e_what, "Broadcasting...";
		if (getarg(1)=="")
			announce @msg$,16;
		else
			mapannounce getarg(1),@msg$,3;
		break;
	default:
		callfunc "F_keIntro", -1, "Ok...";
	}
}	//SF_ end

//SubFunction SF_bcPvp (int cost, String map, int min level, int max level)
//Does the second part of PvP Room Advertising. Level is the level group to
//advertise (1->8 where 8 is free for all)
function	SF_bcPvp {
	set @msg$, "advertising";
	set @lvls$, "";
	if (getarg(3)) {
		if (BaseLevel < getarg(2) || BaseLevel > getarg(3)) {
			callfunc "F_keIntro", e_bzz, "You can only broadcast requests for PvP rooms you can enter!";
			return;
		}
		set @msg$,"levels "+getarg(2)+"-"+getarg(3);
		set @lvls$,"(levels "+getarg(2)+"-"+getarg(3)+") ";
	}
	set @pvpcost,getarg(0);
	switch(select(
		"- Cancel (PvP Rooms "+@msg$+")",
		"- advertise 'Room Sandwich'",
		"- advertise 'Room Rock On'",
		"- advertise 'Four Room'",
		"- advertise 'Room Undercross'",
		"- advertise 'Room Compass'"
	)) {
	case 2:	//Sandwich
		SF_doBroadcast @pvpcost,@map$,"The "+callfunc("GF_getJobName", class)+" "+strcharinfo(0)+" is looking for PvP challengers "+@lvls$+"in the 'Room Sandwich'!",0;
		break;
	case 3:	//Rockon
		SF_doBroadcast @pvpcost,@map$,"The "+callfunc("GF_getJobName", class)+" "+strcharinfo(0)+" is looking for PvP challengers "+@lvls$+"in the 'Room Rock On'!",0;
		break;
	case 4:	//Room Four
		SF_doBroadcast @pvpcost,@map$,"The "+callfunc("GF_getJobName", class)+" "+strcharinfo(0)+" is looking for PvP challengers "+@lvls$+"in the 'Four Room'!",0;
		break;
	case 5:	//Undercross
		SF_doBroadcast @pvpcost,@map$,"The "+callfunc("GF_getJobName", class)+" "+strcharinfo(0)+" is looking for PvP challengers "+@lvls$+"in the 'Room Undercross'!",0;
		break;
	case 6:	//Compass
		SF_doBroadcast @pvpcost,@map$,"The "+callfunc("GF_getJobName", class)+" "+strcharinfo(0)+" is looking for PvP challengers "+@lvls$+"in the 'Room Compass'!",0;
		break;
	}
} //SF_ end

}