Jump to content

BlazingSpear

Members
  • Posts

    64
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by BlazingSpear

  1. hi i would like to request npc like quest but the reward will be type by players item_id and amount of that id

    Example:

    required item

    fluff 10pcs 

    four leaf clover 4pcs

    brigan 4pcs

    then if the item is completed

    the player will type what item id and how many it will produce

  2. //===== rAthena Script =======================================
    //= World Boss Event
    //===== By: ==================================================
    //= Musika6988, Sehrentos
    //===== Current Version: =====================================
    //= 2.9.4
    //===== Compatible With: =====================================
    //= rAthena Project
    //===== Description: =========================================
    //= Summon random World Boss and when defeated get treasure.
    //= Leader will have option to distribute or dispose loots.
    //= GM panel: info/start/stop/skip/lootMode/modify.
    //= Boss HP will increase or decrease by 1.500.000 per each 
    //= player nearby and is updated every 10 seconds.
    //= When boss is defeated it will trigger increased exp and
    //= drop rates to whole server for 1 hour(IF enabled).
    //===== Additional Comments: =================================
    //= 1.x Initial script by Musika6988.
    //= 2.0 Sehrentos added reward arrays. Randomly select a reward.
    //= 2.1 Sehrentos changed single random reward into random all rewards.
    //= 2.2 Sehrentos minor optimizations.
    //= 2.3 Sehrentos added more loot options.
    //= 2.4 Sehrentos added GM panel, Default mob attributes(.MOB_),
    //=  Same party check(reward stealing)
    //= 2.5 Sehrentos added NPC WorldBossRadar to monitor players nearby,
    //=  Removed Flee and Perfect Dodge from Treasure Chest,
    //=  Added timeout to stop the event. Minor text changes.
    //= 2.6 Sehrentos added loot mode 1 give one reward to one random party member.
    //=  Added loot modes 4-5 give all/one rewards to all nearby players and their party members.
    //=  Added loot modes 6-7 give all/one rewards to all nearby players.
    //= 2.7 Sehrentos removed Treasure Chest monster.
    //=  Added Treasure Chest NPCs.
    //=  Added multiple events at once, but not in same map.
    //=  Added loot modes 8-9 give all/one rewards to all players in same map.
    //=  Added double server rates for 1 hour after boss is killed event.
    //= 2.8 Sehrentos added jump_zero optimizations.
    //=  Fixed WorldBossRates::OnInit first run on the server.
    //=  Added [email protected]_ACCESS_EXPIRE timer. Clean the access array when it expires.
    //= 2.9 Sehrentos WorldBossRadar enable/disable option.
    //=  Added loot modes 10 give all rewards to selected party member.
    //=  Added loot modes 11 give one random reward to selected party member.
    //= 2.9.1 Sehrentos Fixes and additions.
    //=  Added option to turn off mapflags.
    //=  Added more default .MOB_ status points.
    //=  Fix random reward will be selected only once, to avoid abuse ([email protected]_REWARD_INDEX).
    //=  Renamed some values. easier to understand.
    //= 2.9.2 Sehrentos Disabled FOG effect.
    //=  Added more announcements when event fail to start.
    //=  Added unit checks on OnMobDie event.
    //=  Added inarray optimizations.
    //= 2.9.3 Sehrentos changed the way event starts and announces.
    //=  Fixed WorldBossRates when .use_floating_rates is enabled(report @Quesooo).
    //= 2.9.4 Sehrentos added loots amounts in array (suggest @Radian).
    //= !TODO: Loot mode 12 give each reward to selected party member one by one.
    //============================================================
    -	script	WorldBoss	-1,{
    OnInit:
    	// Settings
    	.npc_name$ = strnpcinfo(0); // Name of this NPC
    	.event_sleep = 60000;       // Event sleep time in milliseconds(60000 = 1 minute)
    	.event_timeout = 7200000;   // Event timeout time in milliseconds before Boss is disabled(60000 = 1 minute)
    	.event_access_expire = 900000; // Event access expire time in milliseconds(60000 = 1 minute)
    
    	// Reward distribution
    	.loot_mode = 4;             // Event loot distribution mode. Look npc_loot_mode_desc for descriptions
    	.loop_max = 200;            // Maximum number of loops (When selecting a random party member)
    	.duplicate_npc_count = 9;   // Number of duplicate Treasure Chest NPC's (Important! 0 counts as well)
    
    	// Experience increases during event(In current event map)
    	.base_exp_multiplier = 3;   // Event base exp rating multiplier(In current event map)
    	.job_exp_multiplier = 3;    // Event job exp rating multiplier(In current event map)
    	.use_floating_rates = 0;    // Increase servers exp and drop rates for 1 hour after boss kill(0=Disable, 1=Enable)
    
    	// Monsters default attributes
    	.MOB_MAXHP = 100000000;     // How much HP can monster have at maximum
    	.MOB_HP = 5000000;          // How much HP monster has on spawn
    	.MOB_SPEED = 130;           // Speed
    	.MOB_CRIT = 450;            // Crit rate (1000=100%)
    	.MOB_HIT = 300;             // Hit rate
    	.MOB_ATKMIN = 1000;         // Base Attack Minimum
    	.MOB_ATKMAX = 4000;         // Base Attack Maximum
    	.MOB_MATKMIN = 1000;        // Magic Attack Minimum
    	.MOB_MATKMAX = 4000;        // Magic Attack Maximum
    	.MOB_DEF = 35;              // Defence
    	.MOB_MDEF = 35;             // Magic Defence
    	.MOB_FLEE = 200;            // Flee rate
    	.MOB_PDODGE = 60;           // Perfect Dodge
    	.MOB_STR = 150;             // Stat strength
    	.MOB_AGI = 150;             // Stat agility
    	.MOB_VIT = 150;             // Stat vitality
    	.MOB_INT = 150;             // Stat intellect
    	.MOB_DEX = 150;             // Stat dexterity
    	.MOB_LUK = 150;             // Stat luck
    
    	// Floating monster HP
    	// When player is detected near the mob, update it's HP.
    	.use_radar = 1;             // 0=Disable, 1=Enable
    
    	// Mapflags effects, monster status, party lock, etc.
    	.use_mapflags = 1;          // 0=Disable, 1=Enable
    
    	// Event monster ID's
    	setarray .event_mobs[0],
    		1093, // Eclipse
    		1096, // Angeling
    		1120, // Ghostring
    		1388, // Archangeling
    		1582, // Deviling
    		1795; // Bloody Knight
    
    	// Event rewards <ID>,<Amount> (One random array is selected)
    	setarray .loots_0, 501,1, 502,1, 503,2, 504,2, 505,3, 506,3;
    	setarray .loots_1, 507,1, 508,1, 509,2, 510,2, 511,3, 512,3;
    	setarray .loots_2, 513,1, 514,1, 515,2, 516,2, 517,3, 518,3;
    	setarray .loots_3, 519,1, 520,1, 521,2, 522,2, 523,3, 525,3;
    
    	// Event reward ID's array size (Important!)
    	// If you add new .loots_<Number> arrays. You must change this accordingly.
    	.loots_count = 3;  // 0 count aswell
    
    	// Event map names
    	setarray .event_maps$[0],
    		"prontera", "morocc", "geffen", "payon",
    		"alberta", "aldebaran", "xmas", "comodo",
    		"yuno", "amatsu", "gonryun", "umbala",
    		"louyang", "ayothaya", "einbroch", "hugel",
    		"rachel", "veins", "moscovia";
    
    	// Event loot distribution mode description
    	setarray .loot_mode_desc$[0],
    		"Give all rewards to all party members",                          // 0
    		"Give one reward to one random party member",                     // 1
    		"Give all rewards to one random party member",                    // 2
    		"Give rewards randomly between all party members",                // 3
    		"Give all rewards to all nearby players and their party members", // 4 (Skip UI)
    		"Give one reward to all nearby players and their party members",  // 5 (Skip UI)
    		"Give all rewards to all nearby players",                         // 6 (Skip UI)
    		"Give one reward to all nearby players",                          // 7 (Skip UI)
    		"Give all rewards to all players in the same map",                // 8 (Skip UI)
    		"Give one reward to all players in the same map",                 // 9 (Skip UI)
    		"Give all rewards to selected party member",                      // 10
    		"Give one random reward to selected party member";                // 11
    
    	// TESTS
    	// Log console information
    	// This will report incorrect monster ID's on script load
    	/*for( [email protected] = 0; [email protected] < getarraysize(.event_mobs); [email protected]++ ) {
    		if( getmonsterinfo(.event_mobs[[email protected]], 0) == "null" ) {
    			debugmes .npc_name$ + ":OnInit Monster ID:" + .event_mobs[[email protected]] + " DOES NOT EXIST!";
    		}
    	}*/
    	// Start event on script load (For testing purposes)
    	//donpcevent .npc_name$ + "::OnEnable";
    	end;
    
    OnEnable:
    OnClock0402:
    OnClock2359:
    	// Check free event maps
    	if ( getarraysize([email protected]_MAP$) >= getarraysize(.event_maps$) ) {
    		debugmes .npc_name$+"::OnEnable all event maps are active!";
    		//announce "[World Boss] Event has been cancelled! All event maps are active!", BC_ALL, 0xFF0000;
    		end;
    	}
    
    	// Select random monster
    	[email protected]_mob = rand( getarraysize( .event_mobs ) );
    	[email protected]_id = .event_mobs[ [email protected]_mob ];
    
    	// Select random map
    	[email protected] = 0;
    	[email protected]_map = rand( getarraysize( .event_maps$ ) ); // Random map index number
    	while(inarray([email protected]_MAP$[0], .event_maps$[[email protected]_map]) != -1) {
    		if([email protected] > .loop_max) {
    			debugmes .npc_name$+"::OnEnable event map max loop count!";
    			//announce "[World Boss] Event has been cancelled! Could not find free event map!", BC_ALL, 0xFF0000;
    			end;
    		}
    		[email protected]_map = rand( getarraysize( .event_maps$ ) );
    		[email protected]++;
    	}
    	[email protected]_name$ = .event_maps$[ [email protected]_map ];
    
    	// Announce event will start soon
    	announce "[World Boss] A rift on time and space is about to be opened! A World Boss will appear in "+(.event_sleep / 60000)+" minute! Prepare your Hunting Party!",BC_ALL,0xFF0000,FW_BOLD,18;
    
    	// Sleep until X time have passed and then continue script
    	sleep .event_sleep;
    
    	// Get last event index
    	[email protected] = getarraysize([email protected]_MOB_GID);
    
    	// Set mapflags if enabled
    	if ( .use_mapflags ) {
    		// Save event maps original mapflags
    		setarray [email protected]_MF_PARTYLOCK[[email protected]], getmapflag([email protected]_name$, MF_PARTYLOCK);
    		setarray [email protected]_MF_NOMOBLOOT[[email protected]], getmapflag([email protected]_name$, MF_NOMOBLOOT);
    		setarray [email protected]_MF_NOMVPLOOT[[email protected]], getmapflag([email protected]_name$, MF_NOMVPLOOT);
    		setarray [email protected]_MF_NOPENALTY[[email protected]], getmapflag([email protected]_name$, MF_NOPENALTY);
    		setarray [email protected]_MF_NOMOBTELE[[email protected]], getmapflag([email protected]_name$, MF_MONSTER_NOTELEPORT);
    		setarray [email protected]_MF_BASEEXP[[email protected]], getmapflag([email protected]_name$, MF_BEXP);
    		setarray [email protected]_MF_JOBEXP[[email protected]], getmapflag([email protected]_name$, MF_JEXP);
    		//setarray [email protected]_MF_FOG[[email protected]], getmapflag([email protected]_name$, MF_FOG);
    
    		// Set new mapflags
    		setmapflag [email protected]_name$, MF_PARTYLOCK; // Disable changing party(Inviting new players in event map)
    		setmapflag [email protected]_name$, MF_NOMOBLOOT; // Disable Normal monster loot drops
    		setmapflag [email protected]_name$, MF_NOMVPLOOT; // Disable Boss monster loot drops
    		setmapflag [email protected]_name$, MF_NOPENALTY; // Disable Exp and Zeny penalty
    		setmapflag [email protected]_name$, MF_MONSTER_NOTELEPORT; // Disable monster teleport
    		setmapflag [email protected]_name$, MF_BEXP, ([email protected]_MF_BASEEXP[[email protected]] * .base_exp_multiplier); // Set Base Exp rating
    		setmapflag [email protected]_name$, MF_JEXP, ([email protected]_MF_JOBEXP[[email protected]] * .job_exp_multiplier); // Set Job Exp rating
    		//setmapflag [email protected]_name$, MF_FOG; // Enable FOG effect
    	}
    
    	// Summon event monster unit
    	monster [email protected]_name$, 0, 0, "World Boss", [email protected]_id, 1, .npc_name$+"::OnMobDie", Size_Large, AI_NONE;
    	[email protected] = [email protected][0]; // Get monster's Game ID
    
    	// Change unit data to defaults
    	setunitdata [email protected], UMOB_MAXHP, .MOB_MAXHP;
    	setunitdata [email protected], UMOB_HP, .MOB_HP;
    	setunitdata [email protected], UMOB_SPEED, .MOB_SPEED;
    	setunitdata [email protected], UMOB_CRIT, .MOB_CRIT;
    	setunitdata [email protected], UMOB_HIT, .MOB_HIT;
    	setunitdata [email protected], UMOB_ATKMIN, .MOB_ATKMIN;
    	setunitdata [email protected], UMOB_ATKMAX, .MOB_ATKMAX;
    	setunitdata [email protected], UMOB_MATKMIN, .MOB_MATKMIN;
    	setunitdata [email protected], UMOB_MATKMAX, .MOB_MATKMAX;
    	setunitdata [email protected], UMOB_DEF, .MOB_DEF;
    	setunitdata [email protected], UMOB_MDEF, .MOB_MDEF;
    	setunitdata [email protected], UMOB_FLEE, .MOB_FLEE;
    	setunitdata [email protected], UMOB_PDODGE, .MOB_PDODGE;
    	setunitdata [email protected], UMOB_STR, .MOB_STR;
    	setunitdata [email protected], UMOB_AGI, .MOB_AGI;
    	setunitdata [email protected], UMOB_VIT, .MOB_VIT;
    	setunitdata [email protected], UMOB_INT, .MOB_INT;
    	setunitdata [email protected], UMOB_DEX, .MOB_DEX;
    	setunitdata [email protected], UMOB_LUK, .MOB_LUK;
    
    	// Get units updated data
    	getunitdata([email protected], [email protected]);
    
    	// Save event arrays
    	setarray [email protected]_MOB_ID[[email protected]], [email protected]_id;
    	setarray [email protected]_MOB_GID[[email protected]], [email protected];
    	setarray [email protected]_TIMEOUT[[email protected]], gettimetick(0);
    	setarray [email protected]_RADAR_NEAR[[email protected]], 0;
    	setarray [email protected]_MAP$[[email protected]], [email protected]_name$;
    	setarray [email protected]_X[[email protected]], [email protected][UMOB_X];
    	setarray [email protected]_Y[[email protected]], [email protected][UMOB_Y];
    
    	// Unit talk
    	unittalk [email protected], "Tremble before me mortals!", BC_AREA;
    
    	// Announce event started
    	announce "[World Boss] A "+ getunitname([email protected]) +" has appeared in "+ [email protected]_name$ +" to wreck havoc!! Form a Hunting Party and stop it!!",BC_ALL,0xFF0000,FW_BOLD,18;
    
    	// Start unit radar
    	if ( .use_radar && getarraysize([email protected]_MOB_GID) ) {
    		donpcevent "WorldBossRadar::OnEnable";
    	}
    
    	// Start timeout timer
    	if ( !getnpctimer(1, "WorldBossTimeout") ) {
    		donpcevent "WorldBossTimeout::OnEnable";
    	}
    	end;
    
    // Disable event
    OnDisable:
    	//debugmes .npc_name$+"::OnDisable stop event!";
    	// Stop timeout timer
    	donpcevent "WorldBossTimeout::OnDisable";
    
    	// Stop unit radar
    	if ( .use_radar ) {
    		donpcevent "WorldBossRadar::OnDisable";
    	}
    
    	// Reset server exp and drop rates
    	if ( .use_floating_rates ) {
    		donpcevent "WorldBossRates::OnDisable";
    	}
    
    	// Loop all events
    	for ( [email protected] = 0; [email protected] < getarraysize([email protected]_MOB_GID); [email protected]++ ) {
    		// Kill all units
    		if ( unitexists([email protected]_MOB_GID[[email protected]]) ) {
    			unitkill([email protected]_MOB_GID[[email protected]]);
    		}
    
    		// Reset all mapflags to original values
    		if ( .use_mapflags ) {
    			callfunc("WB_ResetMapflags", [email protected]_MAP$[[email protected]], [email protected]);
    		}
    	}
    	// Kill all script or gm summoned monsters
    	//killmonster .event_map$, "All";
    
    	// Reset all event arrays
    	callfunc("WB_ResetAllGlobals");
    	end;
    
    OnMobDie:
    	// Event when monster has been killed
    	// Stop unit radar and timeout if no unit is alive
    	if ( !getarraysize([email protected]_MOB_GID) ) {
    		if ( .use_radar ) donpcevent "WorldBossRadar::OnDisable";
    		donpcevent "WorldBossTimeout::OnDisable";
    	}
    
    	// Check attached unit
    	[email protected]_gid = getattachedrid();
    	if ( [email protected]_gid ) {
    		// No unit attached. Propably killed by unitkill or other script command
    		//donpcevent .npc_name$+"::OnDisable";
    		end;
    	}
    
    	// Get unit type
    	[email protected]_type = getunittype([email protected]_gid);
    	if ( [email protected]_type == -1 ) {
    		debugmes .npc_name$+"::OnMobDie FATAL no unit type found!";
    		donpcevent .npc_name$+"::OnDisable";
    		end;
    	}
    
    	// Get map coordinates (Treasure Chest NPC will need these coordinates)
    	getmapxy(.event_map$, .event_x, .event_y, [email protected]_type);
    
    	// Announce
    	announce "[World Boss] The World Boss have been killed! Congratulations!", bc_all, 0xFF0000;
    
    	// Increase server exp and drop rates for limited time
    	if ( .use_floating_rates ) {
    		donpcevent "WorldBossRates::OnEnable";
    	}
    
    	// Get index if map name are the same
    	[email protected]_index = inarray([email protected]_MAP$[0], .event_map$);
    
    	// Check if index was found and stop if not
    	if ( [email protected]_index == -1 ) {
    		debugmes .npc_name$+"::OnMobDie event index was not found!";
    		end;
    	}
    
    	// Reset mapflags to original values
    	if ( .use_mapflags ) {
    		callfunc("WB_ResetMapflags", [email protected]_MAP$[[email protected]_index], [email protected]_index);
    	}
    
    	// If unit is not PC, try to attach unit master to the script
    	if ( [email protected]_type != BL_PC ) {
    		getunitdata([email protected]_gid, [email protected]);
    		if ([email protected]_type == BL_NPC) {
    			// NPC does not have master
    			debugmes .npc_name$+"::OnMobDie NPC no player attached!";
    			end;
    		}
    		if ([email protected]_type == BL_PET) {
    			if (!attachrid([email protected][UPET_MASTERAID])) {
    				debugmes .npc_name$+"::OnMobDie PET no player attached!";
    				end;
    			}
    		}
    		if ([email protected]_type == BL_MOB) {
    			if (!attachrid([email protected][UMOB_MASTERAID])) {
    				debugmes .npc_name$+"::OnMobDie MOB no player attached!";
    				end;
    			}
    		}
    		if ([email protected]_type == BL_HOM) {
    			[email protected]$ = strcharinfo(0,[email protected][UHOM_MASTERCID]);
    			if (!attachrid(getcharid(3,[email protected]$))) {
    				debugmes .npc_name$+"::OnMobDie HOM no player attached!";
    				end;
    			}
    		}
    		if ([email protected]_type == BL_MER) {
    			[email protected]$ = strcharinfo(0,[email protected][UMER_MASTERCID]);
    			if (!attachrid(getcharid(3,[email protected]$))) {
    				debugmes .npc_name$+"::OnMobDie MER no player attached!";
    				end;
    			}
    		}
    		if ([email protected]_type == BL_ELEM) {
    			[email protected]$ = strcharinfo(0,[email protected][UELE_MASTERCID]);
    			if (!attachrid(getcharid(3,[email protected]$))) {
    				debugmes .npc_name$+"::OnMobDie ELE no player attached!";
    				end;
    			}
    		}
    	}
    
    	// Get party ID
    	[email protected]_id = getcharid(1);
    	// Save event arrays
    	setarray [email protected]_MAP$[[email protected]_index], .event_map$;
    	setarray [email protected]_X[[email protected]_index], .event_x;
    	setarray [email protected]_Y[[email protected]_index], .event_y;
    	setarray [email protected]_PARTY_ID[[email protected]_index], [email protected]_id;
    	// Select random reward/loots array
    	setarray [email protected]_REWARD_INDEX[[email protected]_index], rand(0, .loots_count);
    
    	// Enable first available Treasure Chest NPC
    	// Set .event_map$, .event_x, .event_y before enabling ( Important! )
    	for ( [email protected] = 0; [email protected] <= .duplicate_npc_count; [email protected]++ ) {
    		[email protected]$ = "Treasure Chest#wb_"+ [email protected]; // Name of the NPC
    		if ( getnpcid(0, [email protected]$) ) { // If NPC exists
    			if ( !getnpctimer( 1, [email protected]$ ) ) { // If has active timer=1
    				setarray [email protected]_NPC_NAME$[[email protected]_index], [email protected]$;
    				donpcevent [email protected]$ +"::OnEnable";
    				break;
    			}
    		} else {
    			debugmes .npc_name$+"::OnMobDie no Treasure Chest#wb_"[email protected]+" NPC found!";
    		}
    	}
    
    	// Switch by loot mode and save character IDs for access
    	switch( .loot_mode ) {
    		case 0:
    		case 1:
    		case 2:
    		case 3: // In same party or single player
    		case 10: // All to selected party member
    		case 11: // One random to selected party member
    			// Attach all available party members
    			if ( getcharid(1) ) {
    				addrid(2, 0, getcharid(1));
    			}
    			break;
    
    		case 4:
    		case 5: // In range and party
    			// Attach all available players in 20 cells from the killer RID
    			addrid(4, 0, (.event_x - 20),(.event_y - 20), (.event_x + 20),(.event_y + 20));
    
    			// Attach all available party members
    			if ( getcharid(1) ) {
    				addrid(2, 0, getcharid(1));
    			}
    			break;
    
    		case 6:
    		case 7: // In range
    			// Attach all available players in 20 cells from the killer RID
    			addrid(4, 0, (.event_x - 20),(.event_y - 20), (.event_x + 20),(.event_y + 20));
    			break;
    
    		case 8:
    		case 9: // In the same map
    			addrid(1, 0, getcharid(1));
    			break;
    	}
    
    	// Find matching character IDs from the access array
    	[email protected]_index = inarray([email protected]_ACCESS[0], getcharid(0));
    
    	// Exit if character already has access
    	if ( [email protected]_index != -1 ) {
    		end;
    	}
    
    	// Save character ID into access array
    	setarray [email protected]_ACCESS[getarraysize([email protected]_ACCESS)], getcharid(0);
    	setarray [email protected]_ACCESS_EXPIRE[getarraysize([email protected]_ACCESS_EXPIRE)], gettimetick(0);
    	
    	// Start access expire timer if not already running
    	if ( !getnpctimer(1, "WorldBossAccessExpire") ) {
    		donpcevent "WorldBossAccessExpire::OnEnable";
    	}
    	end;
    
    // Event when player opens Treasure Chest NPC
    OnTreasureOpen:
    	// Get map coordinates of the player
    	getmapxy([email protected]_map$, [email protected], [email protected], BL_PC);
    
    	// Search for character ID from the access array
    	[email protected]_index = inarray([email protected]_ACCESS[0], getcharid(0));
    
    	// User has no access!
    	if ( [email protected]_index == -1 ) {
    		message strcharinfo(0), "Treasure Chest is empty.";
    		end;
    	}
    
    	// Get event index from the map name array
    	[email protected]_index = inarray([email protected]_MAP$[0], [email protected]_map$);
    
    	// Check if event index was found
    	if ( [email protected]_index == -1 ) {
    		debugmes [email protected]$+"::OnTreasureOpen event map name ( "+ [email protected]_map$ +" ) not found!";
    		message strcharinfo(0), "Treasure Chest is empty.";
    		end;
    	}
    
    	// Select reward array
    	[email protected]_reward = [email protected]_REWARD_INDEX[[email protected]_index];
    	[email protected]_size = getarraysize( getd(".loots_" + [email protected]_reward) );
    	//copyarray [email protected]_id[0], getd(".loots_" + [email protected]_reward + "[0]"), [email protected]_size; // .loots_0
    
    	// Rewards array
    	// Get every second value from array.
    	[email protected] = 0;
    	for( [email protected] = 0; [email protected] < [email protected]_size; [email protected] += 2 ) {
    		setarray [email protected]_id[[email protected]], getd(".loots_" + [email protected]_reward + "[" + [email protected] + "]");
    		[email protected]++;
    	}
    	[email protected]_size = getarraysize( [email protected]_id );
    	// Amounts array
    	// Get every second value from array.
    	[email protected] = 0;
    	for( [email protected] = 1; [email protected] < [email protected]_size; [email protected] += 2 ) {
    		setarray [email protected]_amount[[email protected]], getd(".loots_" + [email protected]_reward + "[" + [email protected] + "]");
    		[email protected]++;
    	}
    
    	switch( .loot_mode ) {
    		case 0: // All to all members
    		case 2: // All to random member
    		case 3: // Randomly to all members
    		case 10: // All to selected party member
    		case 11: // One random to selected party member
    			if ( getcharid(1) ) {
    				goto OnPartyLeader;
    			} else {
    				// Has no party
    				for( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    					getitem [email protected]_id[[email protected]], [email protected]_amount[[email protected]];
    				}
    			}
    			break;
    
    		case 1: // One to random member
    			if ( getcharid(1) ) {
    				// Party Leader will distribute loots
    				goto OnPartyLeader;
    			} else {
    				// Has no party
    				[email protected] = rand([email protected]_size);
    				getitem [email protected]_id[[email protected]], [email protected]_amount[[email protected]];
    			}
    			break;
    
    		case 4: // All in range and party
    		case 6: // All in range
    		case 8: // All in same map
    		default:
    			// No UI
    			for( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    				getitem [email protected]_id[[email protected]], [email protected]_amount[[email protected]];
    			}
    			break;
    
    		case 5: // One in range and party
    		case 7: // One in range
    		case 9: // One in same map
    			// No UI
    			[email protected] = rand([email protected]_size);
    			getitem [email protected]_id[[email protected]], [email protected]_amount[[email protected]];
    			break;
    	}
    
    	// Remove character ID from the access array (Access is now used)
    	deletearray [email protected]_ACCESS[[email protected]_index], 1;
    	deletearray [email protected]_ACCESS_EXPIRE[[email protected]_index], 1;
    
    	// Announce player
    	message strcharinfo(0), "Congratulations! You have been rewarded for killing the World Boss.";
    
    	// Disable current NPC Treasure Chest
    	if ( !getarraysize([email protected]_ACCESS) ) {
    		// Disable current NPC Treasure Chest
    		callfunc("WB_ResetBox", [email protected]_index);
    		// Stop access expire timer
    		donpcevent "WorldBossAccessExpire::OnDisable";
    	}
    	end;
    
    OnPartyLeader:
    	// Get party ID
    	[email protected]_id = getcharid(1);
    
    	// Check if player is party leader
    	if ( getcharid(0) != getpartyleader( [email protected]_id, 2 ) ) {
    		message strcharinfo(0), "You're not Party Leader.";
    		end;
    	}
    
    	// Get event index from the party ID array
    	[email protected]_index = inarray([email protected]_PARTY_ID[0], [email protected]_id );
    
    	// Check if party id has access!
    	if ( [email protected]_index == -1 ) {
    		message strcharinfo(0), "Treasure Chest is empty.";
    		end;
    	}
    
    	// Select random reward array
    	[email protected]_reward = [email protected]_REWARD_INDEX[[email protected]_index];
    	[email protected]_size = getarraysize(getd(".loots_" + [email protected]_reward));
    	//copyarray [email protected]_id[0], getd(".loots_" + [email protected]_reward + "[0]"), [email protected]_size; // .loots_0_id
    
    	// Rewards array
    	// Get every second value from array.
    	[email protected] = 0;
    	for( [email protected] = 0; [email protected] < [email protected]_size; [email protected] += 2 ) {
    		setarray [email protected]_id[[email protected]], getd(".loots_" + [email protected]_reward + "[" + [email protected] + "]");
    		[email protected]++;
    	}
    	[email protected]_size = getarraysize( [email protected]_id );
    	// Amounts array
    	// Get every second value from array.
    	[email protected] = 0;
    	for( [email protected] = 1; [email protected] < [email protected]_size; [email protected] += 2 ) {
    		setarray [email protected]_amount[[email protected]], getd(".loots_" + [email protected]_reward + "[" + [email protected] + "]");
    		[email protected]++;
    	}
    
    	// Show loot distribution window
    	mes "[ Loot Distributor ]";
    	mes "Please ensure you distribute the Rewards. If you cancelled this, your party might not able to receive any rewards.";
    	mes "^777777Loot mode : ^000000" + .loot_mode_desc$[.loot_mode]; // Loot mode description
    	next;
    	mes "[ Loot Distributor ]";
    	for( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    		mes "^777777 ~ " + [email protected]_amount[[email protected]] + " x " + getitemname( [email protected]_id[[email protected]] ) + "^000000";
    	}
    	next;
    	if( select( "Distribute Loots", "Dispose Loots" ) == 1 ) {
    		// Get party data
    		getpartymember [email protected]_id, 0; // Name
    		getpartymember [email protected]_id, 1; // Character IDs
    		getpartymember [email protected]_id, 2; // Account IDs
    
    		// Copy the temporary party data
    		[email protected]_size = [email protected];
    		copyarray [email protected]_cid[0], [email protected][0], [email protected]_size;
    		copyarray [email protected]_aid[0], [email protected][0], [email protected]_size;
    		copyarray [email protected]_name$[0], [email protected]$[0], [email protected]_size;
    
    		// LOOT MODE 0: Give all rewards to all party members
    		if( .loot_mode == 0 ) {
    			mes "[ Loot Distributor ]";
    			// Loop through each party member
    			for( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    				// Online check
    				if( isloggedin([email protected]_aid[[email protected]], [email protected]_cid[[email protected]]) ) {
    					mes " ~ " + strcharinfo(0, [email protected]_cid[[email protected]]) + " was rewarded!";
    					// Loop through each reward
    					for( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    						getitem [email protected]_id[[email protected]], [email protected]_amount[[email protected]], [email protected]_aid[[email protected]];
    					}
    				}
    			}
    		}
    
    		// LOOT MODE 1: Give one reward to one random party member
    		else if( .loot_mode == 1 ) {
    			// Select random party member X times.
    			SelectRandom1:
    			[email protected] = 0; // Counter for random player select
    			[email protected]_party = rand([email protected]_size);
    			while( !isloggedin([email protected]_aid[[email protected]_party], [email protected]_cid[[email protected]_party]) ) {
    				if( [email protected] >= .loop_max ) break;
    				[email protected]_party = rand([email protected]_size);
    				[email protected]++;
    			}
    			// Max attempts reached					
    			if( [email protected] >= .loop_max ) {
    				mes "[ Player not found ]";
    				mes "Tried to select random player " + [email protected] + " times!";
    				mes "Do you want to try again?";
    				next;
    				if( select("Yes:No") == 1 ) {
    					goto SelectRandom1;
    				} else {
    					goto OnClose;
    				}
    			}
    			// Backup online check (next; will pause script and players can disconnect)
    			if( !isloggedin([email protected]_aid[[email protected]_party], [email protected]_cid[[email protected]_party]) ) {
    				mes "[ Player not online ]";
    				mes "Member is ^777777offline^000000";
    				mes "Do you want to try again?";
    				next;
    				if( select("Yes:No") == 1 ) {
    					goto SelectRandom1;
    				} else {
    					goto OnClose;
    				}
    			}
    			// Give random reward
    			[email protected]_item = rand([email protected]_size);
    			[email protected]$ = strcharinfo(0, [email protected]_cid[[email protected]_party]);
    			mes "[ Loot Distributor ]";
    			mes [email protected]$ + "^777777 ~ " + [email protected]_amount[[email protected]_item] + " x " + getitemname( [email protected]_id[[email protected]_item] ) + "^000000";
    			message [email protected]$, "Gained " + [email protected]_amount[[email protected]_item] + " x " + getitemname( [email protected]_id[[email protected]_item] ) + " ( Distributed Randomly )";
    			getitem [email protected]_id[[email protected]_item], [email protected]_amount[[email protected]_item], [email protected]_aid[[email protected]_party];
    		}
    
    		// LOOT MODE 2: Give all rewards to one random party member
    		else if( .loot_mode == 2 ) {
    			// Select random party member X times.
    			SelectRandom2:
    			[email protected] = 0; // Counter for random player select
    			[email protected]_party = rand([email protected]_size);
    			while( !isloggedin([email protected]_aid[[email protected]_party], [email protected]_cid[[email protected]_party]) ) {
    				if( [email protected] >= .loop_max ) break;
    				[email protected]_party = rand([email protected]_size);
    				[email protected]++;
    			}
    			// Max attempts reached					
    			if( [email protected] >= .loop_max ) {
    				mes "[ Player not found ]";
    				mes "Tried to select random player " + [email protected] + " times!";
    				mes "Do you want to try again?";
    				next;
    				if( select("Yes:No") == 1 ) {
    					goto SelectRandom2;
    				} else {
    					goto OnClose;
    				}
    			}
    			// Backup online check (next; will pause script and players can disconnect)
    			if( !isloggedin([email protected]_aid[[email protected]_party], [email protected]_cid[[email protected]_party]) ) {
    				mes "[ Player not online ]";
    				mes "Member is ^777777offline^000000";
    				mes "Do you want to try again?";
    				next;
    				if( select("Yes:No") == 1 ) {
    					goto SelectRandom2;
    				} else {
    					goto OnClose;
    				}
    			}
    			// Give rewards
    			[email protected]$ = strcharinfo(0, [email protected]_cid[[email protected]_party]);
    			mes "[ Loot Distributor ]";
    			// Loop through each reward
    			for( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    				mes [email protected]$ + "^777777 ~ " + [email protected]_amount[[email protected]] + " x " + getitemname( [email protected]_id[[email protected]] ) + "^000000";
    				message [email protected]$, "Gained " + [email protected]_amount[[email protected]] + " x " + getitemname( [email protected]_id[[email protected]] ) + " ( Distributed Randomly )";
    				getitem [email protected]_id[[email protected]], [email protected]_amount[[email protected]], [email protected]_aid[[email protected]_party];
    			}
    		}
    
    		// LOOT MODE 3: Give rewards randomly between all party members
    		else if( .loot_mode == 3 ) {
    			mes "[ Loot Distributor ]";
    			// Loop through each reward
    			for( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    				// Select random party member X times.
    				SelectRandom3:
    				[email protected] = 0; // Counter for random player select
    				[email protected]_party = rand([email protected]_size);
    				while( !isloggedin([email protected]_aid[[email protected]_party], [email protected]_cid[[email protected]_party]) ) {
    					if( [email protected] >= .loop_max ) break;
    					[email protected]_party = rand([email protected]_size);
    					[email protected]++;
    				}
    				// Max attempts reached					
    				if( [email protected] >= .loop_max ) {
    					mes "[ Player not found ]";
    					mes "Tried to select random player " + [email protected] + " times!";
    					mes "Do you want to try again?";
    					next;
    					if( select("Yes:No") == 1 ) {
    						goto SelectRandom3;
    					} else {
    						goto OnClose;
    					}
    				}
    				// Backup online check (next; will pause script and players can disconnect)
    				if( !isloggedin([email protected]_aid[[email protected]_party], [email protected]_cid[[email protected]_party]) ) {
    					mes "[ Player not online ]";
    					mes "Member is ^777777offline^000000";
    					mes "Do you want to try again?";
    					next;
    					if( select("Yes:No") == 1 ) {
    						goto SelectRandom3;
    					} else {
    						goto OnClose;
    					}
    				}
    				// Give single reward
    				[email protected]$ = strcharinfo(0, [email protected]_cid[[email protected]_party]);
    				mes [email protected]$ + "^777777 ~ " + [email protected]_amount[[email protected]] + " x " + getitemname( [email protected]_id[[email protected]] ) + "^000000";
    				message [email protected]$, "Gained " + [email protected]_amount[[email protected]] + " x " + getitemname( [email protected]_id[[email protected]] ) + " ( Distributed Randomly )";
    				getitem [email protected]_id[[email protected]], [email protected]_amount[[email protected]], [email protected]_aid[[email protected]_party];
    			}
    		}
    
    		// LOOT MODE 10: Give all rewards to selected party member
    		// LOOT MODE 11: Give one reward to selected party member
    		else if( .loot_mode >= 10 && .loot_mode <= 11 ) {
    			SelectMember:
    			// Open Party Select Menu
    			[email protected] = callfunc("WB_PartySelect", 1, 1);
    
    			// Refresh selected
    			while ( [email protected] == -1 ) {
    				message strcharinfo(0), "Refresh menu!";
    				[email protected] = callfunc("WB_PartySelect", 1, 1);
    			}
    
    			// Not in a party (Leaved before select or removed)
    			if ( [email protected] == -2 ) {
    				message strcharinfo(0), "You don't have a party.";
    				end;
    			}
    
    			// Is selected member online
    			if ( !isloggedin([email protected]_aid[[email protected]], [email protected]_cid[[email protected]]) ) {
    				mes "[ Loot Distributor ]";
    				mes "Selected party member is not online.";
    				mes "Please select again.";
    				next;
    				goto SelectMember;
    			}
    
    			// Get more party data
    			[email protected]_name$ = getpartyname([email protected]_id); // Party Name
    			[email protected]_leader_cid = getpartyleader([email protected]_id, 2); // Party Leader Character ID
    			// Party Leader Name
    			[email protected]_leader_name$ = "[Offline]";
    			if ( [email protected]_leader_cid != -1 ) {
    				// strcharinfo(0,[email protected]_leader_cid); will fail if leader is offline!
    				for ([email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    					// Match leader cid with party member cid
    					if ( [email protected]_leader_cid == [email protected]_member_cid[[email protected]] ) {
    						[email protected]_leader_name$ = [email protected]_member_name$[[email protected]];
    					}
    				}
    			}
    
    			// Double check
    			// Check for party changes, because players can leave anytime.
    			[email protected]_id2 = getcharid(1);
    			[email protected]_failed = false;
    
    			// Not in a party anymore (Leaved after select or removed)
    			if ( [email protected]_id2 ) {
    				message strcharinfo(0), "You don't have a party.";
    				mes "[ Loot Distributor ]";
    				mes "Your party has made changes during selection.";
    				mes "Please select again.";
    				close;
    			}
    			
    			// Check if party ID has changed
    			if ([email protected]_id != [email protected]_id2) {
    				message strcharinfo(0), "Failed: Party ID has changed!";
    				mes "[ Loot Distributor ]";
    				mes "Your party has made changes during selection.";
    				mes "Please select again.";
    				close;
    			}
    
    			// Get new party data
    			getpartymember [email protected]_id2, 0; // names
    			[email protected]_party_size = [email protected];
    			copyarray [email protected]$[0], [email protected]$[0], [email protected]_party_size;
    
    			// Check if party size has changed during select.
    			if ([email protected]_party_size != [email protected]_size) {
    				message strcharinfo(0), "Failed: Party size has changed!";
    				mes "[ Loot Distributor ]";
    				mes "Your party has made changes during selection.";
    				mes "Please select again.";
    				close;
    			}
    
    			// Check if party member names has changed during select.
    			for ([email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    				// Match new and old name
    				if ( [email protected]$[[email protected]] != [email protected]_member_name$[[email protected]] ) {
    					[email protected]_failed = true;
    					message strcharinfo(0), "Failed: Party member name has changed!";
    					break;
    				}
    			}
    
    			// Has any checks failed
    			if ( [email protected] >= [email protected]_size && [email protected]_failed ) {
    				mes "[ Loot Distributor ]";
    				mes "Your party has made changes during selection.";
    				mes "Please select again.";
    				close;
    			}
    
    			// Success; Give rewards
    			if (.loot_mode == 10) {
    				// All rewards to selected member
    				[email protected]$ = strcharinfo(0, [email protected]_cid[[email protected]]);
    				mes "[ Loot Distributor ]";
    				// Loop through each reward
    				for( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    					mes [email protected]$ + "^777777 ~ " + [email protected]_amount[[email protected]] + " x " + getitemname( [email protected]_id[[email protected]] ) + "^000000";
    					message [email protected]$, "Gained " + [email protected]_amount[[email protected]] + " x " + getitemname( [email protected]_id[[email protected]] ) + " ( Distributed Randomly )";
    					getitem [email protected]_id[[email protected]], [email protected]_amount[[email protected]], [email protected]_aid[[email protected]];
    				}
    			}
    			else if (.loot_mode == 11) {
    				// Give one random reward to selected member
    				[email protected]_item = rand([email protected]_size);
    				[email protected]$ = strcharinfo(0, [email protected]_cid[[email protected]]);
    				mes "[ Loot Distributor ]";
    				mes [email protected]$ + "^777777 ~ " + [email protected]_amount[[email protected]_item] + " x " + getitemname( [email protected]_id[[email protected]_item] ) + "^000000";
    				message [email protected]$, "Gained " + [email protected]_amount[[email protected]_item] + " x " + getitemname( [email protected]_id[[email protected]_item] ) + " ( Distributed Randomly )";
    				getitem [email protected]_id[[email protected]_item], [email protected]_amount[[email protected]_item], [email protected]_aid[[email protected]];
    			}
    		}
    	} else {
    		// Disposed loots
    		mes "[ Loot Distributor ]";
    	}
    	mes "Congratulations!";
    	// Remove all party members access
    	callfunc("WB_ResetPartyAccess", [email protected]_id);
    	close2;
    	// Disable current NPC Treasure Chest
    	callfunc("WB_ResetBox", [email protected]_index);
    	end;
    
    OnClose:
    	// Close reward window
    	mes "[ Loot Distributor ]";
    	mes "Good bye.";
    	close;
    }
    
    // Function: Reset all party members access IDs
    // callfunc("WB_ResetPartyAccess", <party id>)
    function	script	WB_ResetPartyAccess	{
    	[email protected]_id = getarg(0);
    	getpartymember [email protected]_id, 1; // Character IDs
    	[email protected]_size = [email protected];
    	copyarray [email protected]_cid[0], [email protected][0], [email protected]_size;
    	for ( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    		for ( [email protected] = 0; [email protected] < getarraysize([email protected]_ACCESS); [email protected]++ ) {
    			if ( [email protected]_ACCESS[[email protected]] == [email protected]_cid[[email protected]] ) {
    				deletearray [email protected]_ACCESS[[email protected]], 1;
    				deletearray [email protected]_ACCESS_EXPIRE[[email protected]], 1;
    			}
    		}
    	}
    	// Remove party id
    	/*for ( [email protected] = 0; [email protected] < getarraysize([email protected]_PARTY_ID); [email protected]++ ) {
    		if ( [email protected]_PARTY_ID[[email protected]] == [email protected]_id ) {
    			deletearray [email protected]_PARTY_ID[[email protected]], 1;
    		}
    	}*/
    	return;
    }
    
    // Function: Reset specific WorldBoss event global arrays
    // callfunc("WB_ResetEventGlobals", <index>)
    function	script	WB_ResetEventGlobals	{
    	[email protected] = getarg(0, 0); // Event index Default=0
    	deletearray [email protected]_MOB_ID[[email protected]], 1;   // Rename from [email protected]_ID
    	deletearray [email protected]_MOB_GID[[email protected]], 1;  // Rename from [email protected]_GID
    	deletearray [email protected]_TIMEOUT[[email protected]], 1;
    	deletearray [email protected]_RADAR_NEAR[[email protected]], 1; // Rename from [email protected]_NEAR
    	deletearray [email protected]_MAP$[[email protected]], 1;
    	deletearray [email protected]_X[[email protected]], 1;
    	deletearray [email protected]_Y[[email protected]], 1;
    	deletearray [email protected]_REWARD_INDEX[[email protected]], 1; // Rename from [email protected]_REWARD
    	deletearray [email protected]_PARTY_ID[[email protected]], 1; // Rename from [email protected]_PARTY
    	deletearray [email protected]_NPC_NAME$[[email protected]], 1; // Rename from [email protected]_BOX
    	//deletearray [email protected]_ACCESS[[email protected]], 1;
    	//deletearray [email protected]_ACCESS_EXPIRE[[email protected]], 1;
    	deletearray [email protected]_MF_PARTYLOCK[[email protected]], 1;
    	deletearray [email protected]_MF_NOMOBLOOT[[email protected]], 1;
    	deletearray [email protected]_MF_NOMVPLOOT[[email protected]], 1;
    	deletearray [email protected]_MF_NOPENALTY[[email protected]], 1;
    	deletearray [email protected]_MF_NOMOBTELE[[email protected]], 1;
    	deletearray [email protected]_MF_BASEEXP[[email protected]], 1;
    	deletearray [email protected]_MF_JOBEXP[[email protected]], 1;
    	//deletearray [email protected]_MF_FOG[[email protected]], 1;
    	return;
    }
    
    // Function: Reset all WorldBoss event global arrays
    // callfunc("WB_ResetAllGlobals")
    function	script	WB_ResetAllGlobals	{
    	deletearray [email protected]_MOB_ID[0], getarraysize([email protected]_MOB_ID);
    	deletearray [email protected]_MOB_GID[0], getarraysize([email protected]_MOB_GID);
    	deletearray [email protected]_TIMEOUT[0], getarraysize([email protected]_TIMEOUT);
    	deletearray [email protected]_RADAR_NEAR[0], getarraysize([email protected]_RADAR_NEAR);
    	deletearray [email protected]_MAP$[0], getarraysize([email protected]_MAP$);
    	deletearray [email protected]_X[0], getarraysize([email protected]_X);
    	deletearray [email protected]_Y[0], getarraysize([email protected]_Y);
    	deletearray [email protected]_REWARD_INDEX[0], getarraysize([email protected]_REWARD_INDEX);
    	deletearray [email protected]_PARTY_ID[0], getarraysize([email protected]_PARTY_ID);
    	deletearray [email protected]_NPC_NAME$[0], getarraysize([email protected]_NPC_NAME$);
    	deletearray [email protected]_ACCESS[0], getarraysize([email protected]_ACCESS);
    	deletearray [email protected]_ACCESS_EXPIRE[0], getarraysize([email protected]_ACCESS_EXPIRE);
    	deletearray [email protected]_MF_PARTYLOCK[0], getarraysize([email protected]_MF_PARTYLOCK);
    	deletearray [email protected]_MF_NOMOBLOOT[0], getarraysize([email protected]_MF_NOMOBLOOT);
    	deletearray [email protected]_MF_NOMVPLOOT[0], getarraysize([email protected]_MF_NOMVPLOOT);
    	deletearray [email protected]_MF_NOPENALTY[0], getarraysize([email protected]_MF_NOPENALTY);
    	deletearray [email protected]_MF_NOMOBTELE[0], getarraysize([email protected]_MF_NOMOBTELE);
    	deletearray [email protected]_MF_BASEEXP[0], getarraysize([email protected]_MF_BASEEXP);
    	deletearray [email protected]_MF_JOBEXP[0], getarraysize([email protected]_MF_JOBEXP);
    	//deletearray [email protected]_MF_FOG[0], getarraysize([email protected]_MF_FOG);
    	return;
    }
    
    // Function: Reset all mapflags to original values
    // callfunc("WB_ResetMapflags", <map name>, <index>)
    function	script	WB_ResetMapflags	{
    	[email protected]$ = getarg(0, "null"); // Map name Default="null"
    	[email protected] = getarg(1, 0); // Event index Default=0
    	// Map name exists
    	if ([email protected]$ == "" || [email protected]$ == "null") {
    		debugmes "WB_ResetMapflags was given:"+ [email protected]$;
    		return;
    	}
    	// Party Lock
    	if ( [email protected]_MF_PARTYLOCK[[email protected]] )
    		setmapflag [email protected]$, MF_PARTYLOCK;
    	else
    		removemapflag [email protected]$, MF_PARTYLOCK;
    	// No mob loot
    	if ( [email protected]_MF_NOMOBLOOT[[email protected]] )
    		setmapflag [email protected]$, MF_NOMOBLOOT;
    	else
    		removemapflag [email protected]$, MF_NOMOBLOOT;
    	// No MVP loot
    	if ( [email protected]_MF_NOMVPLOOT[[email protected]] )
    		setmapflag [email protected]$, MF_NOMVPLOOT;
    	else
    		removemapflag [email protected]$, MF_NOMVPLOOT;
    	// No penalty
    	if ( [email protected]_MF_NOPENALTY[[email protected]] )
    		setmapflag [email protected]$, MF_NOPENALTY;
    	else
    		removemapflag [email protected]$, MF_NOPENALTY;
    	// No mob teleport
    	if ( [email protected]_MF_NOMOBTELE[[email protected]] )
    		setmapflag [email protected]$, MF_MONSTER_NOTELEPORT;
    	else
    		removemapflag [email protected]$, MF_MONSTER_NOTELEPORT;
    	// Base Exp
    	setmapflag [email protected]$, MF_BEXP, [email protected]_MF_BASEEXP[[email protected]];
    	// Job Exp
    	setmapflag [email protected]$, MF_JEXP, [email protected]_MF_JOBEXP[[email protected]];
    	// Effect FOG
    	//if ( [email protected]_MF_FOG[[email protected]] )
    	//	setmapflag [email protected]$, MF_FOG;
    	//else
    	//	removemapflag [email protected]$, MF_FOG;
    	return;
    }
    
    // Function: Reset specific Treasure Chest NPC
    // callfunc("WB_ResetBox", <index>)
    function	script	WB_ResetBox	{
    	[email protected] = getarg(0, 0); // Event index Default=0
    	if ( [email protected]_NPC_NAME$[[email protected]] != "" ) {
    		if ( getnpcid(0, [email protected]_NPC_NAME$[[email protected]]) ) {
    			// Do these checks or this will select all NPCs on the server when fail
    			donpcevent [email protected]_NPC_NAME$[[email protected]]+"::OnDisable";
    		}
    	}
    }
    
    // Function: Reset all Treasure Chest NPC's
    // callfunc("WB_ResetAllBoxes")
    function	script	WB_ResetAllBoxes	{
    	for ( [email protected] = 0; [email protected] < getarraysize([email protected]_NPC_NAME$); [email protected]++ ) {
    		if ( [email protected]_NPC_NAME$[[email protected]] != "" ) {
    			if ( getnpcid(0, [email protected]_NPC_NAME$[[email protected]]) ) {
    				// Do these checks or this will select all NPCs on the server when fail
    				donpcevent [email protected]_NPC_NAME$[[email protected]]+"::OnDisable";
    			}
    		}
    	}
    }
    
    // Function Party Select
    // callfunc("WB_PartySelect", <INT_show_offline>, <INT_show_refresh>)
    // Return INT=Party index number, -1=Refresh selected, -2=Not in party
    function	script	WB_PartySelect	{
    	[email protected]_offline = getarg(0, 1); // Show offline players in menu? 1=Yes 0=No
    	[email protected]_refresh = getarg(1, 1); // Show refresh menu item? 1=Yes 0=No
    	[email protected]_id = getcharid(1);  // Party ID
     
    	// Not in a party
    	if ( [email protected]_id )
    		return -2;
     
    	getpartymember [email protected]_id, 0; // Names
    	getpartymember [email protected]_id, 1; // Character IDs
    	getpartymember [email protected]_id, 2; // Account IDs
     
    	// Copy the temporary party data
    	[email protected]_size = [email protected];
    	copyarray [email protected]_member_name$[0], [email protected]$[0], [email protected]_size;
    	copyarray [email protected]_member_cid[0], [email protected][0], [email protected]_size;
    	copyarray [email protected]_member_aid[0], [email protected][0], [email protected]_size;
     
    	// Create menu
    	if ( [email protected]_refresh )
    		[email protected]_party$ = "^777777[Refresh]^000000";
    	[email protected]_party$ = [email protected]_party$ + ":";
     
    	// Loop through each party member and add to menu
    	for ( [email protected] = 0; [email protected] < [email protected]_size; [email protected]++ ) {
    		if ( isloggedin([email protected]_member_aid[[email protected]], [email protected]_member_cid[[email protected]]) ) {
    			if ([email protected]_offline)
    				[email protected]_party$ = [email protected]_party$ + [email protected]_member_name$[[email protected]] + " ^00cc36[ON]^000000";
    			else
    				[email protected]_party$ = [email protected]_party$ + [email protected]_member_name$[[email protected]];
    		} else if ([email protected]_offline)
    			[email protected]_party$ = [email protected]_party$ + [email protected]_member_name$[[email protected]] + " ^777777[OFF]^000000";
    		[email protected]_party$ = [email protected]_party$ + ":";
    	}
     
    	// Open select menu (-2 select start from 1 and we have [Refresh] at first)
    	[email protected] = select([email protected]_party$) - 2;
    	return [email protected];
    }
    
    // Treasure chest NPC
    alberta,0,0,5	script	Treasure Chest#wb_0	1324,{
    	emotion ET_SURPRISE, getcharid(3); // Emotion on the player
    	// Disable current NPC Treasure Chest if empty
    	if ( !getarraysize([email protected]_ACCESS) ) {
    		message strcharinfo(0), "Treasure Chest is empty.";
    		donpcevent strnpcinfo(0)+"::OnDisable";
    		// Stop access expire timer
    		donpcevent "WorldBossAccessExpire::OnDisable";
    		end;
    	}
    	doevent "WorldBoss::OnTreasureOpen";
    	end;
    
    OnInit:
    	[email protected]$ = strnpcinfo(0); //rid2name( [email protected] );
    	[email protected] = getnpctimer(1, [email protected]$);
    	getmapxy(.map$, .x, .y, BL_NPC);
    	disablenpc [email protected]$;
    	//debugmes [email protected]$+"::OnInit target=" + .map$ + " NPC="+ [email protected]$ + " timer="+ [email protected];
    	end;
    
    OnEnable:
    	// if enabled getnpctimer(1, strnpcinfo(0)) will return 1
    	[email protected] = getnpcid(0);
    	[email protected]$ = strnpcinfo(0); //rid2name( [email protected] );
    	[email protected] = getnpctimer(1, [email protected]$);
    
    	[email protected]$ = "WorldBoss";
    	[email protected]$ = getvariableofnpc(.event_map$, [email protected]$);
    	[email protected] = getvariableofnpc(.event_x, [email protected]$);
    	[email protected] = getvariableofnpc(.event_y, [email protected]$);
    
    	enablenpc( [email protected]$ );
    	unitwarp( [email protected], [email protected]$, [email protected], [email protected] ); // Move to new position
    	initnpctimer( [email protected]$ ); // Start timeout timer
    
    	//debugmes [email protected]$+"::OnEnable target="+ [email protected]$ +", "+ [email protected] +", "+ [email protected] +" NPC="+ [email protected]$ +" timer="+ [email protected];
    	end;
    
    // Disable Treasure NPC and clean event array
    OnDisable:
    	[email protected] = getnpcid(0);
    	[email protected]$ = strnpcinfo(0); //rid2name( [email protected] );
    	[email protected] = getnpctimer(1, [email protected]$);
    	getmapxy([email protected]_map$, [email protected], [email protected], BL_NPC);
    
    	stopnpctimer( [email protected]$ ); // Stop timeout timer
    	unitwarp( [email protected], .map$, .x, .y ); // Return to default position
    	disablenpc( [email protected]$ );
    
    	// Clean event data
    	// Get event index from the map name array
    	[email protected] = inarray([email protected]_MAP$[0], [email protected]_map$);
    
    	// Check if index was found
    	if ( [email protected] == -1 ) {
    		debugmes [email protected]$+"::OnDisable event map name ( "+ [email protected]_map$ +" ) not found!";
    		end;
    	}
    
    	// Remove current event from the arrays
    	callfunc("WB_ResetEventGlobals", [email protected]);
    
    	//debugmes [email protected]$+"::OnDisable target="+ [email protected]_map$ +", "+ [email protected] +", "+ [email protected] +" NPC="+ [email protected]$ +" timer="+ [email protected];
    	end;
    
    //OnTimer30000:  // 30 seconds
    //OnTimer120000:  // 2 minutes
    //OnTimer300000:  // 5 minutes
    OnTimer600000: // 10 minutes
    //OnTimer900000: // 15 minutes
    	[email protected]$ = strnpcinfo(0);
    	getmapxy([email protected]$, [email protected], [email protected], BL_NPC);
    	//debugmes [email protected]$+"::OnTimeout target="+ [email protected]$ +", "+ [email protected] +", "+ [email protected] +" NPC="+ [email protected]$;
    	donpcevent [email protected]$+"::OnDisable";
    	end;
    }
    
    // Treasure Chest duplicates (Add more if you run out)
    // NPC Name = Treasure Chest#wb_<indexNumber> (Important!)
    alberta,0,0,5	duplicate(Treasure Chest#wb_0)	Treasure Chest#wb_1	1324
    alberta,0,0,5	duplicate(Treasure Chest#wb_0)	Treasure Chest#wb_2	1324
    alberta,0,0,5	duplicate(Treasure Chest#wb_0)	Treasure Chest#wb_3	1324
    alberta,0,0,5	duplicate(Treasure Chest#wb_0)	Treasure Chest#wb_4	1324
    alberta,0,0,5	duplicate(Treasure Chest#wb_0)	Treasure Chest#wb_5	1324
    alberta,0,0,5	duplicate(Treasure Chest#wb_0)	Treasure Chest#wb_6	1324
    alberta,0,0,5	duplicate(Treasure Chest#wb_0)	Treasure Chest#wb_7	1324
    alberta,0,0,5	duplicate(Treasure Chest#wb_0)	Treasure Chest#wb_8	1324
    alberta,0,0,5	duplicate(Treasure Chest#wb_0)	Treasure Chest#wb_9	1324
    
    // World Boss timeout timer
    -	script	WorldBossTimeout	-1,{
    	end;
    OnEnable:
    	initnpctimer;
    	end;
    OnDisable:
    	stopnpctimer;
    	end;
    // Update every 1 minutes
    OnTimer60000:
    	[email protected] = gettimetick(0);
    	[email protected] = getvariableofnpc(.event_timeout, "WorldBoss");
    	[email protected] = getvariableofnpc(.use_mapflags, "WorldBoss");
    	for ( [email protected] = 0; [email protected] < getarraysize([email protected]_MOB_GID); [email protected]++ ) {
    		// Unit must be alive
    		if ( unitexists([email protected]_MOB_GID[[email protected]]) && [email protected] > ([email protected]_TIMEOUT[[email protected]] + [email protected]) ) {
    			announce "[World Boss] World Boss in "+ [email protected]_MAP$[[email protected]] +" has expired!", bc_all, 0xFF0000;
    			unitkill( [email protected]_MOB_GID[[email protected]] );
    
    			// Reset event mapflags
    			if ( [email protected] ) {
    				callfunc("WB_ResetMapflags", [email protected]_MAP$[[email protected]], [email protected]);
    			}
    
    			// Remove event global arrays
    			callfunc("WB_ResetEventGlobals", [email protected]);
    		}
    	}
    	initnpctimer;
    	end;
    }
    
    // World Boss Unit's Radar
    // Count users around the world boss and increase it's HP by each Player nearby
    -	script	WorldBossRadar	-1,{
    	end;
    OnInit:
    	.npc_name$ = strnpcinfo(0);
    	.radius = 15; // Cell radius
    	.HPLevel = 1500000; // HP increase per player
    	.MinHP = .HPLevel * 2; // Minimum HP when to stop decreasing HP
    	end;
    OnEnable:
    	initnpctimer;
    	end;
    OnDisable:
    	stopnpctimer;
    	end;
    // Every 10 secods update all World Boss unit data
    OnTimer10000:
    	for ( [email protected] = 0; [email protected] < getarraysize([email protected]_MOB_GID); [email protected]++ ) {
    		[email protected]_gid = [email protected]_MOB_GID[[email protected]];
    		if ( unitexists([email protected]_gid) ) {
    			getunitdata([email protected]_gid, [email protected]);
    			[email protected] = [email protected][UMOB_HP];
    			[email protected] = [email protected][UMOB_MAXHP];
    			[email protected] = [email protected][UMOB_X];
    			[email protected] = [email protected][UMOB_Y];
    			[email protected] = getareausers(mapid2name([email protected][UMOB_MAPID]), ([email protected] - .radius), ([email protected] - .radius), ([email protected] + .radius), ([email protected] + .radius));
    			if ( [email protected] > [email protected]_RADAR_NEAR[[email protected]] ) {
    				// Increase HP per each player nearby
    				[email protected]_hp = [email protected] + ( .HPLevel * [email protected] );
    				// Stop increasing HP after maximum has been reached
    				if ( [email protected]_hp < [email protected] ) {
    					setunitdata [email protected]_gid, UMOB_HP, [email protected]_hp;
    					unittalk [email protected]_gid, rid2name([email protected]_gid) + " : Mortals has entered my sight!", bc_area;
    				}
    			} else if ( [email protected] < [email protected]_RADAR_NEAR[[email protected]] ) {
    				// Decrease HP per each player nearby
    				[email protected]_hp = [email protected] - .HPLevel;
    				// Stop decreasing HP after minimum has been reached
    				if ( [email protected]_hp > .MinHP ) {
    					setunitdata [email protected]_gid, UMOB_HP, [email protected]_hp;
    					unittalk [email protected]_gid, rid2name([email protected]_gid) + " : Mortals has left my sight!", bc_area;
    				}
    			}
    			// Update users count
    			setarray [email protected]_RADAR_NEAR[[email protected]], [email protected];
    		}
    	}
    	initnpctimer;
    	end;
    }
    
    // World Boss access expire timer
    // This will clean event access array from getting too big in time.
    -	script	WorldBossAccessExpire	-1,{
    	end;
    OnEnable:
    	//debugmes strnpcinfo(0)+"::OnEnable";
    	initnpctimer;
    	end;
    OnDisable:
    	//debugmes strnpcinfo(0)+"::OnDisable";
    	stopnpctimer;
    	end;
    // Update every 5 minutes
    OnTimer300000:
    	//debugmes strnpcinfo(0)+"::OnTimer";
    	[email protected] = gettimetick(0);
    	[email protected] = getvariableofnpc(.event_access_expire, "WorldBoss");
    	for ( [email protected] = 0; [email protected] < getarraysize([email protected]_ACCESS); [email protected]++ ) {
    		// Check if access has expired
    		if ( [email protected] > ([email protected]_ACCESS_EXPIRE[[email protected]] + [email protected]) ) {
    			// Current access has expired! Remove access and expire time.
    			deletearray [email protected]_ACCESS[[email protected]], 1;
    			deletearray [email protected]_ACCESS_EXPIRE[[email protected]], 1;
    		}
    	}
    	// Continue timer if access is not empty
    	if ( getarraysize([email protected]_ACCESS) ) {
    		initnpctimer;
    	}
    	end;
    }
    
    // World Boss Floating Rates
    -	script	WorldBossRates	-1,{
    OnInit: // Will fire before OnInterIfInitOnce on server start
    	// Floating rates are enabled
    	if(!getvariableofnpc(.use_floating_rates, "WorldBoss")) end;
    
    	// Reset rates on script load
    	if ( $wb_base_exp_rate && getBattleFlag("base_exp_rate") != $wb_base_exp_rate )
    		donpcevent strnpcinfo(0)+"::OnDisable";
    	end;
    
    OnInterIfInitOnce: // Will fire after OnInit on server start
    	// Floating rates are enabled
    	if(!getvariableofnpc(.use_floating_rates, "WorldBoss")) end;
    	// Set once on server start
    	$wb_battle_flags = 0;
    	// Set servers default battle flags
    	$wb_base_exp_rate = getBattleFlag("base_exp_rate");
    	$wb_job_exp_rate = getBattleFlag("job_exp_rate");
    	$wb_item_rate_common = getBattleFlag("item_rate_common");
    	$wb_item_rate_common_boss = getBattleFlag("item_rate_common_boss");
    	$wb_item_rate_common_mvp = getBattleFlag("item_rate_common_mvp");
    	$wb_item_rate_heal = getBattleFlag("item_rate_heal");
    	$wb_item_rate_heal_boss = getBattleFlag("item_rate_heal_boss");
    	$wb_item_rate_heal_mvp = getBattleFlag("item_rate_heal_mvp");
    	$wb_item_rate_use = getBattleFlag("item_rate_use");
    	$wb_item_rate_use_boss = getBattleFlag("item_rate_use_boss");
    	$wb_item_rate_use_mvp = getBattleFlag("item_rate_use_mvp");
    	$wb_item_rate_equip = getBattleFlag("item_rate_equip");
    	$wb_item_rate_equip_boss = getBattleFlag("item_rate_equip_boss");
    	$wb_item_rate_equip_mvp = getBattleFlag("item_rate_equip_mvp");
    	$wb_item_rate_card = getBattleFlag("item_rate_card");
    	$wb_item_rate_card_boss = getBattleFlag("item_rate_card_boss");
    	$wb_item_rate_card_mvp = getBattleFlag("item_rate_card_mvp");
    	$wb_item_rate_mvp = getBattleFlag("item_rate_mvp");
    	$wb_item_rate_adddrop = getBattleFlag("item_rate_adddrop");
    	$wb_item_rate_treasure = getBattleFlag("item_rate_treasure");
    	end;
    
    OnDisable:
    	// Reset normal rates
    	if ( $wb_battle_flags ) {
    		setBattleFlag("base_exp_rate", $wb_base_exp_rate);
    		setBattleFlag("job_exp_rate", $wb_job_exp_rate);
    		setBattleFlag("item_rate_common", $wb_item_rate_common);
    		setBattleFlag("item_rate_common_boss", $wb_item_rate_common_boss);
    		setBattleFlag("item_rate_common_mvp", $wb_item_rate_common_mvp);
    		setBattleFlag("item_rate_heal", $wb_item_rate_heal);
    		setBattleFlag("item_rate_heal_boss", $wb_item_rate_heal_boss);
    		setBattleFlag("item_rate_heal_mvp", $wb_item_rate_heal_mvp);
    		setBattleFlag("item_rate_use", $wb_item_rate_use);
    		setBattleFlag("item_rate_use_boss", $wb_item_rate_use_boss);
    		setBattleFlag("item_rate_use_mvp", $wb_item_rate_use_mvp);
    		setBattleFlag("item_rate_equip", $wb_item_rate_equip);
    		setBattleFlag("item_rate_equip_boss", $wb_item_rate_equip_boss);
    		setBattleFlag("item_rate_equip_mvp", $wb_item_rate_equip_mvp);
    		setBattleFlag("item_rate_card", $wb_item_rate_card);
    		setBattleFlag("item_rate_card_boss", $wb_item_rate_card_boss);
    		setBattleFlag("item_rate_card_mvp", $wb_item_rate_card_mvp);
    		setBattleFlag("item_rate_mvp", $wb_item_rate_mvp);
    		setBattleFlag("item_rate_adddrop", $wb_item_rate_adddrop);
    		setBattleFlag("item_rate_treasure", $wb_item_rate_treasure);
    	}
    	$wb_battle_flags = 0;
    	stopnpctimer;
    	end;
    
    OnEnable:
    	// Check already enabled
    	if ( !$wb_battle_flags ) {
    		// Double server ratings
    		setBattleFlag("base_exp_rate", $wb_base_exp_rate * 2);
    		setBattleFlag("job_exp_rate", $wb_job_exp_rate * 2);
    		setBattleFlag("item_rate_common", $wb_item_rate_common * 2);
    		setBattleFlag("item_rate_common_boss", $wb_item_rate_common_boss * 2);
    		setBattleFlag("item_rate_common_mvp", $wb_item_rate_common_mvp * 2);
    		setBattleFlag("item_rate_heal", $wb_item_rate_heal * 2);
    		setBattleFlag("item_rate_heal_boss", $wb_item_rate_heal_boss * 2);
    		setBattleFlag("item_rate_heal_mvp", $wb_item_rate_heal_mvp * 2);
    		setBattleFlag("item_rate_use", $wb_item_rate_use * 2);
    		setBattleFlag("item_rate_use_boss", $wb_item_rate_use_boss * 2);
    		setBattleFlag("item_rate_use_mvp", $wb_item_rate_use_mvp * 2);
    		setBattleFlag("item_rate_equip", $wb_item_rate_equip * 2);
    		setBattleFlag("item_rate_equip_boss", $wb_item_rate_equip_boss * 2);
    		setBattleFlag("item_rate_equip_mvp", $wb_item_rate_equip_mvp * 2);
    		setBattleFlag("item_rate_card", $wb_item_rate_card * 2);
    		setBattleFlag("item_rate_card_boss", $wb_item_rate_card_boss * 2);
    		setBattleFlag("item_rate_card_mvp", $wb_item_rate_card_mvp * 2);
    		setBattleFlag("item_rate_mvp", $wb_item_rate_mvp * 2);
    		setBattleFlag("item_rate_adddrop", $wb_item_rate_adddrop * 2);
    		setBattleFlag("item_rate_treasure", $wb_item_rate_treasure * 2);
    	}
    	announce "[World Boss] Experience and Drop rates has been doubled for one hour! Enjoy!", bc_all, 0x00FF00;
    	$wb_battle_flags = 1;
    	initnpctimer;
    	end;
    
    OnTimer3600000: // 1 hour
    	donpcevent strnpcinfo(0)+"::OnDisable";
    	end;
    }
    
    // NPC World Boss Information
    prontera,147,174,4	script	World Boss#info	495,5,5,{
    	mes "[ " + strnpcinfo(1) + " ]";
    	mes "About the world bosses.";
    	if ( getarraysize([email protected]_MOB_GID) ) {
    		[email protected] = gettimetick(0);
    		[email protected] = getvariableofnpc(.event_timeout, "WorldBoss");
    		mes "Status: ^00CC36Active^000000";
    		for ( [email protected] = 0; [email protected] < getarraysize([email protected]_MOB_GID); [email protected]++ ) {
    			[email protected] = ([email protected]_TIMEOUT[[email protected]] + [email protected]) - [email protected];
    			mes ([email protected] + 1) + ". Location : " + [email protected]_MAP$[[email protected]];
    			mes " ^777777 Time Left :^000000 " + ([email protected] / 60000) + " min.";
    		}
    		mes "Good luck!";
    	} else {
    		mes "Status: ^CC3300Inactive^000000";
    		mes "Event timetable:";
    		mes "^777777 ~ 04:02 ^000000";
    		mes "^777777 ~ 23:59 ^000000";
    		mes "Wait until the event starts.";
    	}
    	// GM level 60+ has access to menu
    	if( getgmlevel() >= 60 ) {
    		next;
    		switch( select("Information:Start Event:Skip Start Timer:Stop Event:Change Loot Mode:Change Unit Data:Map Flags:Leave") ) {
    			case 1: callsub S_Info; break;
    			case 2: callsub S_Start; break;
    			case 3: callsub S_Skip; break;
    			case 4: callsub S_Stop; break;
    			case 5: callsub S_Loot; break;
    			case 6: callsub S_Unit; break;
    			case 7: callsub S_Mapflags; break;
    			default: break;
    		}
    	}
    	close;
    
    S_Info:
    	// Set variables
    	[email protected] = getarraysize([email protected]_MOB_GID);
    	[email protected]_mode = getvariableofnpc(.loot_mode, .event_npc$);
    	[email protected] = gettimetick(0);
    	[email protected] = getvariableofnpc(.event_timeout, "WorldBoss");
    	mes "[ " + strnpcinfo(1) + " ]";
    	mes "^777777Status: ^000000" + ([email protected] ? "^00CC36Active^000000" : "^CC3300Inactive^000000");
    	mes "^777777Loot mode: ^000000" + .event_loot_modes$[[email protected]_mode];
    	[email protected]$ = "Leave:";
    	for ( [email protected] = 0; [email protected] < getarraysize([email protected]_MOB_GID); [email protected]++ ) {
    		if ( [email protected]_MOB_GID[[email protected]] || [email protected]_NPC_NAME$[[email protected]] != "" ) {
    			// Monster Unit
    			[email protected] = ([email protected]_TIMEOUT[[email protected]] + [email protected]) - [email protected]; // ms
    			// Get unit data
    			if ( unitexists([email protected]_MOB_GID[[email protected]]) ) {
    				// Monster unit
    				getunitdata([email protected]_MOB_GID[[email protected]], [email protected]);
    				mes ([email protected] + 1) +". Monster: " + [email protected]_MOB_ID[[email protected]] +" / "+ getmonsterinfo([email protected]_MOB_ID[[email protected]], 0);
    				mes " ^777777 GID: ^000000" + [email protected]_MOB_GID[[email protected]];
    				mes " ^777777 Name: ^000000" + rid2name([email protected]_MOB_GID[[email protected]]);
    				mes " ^777777 HP: ^000000" + [email protected][UMOB_HP] + " / " + [email protected][UMOB_MAXHP];
    				mes " ^777777 Location: ^000000" + mapid2name([email protected][UMOB_MAPID]) +
    					" ^777777 x ^000000" + [email protected][UMOB_X] +
    					" ^777777 y ^000000" + [email protected][UMOB_Y];
    				mes " ^777777 Time Left :^000000 " + ([email protected] / 60000) + " min.";
    			} else if (unitexists(getnpcid(0, [email protected]_NPC_NAME$[[email protected]]))) {
    				// NPC unit
    				getunitdata(getnpcid(0, [email protected]_NPC_NAME$[[email protected]]), [email protected]);
    				mes ([email protected] + 1) +". Treasure Chest";
    				mes " ^777777 GID: ^000000" + getnpcid(0, [email protected]_NPC_NAME$[[email protected]]);
    				mes " ^777777 Name: ^000000" + [email protected]_NPC_NAME$[[email protected]];
    				mes " ^777777 Location: ^000000" + mapid2name([email protected][UNPC_MAPID]) +
    					" ^777777 x ^000000" + [email protected][UNPC_X] +
    					" ^777777 y ^000000" + [email protected][UNPC_Y];
    			}
    			mes "^777777-------^000000";
    			[email protected]$ += "Go to "[email protected]_MAP$[[email protected]];
    		}
    		[email protected]$ += ":";
    	}
    	[email protected] = select([email protected]$) - 2;
    	if ( [email protected] >= 0 ) {
    		if ( unitexists([email protected]_MOB_GID[[email protected]]) ) {
    			// Warp to the monster location
    			getunitdata([email protected]_MOB_GID[[email protected]], [email protected]);
    			warp mapid2name([email protected][UMOB_MAPID]), [email protected][UMOB_X], [email protected][UMOB_Y];
    		} else if ( [email protected]_NPC_NAME$[[email protected]] != "" ) {
    			// Warp to the NPC location
    			if (unitexists(getnpcid(0, [email protected]_NPC_NAME$[[email protected]]))) {
    				getunitdata(getnpcid(0, [email protected]_NPC_NAME$[[email protected]]), [email protected]);
    				warp mapid2name([email protected][UNPC_MAPID]), [email protected][UNPC_X], [email protected][UNPC_Y];
    			}
    		}
    		end;
    	}
    	return;
    
    S_Mapflags:
    	mes "[ " + strnpcinfo(1) + " ] Mapflags";
    	[email protected] = getarraysize([email protected]_MOB_GID);
    	[email protected] = getvariableofnpc(.use_mapflags, "WorldBoss");
    	if ( [email protected] && [email protected] ) {
    		for ( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
    			[email protected]$ = [email protected]_MAP$[[email protected]];
    			mes [email protected]$ + " : Original Flags";
    			mes " ^777777 PartyLock : " + [email protected]_MF_PARTYLOCK[[email protected]] + "^000000";
    			mes " ^777777 NoMobLoot : " + [email protected]_MF_NOMOBLOOT[[email protected]] + "^000000";
    			mes " ^777777 NoMVPLoot : " + [email protected]_MF_NOMVPLOOT[[email protected]] + "^000000";
    			mes " ^777777 NoPenalty : " + [email protected]_MF_NOPENALTY[[email protected]] + "^000000";
    			mes " ^777777 NoMobTele : " + [email protected]_MF_NOMOBTELE[[email protected]] + "^000000";
    			mes " ^777777 BaseExp : " + [email protected]_MF_BASEEXP[[email protected]] + "^000000";
    			mes " ^777777 JobExp : " + [email protected]_MF_JOBEXP[[email protected]] + "^000000";
    			//mes " ^777777 Fog : " + [email protected]_MF_FOG[[email protected]] + "^000000";
    			mes [email protected]$ + " : New Flags";
    			mes " ^777777 PartyLock : " + getmapflag([email protected]$, MF_PARTYLOCK) + "^000000";
    			mes " ^777777 NoMobLoot : " + getmapflag([email protected]$, MF_NOMOBLOOT) + "^000000";
    			mes " ^777777 NoMVPLoot : " + getmapflag([email protected]$, MF_NOMVPLOOT) + "^000000";
    			mes " ^777777 NoPenalty : " + getmapflag([email protected]$, MF_NOPENALTY) + "^000000";
    			mes " ^777777 NoMobTele : " + getmapflag([email protected]$, MF_MONSTER_NOTELEPORT) + "^000000";
    			mes " ^777777 BaseExp : " + getmapflag([email protected]$, MF_BEXP) + "^000000";
    			mes " ^777777 JobExp : " + getmapflag([email protected]$, MF_JEXP) + "^000000";
    			//mes " ^777777 Fog : " + getmapflag([email protected]$, MF_FOG) + "^000000";
    			mes "^777777-------^000000";
    		}
    	} else {
    		mes "No mapflags has been set.";
    	}
    	return;
    
    S_Start:
    	donpcevent .event_npc$ + "::OnEnable";
    	message strcharinfo(0), "Event has been started!";
    	return;
    
    S_Skip:
    	awake .event_npc$; // Cancels any running sleep timers on the NPC
    	message strcharinfo(0), "Event timer has been skipped!";
    	return;
    
    S_Stop:
    	awake .event_npc$; // Cancels any running sleep timers on the NPC
    	donpcevent .event_npc$ + "::OnDisable";
    	// Announce event stopped
    	announce "[World Boss] The event has been stopped!", bc_all, 0xFF0000;
    	message strcharinfo(0), "Event has been stopped!";
    	return;
    
    S_Loot:
    	[email protected] = getarraysize(.event_loot_modes$);
    	for( [email protected] = 0; [email protected] < [email protected]; [email protected]++ ) {
    		message strcharinfo(0), "Loot mode "+ [email protected] +" : " + .event_loot_modes$[[email protected]];
    	}
    	// Change event loot mode option
    	input [email protected], 0, [email protected];
    	set getvariableofnpc(.loot_mode, .event_npc$), [email protected];
    	message strcharinfo(0), "Event loot mode changed: " + .event_loot_modes$[[email protected]];
    	return;
    
    S_Unit:
    	// Create menu
    	[email protected]$ = "Leave:";
    	for ( [email protected] = 0; [email protected] < getarraysize([email protected]_MOB_GID); [email protected]++ ) {
    		if ( unitexists([email protected]_MOB_GID[[email protected]]) ) {
    			[email protected]$ += [email protected]_MAP$[[email protected]] +" - "+ getmonsterinfo([email protected]_MOB_ID[[email protected]], 0);
    		}
    		[email protected]$ += ":";
    	}
    	[email protected] = select([email protected]$) - 2;
    
    	// Change unit data (HP,Level,Atk,Etc.)
    	if ( [email protected] >= 0 ) {
    		mes "[ " + strnpcinfo(1) + " ]";
    		getunitdata([email protected]_MOB_GID[[email protected]], [email protected]);
    		for ([email protected] = 0; [email protected] < getarraysize([email protected]); [email protected]++ ) {
    			mes .UMOB$[[email protected]] + " = " + [email protected][[email protected]];
    		}
    		[email protected] = select(.UMOB_menu$) - 1;
    		message strcharinfo(0), "Write a new unit ( " + .UMOB$[[email protected]] + " ) value.";
    		input [email protected], 0, 1000000000;
    		setunitdata([email protected]_MOB_GID[[email protected]], [email protected], [email protected]);
    		// Confim data has changed
    		getunitdata([email protected]_MOB_GID[[email protected]], [email protected]_udata);
    		message strcharinfo(0), "New unit data is: " + [email protected]_udata[[email protected]];
    	}
    	return;
    
    OnInit:
    	// Event NPC name
    	.event_npc$ = "WorldBoss";
    
    	// Event loot mode descriptions
    	// Copy array from other NPC
    	copyarray .event_loot_modes$[0], getelementofarray(getvariableofnpc(.loot_mode_desc$, .event_npc$),0), getarraysize(getvariableofnpc(.loot_mode_desc$, .event_npc$));
    
    	// Unit data attibute names
    	setarray .UMOB$[0],
    		"Size","Level","Hp","Max Hp",
    		"Master AID","Map ID","Map X","Map Y",
    		"Speed","Mode","Ai","Scoption",
    		"Sex","Class","Hair style","Hair color",
    		"Head bottom","Head middle","Head top","Cloth color",
    		"Shield","Weapon","Look dir","Can move tick",
    		"Str","Agi","Vit","Int",
    		"Dex","Luk","Slave cpymstrmd","Dmg immune",
    		"Atk range","Atk min","Atk max","Matk min",
    		"Matk max","Def","Mdef","Hit",
    		"Flee","Pdodge","Crit","Race",
    		"Ele type","Ele level","A-motion","A-delay",
    		"D-motion";
    
    	// Unit data menu string
    	.UMOB_menu$ = implode(.UMOB$, ":");
    
    	// Set NPC size if class_id supports
    	[email protected]_class = rand(495, 498);
    	[email protected]_size = rand(0, 2); // 0=normal, 1=small, 2=big
    	setnpcdisplay(strnpcinfo(0), strnpcinfo(1), [email protected]_class, [email protected]_size);
    	end;
    
    OnTouch:
    	// Player attached
    	end;
    
    OnTouchNPC:
    	// Monster attached
    	[email protected]_GID = getattachedrid();
    	//[email protected]_NAME$ = rid2name([email protected]_GID);
    	//debugmes "Target unit name:" + [email protected]_NAME$;
    	// Get unit data as Array
    	getunitdata([email protected]_GID, [email protected]);
    	[email protected]_AID = [email protected][UMOB_MASTERAID]; // UMOB_MASTERAID=4
    	// Unit has a master
    	if ( [email protected]_AID ) {
    		[email protected]_NAME$ = rid2name([email protected]_AID);
    		[email protected] = isloggedin([email protected]_AID);
    		if ( [email protected] ) {
    			end; // Do not target players unit
    		}
    	}
    	// NPC emotion
    	emotion ET_KEK;
    	// Warp monsters away from the NPC
    	unitwarp 0, "this", -1, -1;
    	end;
    }

    im using this script

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.