/*=========================================================
Hercules Invasion
by Mumbles
===========================================================
Description:
A completely revamped and optimised variation of the widely
popular "Poring Invasion" event.
Configuration settings are dynamic and easily modifiable.
Customizable parameters include normal monsters, "prized"
monsters, each respective monster amounts, monster tiers,
invasion map,NPC name, and server name.
NPC can be triggered by staff using the command @invasion.
===========================================================
Compatibility:
Optimised for Hercules emulators.
===========================================================
Changelog:
v1.0 - First version.
v1.0.1 - Removed support for backwards compatibility.
v1.0.2 - Optimised announcements.
=========================================================*/
- script invasion -1,{
OnInit:
// Configuration
.npc_name$ = "[^0000FFHercules Invasion^000000]";
.server_name$ = "Hercules"; // Server name
.map_name$ = "Geffen"; // Invasion map name
.map$ = "geffen"; // Invasion map
.reward = 7711; // Event Ticket
.tiers = 3; // Amount of tiers
.limit = 22; // Kill limit
.delay = 5; // Announcement delay in seconds
.auth = 60; // GM level to access staff panel
// Normal mob IDs
setarray .normal[0], 1002, 1031, 1113, 1242, 1613, 1784,
1388, 1582, 1120, 1062, 1090, 1096;
// Normal mob amounts
setarray .n_mobs[0], 300, 300, 300, 300, 300, 300,
10, 40, 40, 300, 40, 40;
// Prized mob IDs
setarray .prized[0], 1002, 1031, 1113, 1242, 1613, 1784,
1582, 1120, 1062, 1096;
// Prized mob amounts
setarray .p_mobs[0], 3, 2, 3, 3, 3, 3,
1, 1, 3, 1;
// Define announcements
setarray .announce$[0],
"Porings of the world seem to have started an uprising because they continue to be hunted...",
"It appears that they plan to raid the city of "+ .map_name$ +" today!",
"They've feared "+ .map_name$ +" for ages, and are sick of it!",
"Prepare yourself, Warriors of "+ .server_name$ +"!",
"They're approaching...",
"The "+ .map_name$ +" Soldiers are unable to fight!",
"They need assistance!";
// Create @invasion command
bindatcmd "invasion", strnpcinfo(3) +"::OnInvasion", .auth, .auth;
end;
OnInvasion:
mes .npc_name$;
mes "Hey there, "+ strcharinfo(0) +"!";
mes "What would you like to do?";
mes " ";
while (true) {
switch(select("Start invasion:Stop invasion")) {
case 1:
// Check invasion status
if(.state) {
mes "^FF0000The invasion is already in progress!^000000";
break;
}
close2;
OnEnable:
// Set invasion status
.state++;
.wave++;
// Announcements
for (.@i = 0; .@i < getarraysize(.announce$); .@i++) {
announce .announce$[.@i], bc_all;
sleep .delay * 1000;
}
announce "Wave "+ .wave +" of the Poring forces presses onward!", bc_all;
// Normal mobs
for (.@i = 0; .@i < getarraysize(.normal); .@i++) {
monster .map$, 0, 0, getmonsterinfo(.normal[.@i], 0), .normal[.@i], .n_mobs[.@i], "";
}
// Prized mobs
for (.@i = 0; .@i < getarraysize(.prized); .@i++) {
monster .map$, 0, 0, getmonsterinfo(.prized[.@i], 0), .prized[.@i], .p_mobs[.@i], strnpcinfo(3) +"::OnMobKilled";
}
setmapflag .map$, mf_nomobloot;
initnpctimer;
.state++;
end;
case 2:
// Check invasion status
if(.state < 2) {
mes "^FF0000There is no invasion in progress!^000000";
break;
}
// End invasion
donpcevent strnpcinfo(3) +"::OnTimer3600000";
close;
}
}
OnClock0100:
OnClock2100:
// Start invasion
donpcevent strnpcinfo(3) +"::OnEnable";
end;
OnMobKilled:
// Tier 1
setarray .@tier1[0], 1002, 1031, 1062, 1113, 1242, 1613, 1784;
// Tier 2
setarray .@tier2[0], 1582;
// Tier 3
setarray .@tier3[0], 1096, 1120;
// Check if monster killed is listed in tiers
for (.@t = 0; .@t < .@tiers; .@t++) {
for (.@i = 0; .@i < getarraysize(getd(".@tier"+ (.@t + 1))); .@i++) {
if (.state && killedrid == .@tier1[.@i]) {
.@amount = .@t + 1;
.@winner++;
}
}
}
// Reward and announce winner; increment count
if (.@winner) {
announce .@tier +" "+ getitemname(.reward) +" won by "+ strcharinfo(0) + ".", bc_map | bc_blue;
getitem .reward, .@amount;
.count++;
}
if (.count > .limit) {
OnTimer3600000:
// Kill all monsters and reset invasion status
killmonster .map$,"All";
announce "Poring forces have been overcome. They're retreating!",0;
removemapflag .map$, mf_nomobloot;
stopnpctimer;
.count = 0;
.state = 0;
}
end;
}