summaryrefslogtreecommitdiff
path: root/npc/custom/eAAC_Scripts/kafraExpress/ke_broadcast.txt
blob: 669942e720783788bd15695c011f5c131908af49 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
//===== 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

}