summaryrefslogtreecommitdiff
path: root/world/map/npc/annuals/xmas
diff options
context:
space:
mode:
Diffstat (limited to 'world/map/npc/annuals/xmas')
-rw-r--r--world/map/npc/annuals/xmas/barriers.txt161
-rw-r--r--world/map/npc/annuals/xmas/config.txt301
-rw-r--r--world/map/npc/annuals/xmas/core.txt239
-rw-r--r--world/map/npc/annuals/xmas/debug.txt235
-rw-r--r--world/map/npc/annuals/xmas/helpers.txt48
-rw-r--r--world/map/npc/annuals/xmas/list.txt102
-rw-r--r--world/map/npc/annuals/xmas/mobmanager.txt99
-rw-r--r--world/map/npc/annuals/xmas/reagents.txt142
-rw-r--r--world/map/npc/annuals/xmas/states.txt55
-rw-r--r--world/map/npc/annuals/xmas/tree_beard.txt107
10 files changed, 1489 insertions, 0 deletions
diff --git a/world/map/npc/annuals/xmas/barriers.txt b/world/map/npc/annuals/xmas/barriers.txt
new file mode 100644
index 00000000..7db8a472
--- /dev/null
+++ b/world/map/npc/annuals/xmas/barriers.txt
@@ -0,0 +1,161 @@
+// This file is part of Christmas Event
+// author: Jenalya, Chayenne, cinderweb, wushin
+// please see #XmasConfig
+
+function|script|ThrowOutTheBum|,
+{
+ if((@xmas_thrown_out) && ($@xmas_time))
+ goto L_SideOut;
+ goto L_Return;
+
+L_SideOut:
+ if(@xmas_helper_start_state)
+ goto L_Warp;
+ goto L_Hint;
+
+L_Hint:
+ message strcharinfo(0), "I said get out! We've got no time for your kind here.";
+ mes "[Orum's Homunculus]";
+ mes "\"What are you doing? Come, see me in the caves below!\"";
+ mes "\"I said go north till you reach the snoman. Then head into the cave to the east.\"";
+ warp "030-1",99,55;
+ close;
+
+L_Warp:
+ message strcharinfo(0), "I said get out, We've no time for your kind here.";
+ warp "030-1",99,55;
+ end;
+
+L_Return:
+ return;
+}
+
+// Annual Xmas Boss Fight Door
+030-2.gat,153,21,0|script|#DarkDoor|45,0,0,
+{
+ callfunc "XmasStates";
+
+ if((@xmas_boss_door_state) && ($@xmas_time))
+ goto L_XmasMain;
+ goto L_NotActive;
+
+L_XmasMain:
+ mes "You get the strange sensation that this might go terribly wrong. You had better bring some of your strongest comrades to help you in that case.";
+ mes "Open the warehouse door?";
+ menu
+ "Yes, I feel brave.", L_Open,
+ "No, It's quite nice out here.", L_Close;
+
+L_Open:
+ if ($@XmasBattleStatus) goto L_BattleInProgress;
+ warp "030-4.gat",34,48;
+ goto L_Close;
+
+L_BattleInProgress:
+ mes "You can hear shouts and screams of despair from behind the door. But trying to open it fails.";
+ next;
+ mes "You will have to wait till someone from the inside opens the door again.";
+ goto L_Close;
+
+L_NotActive:
+ message strcharinfo(0), "This door appears locked by magical forces.";
+ end;
+
+L_Close:
+ close;
+}
+
+// Annual Xmas secret passage to a trapdoor in Santa's Inn Basement
+
+030-3.gat,100,49,0|script|SmallCrack#XmasPassage|400,0,1,
+{
+ callfunc "XmasStates";
+
+ if((@xmas_basement_passage) && ($@xmas_time))
+ goto L_XmasMain;
+ goto L_NotActive;
+
+L_NotActive:
+ mes "You don't notice anything special.";
+ goto L_Close;
+
+L_XmasMain:
+ mes "You notice a small creak in the wall, what do you want to do?";
+ next;
+
+L_EnterDialogue:
+ menu
+ "Nothing.", L_Close,
+ "Bang my head against it repeatedly.", L_Tux9th,
+ "Oh, not very much, I do not see anynthing there.", L_Close,
+ "Hit it with my strong fist.", L_Enter;
+
+L_Tux9th:
+ itemheal -20, 0;
+ message strcharinfo(0), "Ouch, that hurt!";
+ setlook LOOK_HAIR_STYLE, rand(20);
+ goto L_Fail;
+
+L_Enter:
+ if (getequipid(equip_hand1) > 0 || getequipid(equip_hand2) > 0) goto L_Sword;
+ if (getequipid(equip_gloves) <= 0) goto L_Gloves;
+ goto L_QueryWarp;
+
+L_Sword:
+ mes "That is not your fist silly,";
+ mes "use your fist, alright?";
+ goto L_Close;
+
+L_Gloves:
+ mes "Wow! Next time you plan to hit a wall,";
+ mes "you had better equip some decent gloves in advance.";
+ itemheal -20, 0;
+ message strcharinfo(0), "Ouch, that hurt!";
+ goto L_QueryWarp;
+
+L_QueryWarp:
+ mes "You gaze into a black hole, do you want to enter?";
+ mes " ";
+ menu
+ "Yes", L_Warp,
+ "No", L_Close;
+ goto L_Close;
+
+L_Warp:
+ warp "030-2.gat",47,44;
+ goto L_Close;
+
+L_Fail:
+ mes "Seems like that won't work out as you planned.";
+ goto L_Close;
+
+L_Close:
+ close;
+}
+
+// Annual Xmas Escape Hatch
+030-2.gat,48,44,0|script|#BasementDoor|45,0,0,
+{
+ callfunc "XmasStates";
+
+ if((@xmas_basement_passage) && ($@xmas_time))
+ goto L_XmasMain;
+ goto L_NotActive;
+
+L_XmasMain:
+ mes "Descend into the caves?";
+ menu
+ "Yes.", L_Open,
+ "No.", L_Close;
+
+L_Open:
+ warp "030-3.gat",100,50;
+ goto L_Close;
+
+L_NotActive:
+ message strcharinfo(0), "This door appears locked by magical forces.";
+ end;
+
+L_Close:
+ close;
+}
diff --git a/world/map/npc/annuals/xmas/config.txt b/world/map/npc/annuals/xmas/config.txt
new file mode 100644
index 00000000..d723073f
--- /dev/null
+++ b/world/map/npc/annuals/xmas/config.txt
@@ -0,0 +1,301 @@
+// This file is part of Christmas Event
+// author: Jenalya, Chayenne, cinderweb, wushin
+
+// NPC behavior depending on time:
+// No Event Time: The event didn't start yet or already ended - the house is closed and the outside NPCs give generic dialogue
+// Event Time: Christmas preparation is in progress, main quest can be done
+// Reward Time: Christmas is over, if the main quest was finished, the reward can be taken
+// for now variable xmas used
+// Main quest states: XMASTIME
+// NIBBLE_0
+// 0-15: Main Quest States
+// Nibble_1: @xmas_karma, Event Behavior
+// 0-15: 0: Naughty, 15: Nice
+// List BITS:
+// 8: 021-1.gat,87,66,0|script|Ayasha|258
+// 9: 021-1.gat,63,107,0|script|Latif|262
+// 10: 021-1.gat,123,116,0|script|Charda|260
+// 11: 021-1.gat,78,87,0|script|Faris|259
+// 12: 021-1.gat,98,25,0|script|Rasin|263
+// 13: 021-1.gat,155,25,0|script|Ghada|265
+// 14: 025-1.gat,80,88,0|script|Rossy|114
+// 15: 001-2.gat,76,59,0|script|Kadiya|174
+// Helper Bits
+// 16: Bedding End
+// 17: Bedding Starts
+// 18: Glitter End
+// 19: Glitter Start
+// 20: Storage Helper
+// 21: Roasted Acorns
+// 22: Santa's Helper
+// 23: - free -
+// 24: Basement Passage
+// 25: Thrown Out
+// 26: Boss started Once by Player
+// 27: Boss won on hard mode
+// 28: Perfect Helpers
+// 29: Prefect List
+// 30: Helper Bit
+// 31: Side Choosen: Naughty vs. Nice
+
+-|script|#XmasConfig|-1,
+{
+OnCommandRestartQuest:
+ goto L_Main;
+
+OnInit:
+ goto L_Main;
+
+L_Main:
+ // Xmas Key Identifier Set through Botcheck Debug
+ if(!($XMAS_TIME_KEY) || (getarraysize($XMAS_TIME_KEY) != 6))
+ setarray $XMAS_TIME_KEY, 12,12,1,25,6,gettime(7);
+ if(($XMAS_TIME_KEY[0] == 0) || ($XMAS_TIME_KEY[0] > 12))
+ goto L_XmasError;
+ if(($XMAS_TIME_KEY[1] == 0) || ($XMAS_TIME_KEY[1] > 12))
+ goto L_XmasError;
+ if(($XMAS_TIME_KEY[2] == 0) || ($XMAS_TIME_KEY[2] > 12))
+ goto L_XmasError;
+ if(($XMAS_TIME_KEY[3] == 0) || ($XMAS_TIME_KEY[3] > 31))
+ goto L_XmasError;
+ if(($XMAS_TIME_KEY[4] == 0) || ($XMAS_TIME_KEY[4] > 31))
+ goto L_XmasError;
+ if($XMAS_TIME_KEY[5] == 0)
+ goto L_XmasError;
+
+ // Event Runs until Reward Period.
+ // Month Start/End
+ set $@xmas_start_month, $XMAS_TIME_KEY[0];
+ set $@xmas_reward_start_month, $XMAS_TIME_KEY[1];
+ set $@xmas_end_month, $XMAS_TIME_KEY[2];
+
+ // Reward Day Start/End
+ set $@xmas_reward_start_day, $XMAS_TIME_KEY[3];
+ set $@xmas_reward_end_day, $XMAS_TIME_KEY[4];
+
+ // Time Settings
+ set $@xmas_no_event_time, 0;
+ set $@xmas_event_time, 1;
+ set $@xmas_reward_time, 2;
+
+ // Xmas debug (sets time)
+ set $@xmas_debug, 0;
+
+ // Main Quest Settings
+ // Bit used to Set Which one of the 2 quests you are on
+ set $@xmas_side_bit, (1 << 31);
+ set $@xmas_base_bonus_xp, 4;
+ set $@xmas_karma_bonus, 1;
+ set $@xmas_reward_max_karma, 15;
+ set $@xmas_reward_hero_boss, 15;
+ set $@xmas_reward_all_lists, 10;
+ set $@xmas_reward_all_helpers, 10;
+ set $@xmas_reward_tally_rare, 80;
+ set $@xmas_reward_tally_common, 40;
+ // Guidance System
+ set $@xmas_route_bit, (1 << 23);
+ // Basement Passage way
+ set $@xmas_basement_passage, (1 << 24);
+ // Thrown Out
+ set $@xmas_thrown_out_bit, (1 << 25);
+ // Quest Start (@xmas_state)
+ set $@xmas_list_path2_state, 1;
+ set $@xmas_list_path1_state, 2;
+ set $@xmas_list_both_state, 3;
+ set $@xmas_list_complete_state, 4;
+ set $@xmas_list_deliver_state, 5;
+ // Helper SubQuest
+ set $@xmas_helpers_start_state, 6;
+ set $@xmas_helpers_done_state, 7;
+ // Reagents
+ set $@xmas_reagents_start, 8;
+ set $@xmas_reagents_done, 9;
+ // Boss Door State
+ set $@xmas_boss_door_open_state, 10;
+ // Reward State
+ set $@xmas_reward_start, 11;
+ set $@xmas_reward1_done, 12;
+ set $@xmas_reward2_done, 13;
+ set $@xmas_reward_done, 14;
+
+ // Boss Fight Required Level for Hard Mode
+ set $@BossHardLevel, 70;
+ set $@xmas_boss_start_bit, (1 << 26);
+ set $@xmas_boss_hero_bit, (1 << 27);
+ set $@xmas_boss_start_shift, 26;
+ set $@xmas_boss_hero_shift, 27;
+ setarray $@xmas_boss_req$, "IronPotion", "DarkCrystal";
+ setarray $@xmas_boss_amount, 15, 10;
+ if(getarraysize($@xmas_boss_amount) != getarraysize($@xmas_boss_req$))
+ goto L_XmasError;
+ // Santas Helper quest rewards
+ setarray $@SantasHelper_Annual_Reward$,
+ "RedTurtleneckSweater",
+ "YellowTurtleneckSweater",
+ "LightBlueTurtleneckSwea",
+ "PinkTurtleneckSweater",
+ "OrangeTurtleneckSweater",
+ "PurpleTurtleneckSweater",
+ "KnitCap",
+ "KnitCap";
+
+ // Main Quest rewards
+ setarray $@xmas_present_from$, "Santa", "Orum";
+ setarray $@xmas_rare_reward$, "FunkyChristmasSweater", "DarkChristmasSweater";
+ setarray $@xmas_uncommon_reward$, "NutcrackerHat", "AmberChristmasSweater", "RedStockings", "PinkChristmasSweater", "BlueChristmasSweater";
+ // Quest Side 0 Settings
+ setarray $@xmas_zero_reagents$, "ShockSweet", "EmptyBottle", "EmeraldPowder";
+ setarray $@xmas_zero_reagents_names$, "ShockSweet", "Empty Bottles", "Emerald Powders";
+ setarray $@xmas_zero_reagents_amounts, 1, 4, 10;
+ if(getarraysize($@xmas_zero_reagents_amounts) != getarraysize($@xmas_zero_reagents$))
+ goto L_XmasError;
+
+ // Quest Side 1 Settings
+ setarray $@xmas_one_reagents$, "DarkCrystal", "IronPotion", "EmeraldPowder";
+ setarray $@xmas_one_reagents_names$, "Dark Crystal", "Iron Potions", "Emerald Powders";
+ setarray $@xmas_one_reagents_amounts, 1, 4, 10;
+ if(getarraysize($@xmas_one_reagents_amounts) != getarraysize($@xmas_one_reagents$))
+ goto L_XmasError;
+
+ // List Bits
+ set $@xmas_all_lists_bit, (1 << 29);
+ setarray $@xmas_child_list, (1 << 8), (1 << 9), (1 << 10), (1 << 11), (1 << 12), (1 << 13), (1 << 14), (1 << 15);
+ setarray $@xmas_child_list_name$, "Ayasha", "Latif", "Charda", "Faris", "Rasin", "Ghada", "Rossy", "Kadiya";
+ if(getarraysize($@xmas_child_list) != getarraysize($@xmas_child_list_name$))
+ goto L_XmasError;
+
+ set $@xmas_perfect_list_count, getarraysize($@xmas_child_list);
+ set $@xmas_required_list_count, (getarraysize($@xmas_child_list) / 2);
+
+ // Santa's Helper
+ set $@xmas_sh_bit, (1 << 22);
+ set $@xmas_sh_purple_amount, 25;
+ set $@xmas_sh_blue_amount, 20;
+ set $@xmas_sh_green_amount, 5;
+
+ // Main Helper Bit
+ set $@xmas_helper_bit, (1 << 30);
+ set $@xmas_all_helpers_bit, (1 << 28);
+
+ // Acorns
+ set $@xmas_helper_bit_acorns, (1 << 21);
+ set $@xmas_acorn_amount, 10;
+ set $@xmas_iron_potion_amount, 1;
+
+ // Bedding
+ set $@xmas_helper_bit_bed_starts, (1 << 16);
+ set $@xmas_helper_bit_bed_ends, (1 << 17);
+ set $@xmas_bedding_amount, 10;
+
+ // Boxes
+ set $@xmas_log_amount, 2;
+
+ // Wrap
+ set $@xmas_reed_amount, 2;
+ set $@xmas_water_amount, 1;
+ set $@xmas_wrap_reward, 1;
+
+ // Wrap Dye Amounts
+ set $@xmas_poa_amount, 2;
+ set $@xmas_wrap_yellow_amount, 2;
+ set $@xmas_wrap_ltblue_amount, 2;
+ set $@xmas_wrap_purple_amount, 2;
+ set $@xmas_wrap_green_amount, 2;
+
+ // Present Return
+ set $@xmas_present_amount, 5;
+
+ // Shipping
+ set $@xmas_wrap_amount, 1;
+ set $@xmas_empty_box_amount, 1;
+ set $@xmas_ship_present_amount, 1;
+
+ // Glitter
+ set $@xmas_helper_bit_glitter_starts, (1 << 18);
+ set $@xmas_helper_bit_glitter_ends, (1 << 19);
+ set $@xmas_red_amount, 5;
+ set $@xmas_yellow_amount, 5;
+
+ // Storage (Daily Xmas)
+ set $@xmas_helper_bit_storage, (1 << 20);
+ // Good Daily Ammounts
+ set $@xmas_good_level, 30;
+ set $@xmas_good_cost, 12;
+ set $@xmas_good_count, 3;
+ set $@xmas_good_name$, "Candy";
+ set $@xmas_good_friendly_name$, "Candies";
+ set $@xmas_good_money, 500;
+ set $@xmas_good_exp, 200;
+
+ // Bad Daily Ammounts
+ set $@xmas_bad_level, 30;
+ set $@xmas_bad_cost, 12;
+ set $@xmas_bad_count, 3;
+
+ set $@xmas_bad_name$, "RedApple";
+ set $@xmas_bad_friendly_name$, "Red Apples";
+ set $@xmas_bad_money, 500;
+ set $@xmas_bad_exp, 200;
+
+ //Boss Fight Reward
+ set $@xmas_boss_bp, 50;
+
+ // Helpers Flags needed to set $@xmas_all_helpers_bit
+ setarray $@xmas_helper_list, $@xmas_helper_bit_bed_ends, $@xmas_helper_bit_glitter_ends, $@xmas_helper_bit_storage, $@xmas_helper_bit_acorns, $@xmas_sh_bit;
+ set $@xmas_perfect_helpers_count, getarraysize($@xmas_helper_list);
+ set $@xmas_required_helpers_count, (getarraysize($@xmas_helper_list) / 2);
+
+ // MobManager
+ setarray $@xmas_mob_names$, "Santa Slime", "Candied Slime", "Candied Slime";
+ setarray $@xmas_mob_spawns, "1015", "1111", "1111";
+ setarray $@xmas_mob_counts, 10, 5, 5;
+ setarray $@xmas_map_spawns$, "019-1.gat", "019-3.gat", "030-3.gat";
+ if(getarraysize($@xmas_mob_spawns) != getarraysize($@xmas_map_spawns$))
+ goto L_XmasError;
+ if(getarraysize($@xmas_mob_names$) != getarraysize($@xmas_map_spawns$))
+ goto L_XmasError;
+ if(getarraysize($@xmas_mob_counts) != getarraysize($@xmas_map_spawns$))
+ goto L_XmasError;
+
+ set $@xmas_spawn_x1, 54;
+ set $@xmas_spawn_y1, 48;
+ set $@xmas_spawn_x2, 79;
+ set $@xmas_spawn_y2, 89;
+ set $@xmas_respawn_count, 9;
+
+ if($@xmas_debug == $@xmas_event_time)
+ goto L_EventTime;
+ if($@xmas_debug == $@xmas_reward_time)
+ goto L_RewardTime;
+
+ if((gettime(6) == $@xmas_reward_start_month && gettime(5) >= $@xmas_reward_start_day)
+ || (gettime(6) == $@xmas_end_month && gettime(5) <= $@xmas_reward_end_day))
+ goto L_RewardTime;
+ if(gettime(6) == $@xmas_start_month)
+ goto L_EventTime;
+
+L_NoEventTime:
+ if($XMAS_TIME_KEY[5] < gettime(7))
+ setarray $XMAS_TIME_KEY, $XMAS_TIME_KEY[0],$XMAS_TIME_KEY[1],$XMAS_TIME_KEY[2],$XMAS_TIME_KEY[3],$XMAS_TIME_KEY[4],gettime(7);
+ set $@xmas_time, $@xmas_no_event_time;
+ goto L_Return;
+
+L_EventTime:
+ set $@xmas_time, $@xmas_event_time;
+ goto L_Return;
+
+L_RewardTime:
+ set $@xmas_time, $@xmas_reward_time;
+ goto L_Return;
+
+L_Return:
+ callfunc "ReplaceTrees";
+ callfunc "SpawnMobs";
+ callfunc "PresentHandler";
+ end;
+
+L_XmasError:
+ debugmes "Xmas is Dead Jim.";
+ gmcommand "@mapexit";
+ end;
+}
diff --git a/world/map/npc/annuals/xmas/core.txt b/world/map/npc/annuals/xmas/core.txt
new file mode 100644
index 00000000..f8454088
--- /dev/null
+++ b/world/map/npc/annuals/xmas/core.txt
@@ -0,0 +1,239 @@
+// This file is part of Christmas Event
+// author: Jenalya, Chayenne, cinderweb, wushin
+// please see #XmasConfig
+
+function|script|XmasNaughty|,
+{
+ set @xmas_karma, ((XMASTIME & NIBBLE_1_MASK) >> NIBBLE_1_SHIFT);
+ if((@xmas_karma - @karma_bonus) >= 0)
+ goto L_SetNaughty;
+ goto L_ResetNaughty;
+
+L_SetNaughty:
+ set @xmas_karma, (@xmas_karma - @karma_bonus);
+ goto L_Return;
+
+L_ResetNaughty:
+ set @xmas_karma, 0;
+ goto L_Return;
+
+L_Return:
+ set XMASTIME, (XMASTIME & ~(NIBBLE_1_MASK) | (@xmas_karma << NIBBLE_1_SHIFT));
+ set @karma_bonus, 0;
+ return;
+}
+
+function|script|XmasNice|,
+{
+ set @xmas_karma, ((XMASTIME & NIBBLE_1_MASK) >> NIBBLE_1_SHIFT);
+ if((@xmas_karma + @karma_bonus) < 16)
+ goto L_SetNice;
+ goto L_ResetNice;
+
+L_SetNice:
+ set @xmas_karma, (@karma_bonus + @xmas_karma);
+ goto L_Return;
+
+L_ResetNice:
+ set @xmas_karma, 15;
+ goto L_Return;
+
+L_Return:
+ set XMASTIME, (XMASTIME & ~(NIBBLE_1_MASK) | (@xmas_karma << NIBBLE_1_SHIFT));
+ set @karma_bonus, 0;
+ return;
+}
+
+// Called for a basic reward for quests state completion
+function|script|XmasXpReward|,
+{
+ if (BaseLevel >= 10)
+ goto L_HigherLevel;
+ goto L_LowLevel;
+
+L_HigherLevel:
+ getexp ((BaseLevel / 10) * ($@xmas_base_bonus_xp * BaseLevel)), 0;
+ goto L_Return;
+
+L_LowLevel:
+ getexp ($@xmas_base_bonus_xp * BaseLevel), 0;
+ goto L_Return;
+
+L_Return:
+ return;
+}
+
+function|script|XmasSetState|,
+{
+ set XMASTIME, (XMASTIME & ~(NIBBLE_0_MASK) | (@xmas_state << NIBBLE_0_SHIFT));
+ return;
+}
+
+function|script|XmasSetSide|,
+{
+ set XMASTIME, XMASTIME | $@xmas_side_bit;
+ return;
+}
+
+function|script|XmasSetRoute|,
+{
+ set XMASTIME, XMASTIME | $@xmas_route_bit;
+ return;
+}
+
+function|script|XmasThrowOut|,
+{
+ set XMASTIME, XMASTIME | $@xmas_thrown_out_bit;
+ return;
+}
+
+function|script|XmasSetBossStart|,
+{
+ set XMASTIME, XMASTIME | $@xmas_boss_start_bit;
+ return;
+}
+
+function|script|XmasSetBossHero|,
+{
+ set XMASTIME, XMASTIME | $@xmas_boss_hero_bit;
+ return;
+}
+
+// Tallys the players quest
+function|script|XmasSetReward|,
+{
+ set @xmas_endgame, 0;
+ set @xmas_reward_side, 0;
+ set @xmas_reward_tally, 0;
+ if(@xmas_side)
+ goto L_SetSide;
+ goto L_NotSetSide;
+
+L_SetSide:
+ set @xmas_reward_side, 1;
+ set @xmas_reward_tally, (@xmas_reward_tally + ($@xmas_reward_max_karma - @xmas_karma));
+ goto L_SetRewardBonus;
+
+L_NotSetSide:
+ set @xmas_reward_tally, (@xmas_reward_tally + @xmas_karma);
+ goto L_SetRewardBonus;
+
+L_SetRewardBonus:
+ if(@xmas_boss_hero)
+ set @xmas_reward_tally, (@xmas_reward_tally + $@xmas_reward_hero_boss);
+ if(@xmas_all_helpers)
+ set @xmas_reward_tally, (@xmas_reward_tally + $@xmas_reward_all_helpers);
+ if(@xmas_all_lists)
+ set @xmas_reward_tally, (@xmas_reward_tally + $@xmas_reward_all_lists);
+ //formula should:
+ if (@xmas_reward_tally > 5)
+ set @xmas_reward_lower_bound, 2 * @xmas_reward_tally - rand(5);
+ if (@xmas_reward_tally <= 5)
+ set @xmas_reward_lower_bound, @xmas_reward_tally;
+ set @xmas_reward_upper_bound, @xmas_reward_lower_bound + ((readparam(bLuk)) / 5);
+ set @xmas_reward, (rand(@xmas_reward_lower_bound, @xmas_reward_upper_bound));
+ set @xmas_reward_lower_bound, 0;
+ set @xmas_reward_upper_bound, 0;
+ return;
+}
+
+// Main quest completion reward
+function|script|XmasMainXpBpReward|,
+{
+ callfunc "XmasSetReward";
+
+ if(BaseLevel >= 99)
+ goto L_EndGameReward;
+ goto L_LevelingReward;
+
+L_EndGameReward:
+ set @xmas_bp_reward, 100 + rand(@xmas_reward, 2 * @xmas_reward);
+ set BOSS_POINTS, BOSS_POINTS + @xmas_bp_reward;
+ message strcharinfo(0), "You gain " + @xmas_bp_reward + " Bosspoints, giving you a total of " + BOSS_POINTS + ".";
+ set @xmas_bp_reward, 0;
+ return;
+
+L_LevelingReward:
+ if(@xmas_reward >= $@xmas_reward_tally_rare)
+ goto L_XmasLevel;
+ goto L_XmasExp;
+
+L_XmasLevel:
+ gmcommand "@blvl 1";
+ return;
+
+L_XmasExp:
+ getexp ((@xmas_reward * BaseLevel * (BaseLevel + 10)) / 10), 0;
+ return;
+}
+
+// Final Item reward
+function|script|XmasMainItemReward|,
+{
+ callfunc "XmasSetReward";
+
+ if(($@xmas_time == $@xmas_reward_time) && ((@xmas_reward_start_state) || (@xmas_reward1_done_state)))
+ goto L_FinalGift;
+ goto L_Return;
+
+L_FinalGift:
+ mes "[To: " + strcharinfo(0) + "]";
+ mes "[From: " + $@xmas_present_from$[@xmas_reward_side] + "]";
+ mes "O look, a present from " + $@xmas_present_from$[@xmas_reward_side];
+ next;
+ getinventorylist;
+ if (@inventorylist_count > 97)
+ goto L_FullInv;
+ set @xmas_reward, (@xmas_reward + ((BaseLevel + 10)/10));
+ if (debug > 0)
+ message strcharinfo(0), "Reward variable: " + @xmas_reward;
+ set @xmas_uncommon_slot1, rand(getarraysize($@xmas_uncommon_reward$));
+ set @xmas_uncommon_slot2, rand(getarraysize($@xmas_uncommon_reward$));
+ if(@xmas_reward >= $@xmas_reward_tally_rare)
+ set @xmas_reward_item$, $@xmas_rare_reward$[@xmas_reward_side];
+ if(@xmas_reward >= $@xmas_reward_tally_common)
+ set @xmas_reward_item1$, $@xmas_uncommon_reward$[@xmas_uncommon_slot1];
+ set @xmas_reward_item2$, $@xmas_uncommon_reward$[@xmas_uncommon_slot2];
+ if(checkweight("Iten", 1) == 0)
+ goto L_FullInv;
+ if(@xmas_reward >= 80)
+ getitem @xmas_reward_item$, 1;
+ if(@xmas_reward >= 40)
+ getitem @xmas_reward_item1$, 1;
+ getitem @xmas_reward_item2$, 1;
+ set @xmas_uncommon_slot1, 0;
+ set @xmas_uncommon_slot2, 0;
+ set @xmas_reward_item$, "";
+ set @xmas_reward_item1$, "";
+ set @xmas_reward_item2$, "";
+ if (@xmas_reward_start_state)
+ set @xmas_state, $@xmas_reward2_done;
+ if (@xmas_reward1_done_state)
+ set @xmas_state, $@xmas_reward_done;
+ callfunc "XmasSetState";
+ goto L_Return;
+
+L_FullInv:
+ mes "\"You have no place to put the present.\"";
+ goto L_Return;
+
+L_Return:
+ return;
+}
+
+// Checks for an expired event key
+// Each new annual event needs a new key
+// or it will allow completion from last year
+function|script|XmasCheckOld|,
+{
+ if(XMASYEAR == $XMAS_TIME_KEY[5])
+ goto L_Return;
+
+L_OldMatch:
+ set XMASTIME, 0;
+ set XMASYEAR, $XMAS_TIME_KEY[5];
+ goto L_Return;
+
+L_Return:
+ return;
+}
diff --git a/world/map/npc/annuals/xmas/debug.txt b/world/map/npc/annuals/xmas/debug.txt
new file mode 100644
index 00000000..0153037b
--- /dev/null
+++ b/world/map/npc/annuals/xmas/debug.txt
@@ -0,0 +1,235 @@
+// This file is part of Christmas Event
+// author: Jenalya, Chayenne, cinderweb, wushin
+// please see #XmasConfig
+
+function|script|XmasDebug|,
+{
+ if(debug)
+ goto L_Debug;
+ goto L_Live;
+
+L_Live:
+ mes "What do you want to do?";
+ menu
+ "Debug Vars", L_DebugLive,
+ "Xmas Time Key Change.", L_XmasTimeKey,
+ "Do nothing.", L_Close;
+
+L_DebugLive:
+ mes "--Sever--";
+ mes "Event State: " + $@xmas_time;
+ mes "Event Start" + $XMAS_TIME_KEY[0] + "/1";
+ mes "Reward Start: " + $XMAS_TIME_KEY[1] + "/" + $XMAS_TIME_KEY[3];
+ mes "Event End: " + $XMAS_TIME_KEY[2] + "/" + $XMAS_TIME_KEY[4];
+ mes "Event Time Key (year (CCYY)): " + $XMAS_TIME_KEY[5];
+ goto L_Close;
+
+L_Debug:
+ mes "What do you want to do?";
+ menu
+ "Debug Vars", L_DebugVars,
+ "Set Quest State.", L_XmasState,
+ "Set Karma. [0-15] 15 Nice", L_XmasKarma,
+ "Set All Lists", L_SetAllLists,
+ "Set All Helpers", L_SetAllHelpers,
+ "Set Boss Hero", L_SetBossHero,
+ "Reset Quest State.", L_Reset,
+ "Set Old Event Flag.", L_LastReset,
+ "Xmas Time Key Change.", L_XmasTimeKey,
+ "Do nothing.", L_Close;
+
+L_DebugVars:
+ callfunc "XmasStates";
+ mes "--Sever--";
+ mes "Event State: " + $@xmas_time;
+ mes "Event Start" + $XMAS_TIME_KEY[0] + "/1";
+ mes "Reward Start: " + $XMAS_TIME_KEY[1] + "/" + $XMAS_TIME_KEY[3];
+ mes "Event End: " + $XMAS_TIME_KEY[2] + "/" + $XMAS_TIME_KEY[4];
+ mes "Event Time Key (year (CCYY)): " + $XMAS_TIME_KEY[5];
+ next;
+ mes "--Player--";
+ mes "Player Event Time Key " + XMASYEAR;
+ mes "xmas_state: " + @xmas_state;
+ mes "xmas_karma: " + @xmas_karma;
+ mes "xmas_side: " + @xmas_side;
+ next;
+ mes "xmas_list_gather: " + @xmas_list_gather;
+ mes "xmas_list_complete: " + @xmas_list_complete;
+ mes "xmas_list_deliver: " + @xmas_list_deliver;
+ mes "xmas_helper_start_state: " + @xmas_helper_start_state;
+ mes "xmas_helper_done_state: " + @xmas_helper_done_state;
+ mes "xmas_reagent_start_state: " + @xmas_reagent_start_state;
+ mes "xmas_reagent_done_state: " + @xmas_reagent_done_state;
+ mes "xmas_boss_door_state: " + @xmas_boss_door_state;
+ mes "xmas_reward_start_state " + @xmas_reward_start_state;
+ mes "xmas_reward1_done_state " + @xmas_reward1_done_state;
+ mes "xmas_reward2_done_state " + @xmas_reward2_done_state;
+ mes "xmas_reward_done_state: " + @xmas_reward_done_state;
+ next;
+ mes "xmas_basement_passage: " + @xmas_basement_passage;
+ mes "xmas_thrown_out: " + @xmas_thrown_out;
+ mes "xmas_hard_mode: " + @xmas_boss_hero;
+ next;
+ mes "xmas_sweater: " + @xmas_sh_done;
+ next;
+ mes "xmas_all_lists: " + @xmas_all_lists;
+ next;
+ mes "xmas_helper_bit: " + @xmas_helper_bit;
+ mes "xmas_all_helpers: " + @xmas_all_helpers;
+ mes "xmas_helper_acorn: " + @xmas_helper_acorn;
+ mes "xmas_helper_bedding: " + @xmas_helper_bedding;
+ mes "xmas_helper_glitter: " + @xmas_helper_glitter;
+ mes "xmas_helper_storage: " + @xmas_helper_storage;
+ mes "xmas_knows_route: " + @xmas_knows_route;
+ goto L_Close;
+
+L_LastReset:
+ set XMASTIME, 255;
+ set XMASYEAR, 2012;
+ goto L_Close;
+
+L_Reset:
+ set XMASTIME, 0;
+ set XMASYEAR, $XMAS_TIME_KEY[5];
+ goto L_Close;
+
+L_XmasTimeKey:
+ if (getgmlevel() < 20) goto L_Close;
+ mes "Xmas Time Key Change.";
+ mes "Start Month?";
+ input @xmas_time_key_smonth;
+ if((@xmas_time_key_smonth == 0) || (@xmas_time_key_smonth > 12))
+ goto L_XmasError;
+ mes "Reward Start Month?";
+ input @xmas_time_key_srmonth;
+ if((@xmas_time_key_srmonth == 0) || (@xmas_time_key_srmonth > 12))
+ goto L_XmasError;
+ mes "End Month?";
+ input @xmas_time_key_emonth;
+ if((@xmas_time_key_emonth == 0) || (@xmas_time_key_emonth > 12))
+ goto L_XmasError;
+ mes "Reward Start Day?";
+ input @xmas_time_key_rsday;
+ if((@xmas_time_key_rsday == 0) || (@xmas_time_key_rsday > 31))
+ goto L_XmasError;
+ mes "Reward End Day?";
+ input @xmas_time_key_reday;
+ if((@xmas_time_key_reday == 0) || (@xmas_time_key_reday > 31))
+ goto L_XmasError;
+ mes "Time Key (CCYY) ";
+ input @xmas_time_key_year;
+ goto L_SetNewKey;
+
+L_XmasError:
+ mes "Incorrect Entry. Try again.";
+ goto L_Close;
+
+L_SetNewKey:
+ setarray $XMAS_TIME_KEY, @xmas_time_key_smonth, @xmas_time_key_srmonth, @xmas_time_key_emonth, @xmas_time_key_rsday, @xmas_time_key_reday, @xmas_time_key_year;
+ cmdothernpc "#XmasConfig", "RestartQuest";
+ goto L_Close;
+
+L_XmasState:
+ mes "Quest state?";
+ input @xmas_state;
+ callfunc "XmasSetState";
+ goto L_Close;
+
+L_XmasKarma:
+ mes "Karma (0-15) 0: Naughty, 15: Good";
+ input @xmas_karma;
+ set XMASTIME, (XMASTIME & ~(NIBBLE_1_MASK) | (@xmas_karma << NIBBLE_1_SHIFT));
+ goto L_Close;
+
+L_SetAllLists:
+ set XMASTIME, XMASTIME | $@xmas_all_lists_bit;
+ goto L_Close;
+
+L_SetAllHelpers:
+ set XMASTIME, XMASTIME | $@xmas_all_helpers_bit;
+ goto L_Close;
+
+L_SetBossHero:
+ set XMASTIME, XMASTIME | $@xmas_boss_hero_bit;
+ goto L_Close;
+
+L_Close:
+ set @xmas_state, 0;
+ set @xmas_karma, 0;
+ set @xmas_hard_mode, 0;
+ set @xmas_time_key_smonth, 0;
+ set @xmas_time_key_emonth, 0;
+ set @xmas_time_key_rsday, 0;
+ set @xmas_time_key_reday, 0;
+ set @xmas_time_key_year, 0;
+ close;
+}
+
+030-1.gat,91,48,0|script|XmasDebug#1|105,
+{
+ callfunc "XmasDebug";
+ goto L_end;
+
+OnInit:
+ if(!(debug))
+ disablenpc "XmasDebug#1";
+L_end:
+ end;
+}
+
+030-2.gat,193,62,0|script|XmasDebug#2|105,
+{
+ callfunc "XmasDebug";
+ goto L_end;
+
+OnInit:
+ if(!(debug))
+ disablenpc "XmasDebug#2";
+L_end:
+ end;
+}
+
+030-3.gat,26,26,0|script|XmasDebug#3|105,
+{
+ callfunc "XmasDebug";
+ goto L_end;
+
+OnInit:
+ if(!(debug))
+ disablenpc "XmasDebug#3";
+L_end:
+ end;
+}
+
+030-4.gat,30,30,0|script|XmasDebug#4|111,
+{
+ callfunc "XmasDebug";
+ goto L_end;
+
+OnInit:
+ if(!(debug))
+ disablenpc "XmasDebug#4";
+L_end:
+ end;
+}
+
+
+botcheck.gat,26,28,0|script|XmasDebug#5|105,
+{
+ if(getgmlevel() < 40)
+ goto L_End;
+
+ callfunc "XmasDebug";
+
+L_End:
+ end;
+}
+
+020-1.gat,86,76,0|script|XmasDebug#6|105,
+{
+ callfunc "XmasDebug";
+
+OnInit:
+ if(!(debug))
+ disablenpc "XmasDebug#6";
+}
diff --git a/world/map/npc/annuals/xmas/helpers.txt b/world/map/npc/annuals/xmas/helpers.txt
new file mode 100644
index 00000000..57e535b5
--- /dev/null
+++ b/world/map/npc/annuals/xmas/helpers.txt
@@ -0,0 +1,48 @@
+// This file is part of Christmas Event
+// author: Jenalya, Chayenne, cinderweb, wushin
+// please see #XmasConfig
+// TODO: Make Helpers static functions
+
+function|script|XmasHelperPoints|,
+{
+ set @xmas_helper_count, 0;
+ set @xmas_helper_loop, 0;
+ if((@xmas_helper_done_state) || !(@xmas_helper_start_state))
+ goto L_Return;
+
+L_Loop:
+ if(XMASTIME & $@xmas_helper_list[@xmas_helper_loop])
+ goto L_AddOne;
+ goto L_LoopAgain;
+
+L_AddOne:
+ set @xmas_helper_count, (@xmas_helper_count + 1);
+ goto L_LoopAgain;
+
+L_LoopAgain:
+ if((@xmas_helper_loop + 1) == getarraysize($@xmas_helper_list))
+ goto L_HelperTally;
+ set @xmas_helper_loop, (@xmas_helper_loop + 1);
+ goto L_Loop;
+
+L_HelperTally:
+ if(@xmas_helper_count == $@xmas_perfect_helpers_count)
+ goto L_PerfectHelpers;
+ if(@xmas_helper_count > $@xmas_required_helpers_count)
+ goto L_SetHelperState;
+ goto L_Return;
+
+L_PerfectHelpers:
+ set XMASTIME, XMASTIME | $@xmas_all_helpers_bit;
+ goto L_SetHelperState;
+
+L_SetHelperState:
+ set @xmas_state, $@xmas_helpers_done_state;
+ callfunc "XmasSetState";
+ goto L_Return;
+
+L_Return:
+ set @xmas_helper_count, 0;
+ set @xmas_helper_loop, 0;
+ return;
+}
diff --git a/world/map/npc/annuals/xmas/list.txt b/world/map/npc/annuals/xmas/list.txt
new file mode 100644
index 00000000..a03db395
--- /dev/null
+++ b/world/map/npc/annuals/xmas/list.txt
@@ -0,0 +1,102 @@
+// This file is part of Christmas Event
+// author: Jenalya, Chayenne, cinderweb, wushin
+// please see #XmasConfig
+
+function|script|XmasCheckList|,
+{
+ set @xmas_list_count, 0;
+ set @xmas_list_loop, 0;
+
+ if((@xmas_list_deliver) || !(@xmas_list_gather))
+ goto L_Return;
+
+L_Loop:
+ if(XMASTIME & $@xmas_child_list[@xmas_list_loop])
+ goto L_AddOne;
+ goto L_LoopAgain;
+
+L_AddOne:
+ set @xmas_list_count, (@xmas_list_count + 1);
+ goto L_LoopAgain;
+
+L_LoopAgain:
+ if((@xmas_list_loop + 1) == getarraysize($@xmas_child_list))
+ goto L_ListTally;
+ set @xmas_list_loop, (@xmas_list_loop + 1);
+ goto L_Loop;
+
+L_ListTally:
+ if(@xmas_list_count == $@xmas_perfect_list_count)
+ goto L_PerfectList;
+ if(@xmas_list_count > $@xmas_required_list_count)
+ goto L_SetListState;
+ goto L_Return;
+
+L_PerfectList:
+ set XMASTIME, XMASTIME | $@xmas_all_lists_bit;
+ goto L_SetListState;
+
+L_SetListState:
+ set @xmas_state, $@xmas_list_complete_state;
+ callfunc "XmasSetState";
+ goto L_Return;
+
+L_Return:
+ set @xmas_list_loop, 0;
+ return;
+}
+
+function|script|XmasList|,
+{
+ callfunc "XmasStates";
+
+ if(($@xmas_time) && (@xmas_list_gather) && !(@xmas_list_complete))
+ goto L_QuestTime;
+ goto L_Return;
+
+L_QuestTime:
+ if(XMASTIME & $@xmas_child_list[$@child_number])
+ goto L_Return;
+ goto L_GetList;
+
+L_GetList:
+ menu
+ "Hey, I have come to collect your wish list for Santa", L_List,
+ "Oh sorry, what were you going to say?", L_Return;
+
+L_List:
+ mes "[" + $@xmas_child_list_name$[$@child_number] + "]";
+ mes "Here is my list. Make sure it gets delivered, please!";
+ next;
+ mes "You store " + $@xmas_child_list_name$[$@child_number] + "'s wish list carefully in a hidden pocket of your backpack.";
+ set XMASTIME, XMASTIME | $@xmas_child_list[$@child_number];
+ callfunc "XmasXpReward";
+ menu
+ "I really should be going.", L_Return;
+
+L_Return:
+ return;
+}
+
+function|script|XmasListList|,
+{
+ set @xmas_list_loop, 0;
+ set @xmas_child_loop, 0;
+
+L_Loop:
+ set @xmas_child_loop, ($@xmas_child_list[@xmas_list_loop]);
+ if ((XMASTIME & @xmas_child_loop) != 0) goto L_LoopAgain;
+ mes "\"" + $@xmas_child_list_name$[@xmas_list_loop] + "\"";
+ next;
+ goto L_LoopAgain;
+
+L_LoopAgain:
+ if((@xmas_list_loop + 1) == getarraysize($@xmas_child_list_name$))
+ goto L_Return;
+ set @xmas_list_loop, (@xmas_list_loop + 1);
+ goto L_Loop;
+
+L_Return:
+ set @xmas_list_loop, 0;
+ return;
+}
diff --git a/world/map/npc/annuals/xmas/mobmanager.txt b/world/map/npc/annuals/xmas/mobmanager.txt
new file mode 100644
index 00000000..2ffa5e15
--- /dev/null
+++ b/world/map/npc/annuals/xmas/mobmanager.txt
@@ -0,0 +1,99 @@
+// Spawns mobs
+
+019-1.gat,0,0,0|script|XmasSpawnManager|400,
+{
+
+OnCommandSpawnStart:
+ goto L_InitSpawn;
+
+L_InitSpawn:
+ initnpctimer;
+ set $@xmas_current_count, 0;
+ set $@xmas_map_loop, 0;
+ goto L_StartLoop;
+
+L_StartLoop:
+ set $@xmas_mob_lck, 1;
+ set $@mob_count, mobcount($@xmas_map_spawns$[$@xmas_map_loop], "XmasSpawnCounter#" + $@xmas_map_loop + "::OnTally");
+ set $@spawn_amount, ($@xmas_mob_counts[$@xmas_map_loop] - ($@mob_count + 1));
+ if ($@spawn_amount)
+ goto L_Spawn;
+ goto L_NextMap;
+
+L_Spawn:
+ areamonster $@xmas_map_spawns$[$@xmas_map_loop], $@xmas_spawn_x1, $@xmas_spawn_y1, $@xmas_spawn_x2, $@xmas_spawn_y2, $@xmas_mob_names$[$@xmas_map_loop], $@xmas_mob_spawns[$@xmas_map_loop], $@spawn_amount, "XmasSpawnCounter#" + $@xmas_map_loop + "::OnTally";
+ set $@xmas_current_count, ($@xmas_current_count + $@spawn_amount);
+ goto L_NextMap;
+
+L_NextMap:
+ if (($@xmas_map_loop + 1) == getarraysize($@xmas_map_spawns$))
+ goto L_End;
+ set $@xmas_map_loop, ($@xmas_map_loop + 1);
+ goto L_StartLoop;
+
+L_DespawnLoop:
+ killmonster $@xmas_map_spawns$[$@xmas_map_loop], "XmasSpawnCounter#" + $@xmas_map_loop + "::OnTally";
+ goto L_NextDespawn;
+
+L_NextDespawn:
+ if (($@xmas_map_loop + 1) == getarraysize($@xmas_map_spawns$))
+ goto L_SelfDestruct;
+ set $@xmas_map_loop, ($@xmas_map_loop + 1);
+ goto L_DespawnLoop;
+
+L_StopTracking:
+ set $@xmas_mob_lck, 1;
+ set $@xmas_map_loop, 0;
+ goto L_DespawnLoop;
+
+L_SelfDestruct:
+ stopnpctimer;
+ disablenpc "XmasSpawnManager";
+ goto L_End;
+
+OnCommandTally:
+ set $@xmas_map_loop, 0;
+ set $@xmas_current_count, ($@xmas_current_count - 1);
+ if (($@xmas_current_count < $@xmas_respawn_count) && !($@xmas_mob_lck))
+ goto L_StartLoop;
+ goto L_End;
+
+OnTimer110000:
+ initnpctimer;
+ goto L_StartLoop;
+
+L_End:
+ set $@mob_count, 0;
+ set $@spawn_amount, 0;
+ set $@xmas_mob_lck, 0;
+ set $@xmas_map_loop, 0;
+ end;
+}
+
+019-1.gat,0,0,0|script|XmasSpawnCounter#0|400,
+{
+OnTally:
+ cmdothernpc "XmasSpawnManager", "Tally";
+ end;
+}
+
+019-3.gat,0,0,0|script|XmasSpawnCounter#1|400,
+{
+OnTally:
+ cmdothernpc "XmasSpawnManager", "Tally";
+ end;
+}
+
+030-1.gat,0,0,0|script|XmasSpawnCounter#2|400,
+{
+OnTally:
+ cmdothernpc "XmasSpawnManager", "Tally";
+ end;
+}
+
+030-3.gat,0,0,0|script|XmasSpawnCounter#3|400,
+{
+OnTally:
+ cmdothernpc "XmasSpawnManager", "Tally";
+ end;
+}
diff --git a/world/map/npc/annuals/xmas/reagents.txt b/world/map/npc/annuals/xmas/reagents.txt
new file mode 100644
index 00000000..a1dd8d6f
--- /dev/null
+++ b/world/map/npc/annuals/xmas/reagents.txt
@@ -0,0 +1,142 @@
+// This file is part of Christmas Event
+// author: Jenalya, Chayenne, cinderweb, wushin
+// please see #XmasConfig
+
+function|script|CheckReagents|,
+{
+ set @xmas_reagent_loop, 0;
+ if((@xmas_reagent_done_state) || !(@xmas_reagent_start_state))
+ goto L_Return;
+ if(@xmas_side)
+ goto L_OneLoop;
+ goto L_ZeroLoop;
+
+L_ZeroLoop:
+ if(countitem($@xmas_zero_reagents$[@xmas_reagent_loop]) >= $@xmas_zero_reagents_amounts[@xmas_reagent_loop])
+ goto L_ZeroLoopAgain;
+ goto L_Return;
+
+L_ZeroLoopAgain:
+ if((@xmas_reagent_loop + 1) == getarraysize($@xmas_zero_reagents$))
+ goto L_AllReagents;
+ set @xmas_reagent_loop, (@xmas_reagent_loop + 1);
+ goto L_ZeroLoop;
+
+L_OneLoop:
+ if(countitem($@xmas_one_reagents$[@xmas_reagent_loop]) >= $@xmas_one_reagents_amounts[@xmas_reagent_loop])
+ goto L_OneLoopAgain;
+ goto L_Return;
+
+L_OneLoopAgain:
+ if((@xmas_reagent_loop + 1) == getarraysize($@xmas_one_reagents$))
+ goto L_AllReagents;
+ set @xmas_reagent_loop, (@xmas_reagent_loop + 1);
+ goto L_OneLoop;
+
+L_AllReagents:
+ set @xmas_state, $@xmas_reagents_done;
+ callfunc "XmasSetState";
+ goto L_Return;
+
+L_Return:
+ return;
+}
+
+function|script|DeleteReagents|,
+{
+ set @xmas_reagent_loop, 0;
+ if(@xmas_side)
+ goto L_OneLoop;
+ goto L_ZeroLoop;
+
+L_ZeroLoop:
+ delitem $@xmas_zero_reagents$[@xmas_reagent_loop], $@xmas_zero_reagents_amounts[@xmas_reagent_loop];
+
+L_ZeroLoopAgain:
+ if((@xmas_reagent_loop + 1) == getarraysize($@xmas_zero_reagents$))
+ goto L_Return;
+ set @xmas_reagent_loop, (@xmas_reagent_loop + 1);
+ goto L_ZeroLoop;
+
+L_OneLoop:
+ delitem $@xmas_one_reagents$[@xmas_reagent_loop], $@xmas_one_reagents_amounts[@xmas_reagent_loop];
+
+L_OneLoopAgain:
+ if((@xmas_reagent_loop + 1) == getarraysize($@xmas_one_reagents$))
+ goto L_Return;
+ set @xmas_reagent_loop, (@xmas_reagent_loop + 1);
+ goto L_OneLoop;
+
+L_Return:
+ return;
+}
+
+function|script|ListReagents|,
+{
+ set @xmas_reagent_loop, 0;
+ mes "\"I'm going to need \"";
+ next;
+
+ if(@xmas_side)
+ goto L_OneLoop;
+ goto L_ZeroLoop;
+
+L_ZeroLoop:
+ mes "\"" + $@xmas_zero_reagents_amounts[@xmas_reagent_loop] + " " + $@xmas_zero_reagents_names$[@xmas_reagent_loop] + "\"";
+ next;
+
+L_ZeroLoopAgain:
+ if((@xmas_reagent_loop + 1) == getarraysize($@xmas_zero_reagents$))
+ goto L_AllReagents;
+ set @xmas_reagent_loop, (@xmas_reagent_loop + 1);
+ goto L_ZeroLoop;
+
+L_OneLoop:
+ mes "\"" + $@xmas_one_reagents_amounts[@xmas_reagent_loop] + " " + $@xmas_one_reagents_names$[@xmas_reagent_loop] + "\"";
+ next;
+
+L_OneLoopAgain:
+ if((@xmas_reagent_loop + 1) == getarraysize($@xmas_one_reagents$))
+ goto L_AllReagents;
+ set @xmas_reagent_loop, (@xmas_reagent_loop + 1);
+ goto L_OneLoop;
+
+L_AllReagents:
+ return;
+}
+
+function|script|BadPowderMake|,
+{
+ if(countitem("PileOfAsh") < ($@xmas_red_amount + $@xmas_yellow_amount))
+ goto L_NotEnough;
+ if(countitem("RedDye") < $@xmas_red_amount)
+ goto L_NotEnough;
+ if(countitem("YellowDye") < $@xmas_yellow_amount)
+ goto L_NotEnough;
+ getinventorylist;
+ if (@inventorylist_count > 100)
+ goto L_FullInv;
+ goto L_MakePowder;
+
+L_MakePowder:
+ delitem "PileOfAsh", ($@xmas_red_amount + $@xmas_yellow_amount);
+ delitem "RedDye", $@xmas_red_amount;
+ delitem "YellowDye", $@xmas_yellow_amount;
+ getitem "RedPowder", $@xmas_red_amount;
+ getitem "YellowPowder", $@xmas_yellow_amount;
+ mes "\"Here is your powder, now move!\"";
+ goto L_Return;
+
+L_FullInv:
+ mes "\"... Excuse me but where did you expect you were going to hold these powders...\"";
+ mes "\"WAIT! no, I don't want to know. Just come back when you have some room.\"";
+ goto L_Return;
+
+L_NotEnough:
+ mes "\"You don't have enough of eagents to make the powders.\"";
+ mes "\"To replace the glitter we will need get " + ($@xmas_red_amount + $@xmas_yellow_amount) + " Piles of Ash, " + $@xmas_red_amount + " Red Dyes and " + $@xmas_yellow_amount + " Yellow Dyes\"";
+ goto L_Return;
+
+L_Return:
+ return;
+}
diff --git a/world/map/npc/annuals/xmas/states.txt b/world/map/npc/annuals/xmas/states.txt
new file mode 100644
index 00000000..8d81864f
--- /dev/null
+++ b/world/map/npc/annuals/xmas/states.txt
@@ -0,0 +1,55 @@
+// This file is part of Christmas Event
+// author: Jenalya, Chayenne, cinderweb, wushin
+// please see #XmasConfig
+
+function|script|XmasStates|,
+{
+ // Check for Old Quest Line Keys. Reset Quest if so.
+ callfunc "XmasCheckOld";
+ // Main Quest
+ set @xmas_state, ((XMASTIME & NIBBLE_0_MASK) >> NIBBLE_0_SHIFT);
+ set @xmas_karma, ((XMASTIME & NIBBLE_1_MASK) >> NIBBLE_1_SHIFT);
+ set @xmas_side, XMASTIME & $@xmas_side_bit;
+
+ set @xmas_list_gather, (@xmas_state >= $@xmas_list_path2_state);
+ set @xmas_list_path2, (@xmas_state == $@xmas_list_path2_state);
+ set @xmas_list_path1, (@xmas_state == $@xmas_list_path1_state);
+ set @xmas_list_both, (@xmas_state == $@xmas_list_both_state);
+ set @xmas_list_complete, (@xmas_state >= $@xmas_list_complete_state);
+ set @xmas_list_deliver, (@xmas_state >= $@xmas_list_deliver_state);
+ set @xmas_helper_start_state, (@xmas_state >= $@xmas_helpers_start_state);
+ set @xmas_helper_done_state, (@xmas_state >= $@xmas_helpers_done_state);
+ set @xmas_reagent_start_state, (@xmas_state >= $@xmas_reagents_start);
+ set @xmas_reagent_done_state, (@xmas_state >= $@xmas_reagents_done);
+ set @xmas_boss_door_state, (@xmas_state >= $@xmas_boss_door_open_state);
+ set @xmas_reward_start_state, (@xmas_state == $@xmas_reward_start);
+ set @xmas_reward1_done_state, (@xmas_state == $@xmas_reward1_done);
+ set @xmas_reward2_done_state, (@xmas_state == $@xmas_reward2_done);
+ set @xmas_reward_done_state, (@xmas_state == $@xmas_reward_done);
+
+ // Basement Passage
+ set @xmas_basement_passage, XMASTIME & $@xmas_basement_passage;
+ // Thrown Out
+ set @xmas_thrown_out, XMASTIME & $@xmas_thrown_out_bit;
+ // Learned Route to Orum
+ set @xmas_knows_route, XMASTIME & $@xmas_route_bit;
+ // Santas Helper
+ set @xmas_sh_done, XMASTIME & $@xmas_sh_bit;
+ // List Quest
+ set @xmas_all_lists, XMASTIME & $@xmas_all_lists_bit;
+ // Helper Quest
+ set @xmas_helper_bit, XMASTIME & $@xmas_helper_bit;
+ set @xmas_all_helpers, XMASTIME & $@xmas_all_helpers_bit;
+ // Acorns
+ set @xmas_helper_acorn, XMASTIME & $@xmas_helper_bit_acorns;
+ // Bedding
+ set @xmas_helper_bedding, XMASTIME & $@xmas_helper_bit_bed_starts;
+ // Glitter
+ set @xmas_helper_glitter, XMASTIME & $@xmas_helper_bit_glitter_starts;
+ // Storage
+ set @xmas_helper_storage, XMASTIME & $@xmas_helper_bit_storage;
+ // Bosses
+ set @xmas_boss_start, XMASTIME & $@xmas_boss_start_bit;
+ set @xmas_boss_hero, XMASTIME & $@xmas_boss_hero_bit;
+ return;
+}
diff --git a/world/map/npc/annuals/xmas/tree_beard.txt b/world/map/npc/annuals/xmas/tree_beard.txt
new file mode 100644
index 00000000..474f3c63
--- /dev/null
+++ b/world/map/npc/annuals/xmas/tree_beard.txt
@@ -0,0 +1,107 @@
+// Annual Xmas Environment changes
+020-1.gat,90,78,0|script|#Tree|380,
+{
+ end;
+}
+
+020-1.gat,90,78,0|script|#XmasTree|379,
+{
+ end;
+}
+
+020-1.gat,90,79,0|script|Present#1|386,
+{
+ callfunc "XmasStates";
+ callfunc "XmasMainItemReward";
+ close;
+}
+
+009-1.gat,54,38,0|script|#TreeNoSnow|382,
+{
+ end;
+}
+
+009-1.gat,54,38,0|script|#XmasTreeNoSnow|381,
+{
+ end;
+}
+
+009-1.gat,54,39,0|script|Present#2|386,
+{
+ callfunc "XmasStates";
+ callfunc "XmasMainItemReward";
+ close;
+}
+
+001-1.gat,41,45,0|script|#PalmTree|384,
+{
+ end;
+}
+
+001-1.gat,41,46,0|script|Present#3|386,
+{
+ callfunc "XmasStates";
+ callfunc "XmasMainItemReward";
+ close;
+}
+
+001-1.gat,41,45,0|script|#XmasPalmTree|383,
+{
+ end;
+}
+
+function|script|SpawnMobs|,
+{
+ cmdothernpc "XmasSpawnManager", "SpawnStart";
+ return;
+}
+
+function|script|PresentHandler|,
+{
+ if($@xmas_time == $@xmas_reward_time)
+ goto L_DeliverPresents;
+ goto L_DisablePresents;
+
+L_DeliverPresents:
+ enablenpc "Present#1";
+ enablenpc "Present#2";
+ enablenpc "Present#3";
+ goto L_Return;
+
+L_DisablePresents:
+ disablenpc "Present#1";
+ disablenpc "Present#2";
+ disablenpc "Present#3";
+ goto L_Return;
+
+L_Return:
+ return;
+}
+
+function|script|ReplaceTrees|,
+{
+ if($@xmas_time)
+ goto L_XmasTree;
+ goto L_Tree;
+
+L_XmasTree:
+ disablenpc "#Tree";
+ enablenpc "#XmasTree";
+ disablenpc "#TreeNoSnow";
+ enablenpc "#XmasTreeNoSnow";
+ disablenpc "#PalmTree";
+ enablenpc "#XmasPalmTree";
+ goto L_Return;
+
+L_Tree:
+ disablenpc "#XmasTree";
+ enablenpc "#Tree";
+ disablenpc "#XmasTreeNoSnow";
+ enablenpc "#TreeNoSnow";
+ disablenpc "#XmasPalmTree";
+ enablenpc "#PalmTree";
+ goto L_Return;
+
+L_Return:
+ return;
+}