# dHunger system # Arena admins require op or dhunger.command permission # Arenas are stored in dHungers_saves.yml and it is editable and reloadable. # Created by Talamar1 dHunger: type: world debug: false events: on server start: - run dhunger_task_init delay:1t on shutdown: - run dhunger_task_init delay:1t on player clicks wall_sign: - define sign - wait 1t - foreach { - if && && >= { - if determine cancelled - flag dhg.play:%value% - inject dhunger_command_join - foreach stop } } on player joins: - if { - flag dhg:! } - if ]> { - inject dhunger_task_cleanup_player } - teleport > on player quits: - if { - define arena - inject dhunger_remove_player - run dhunger_check_end_of_game def:%arena% instantly - flag dhg:! } on player killed: - if { - define arena - narrate " was killed by ]:||> in arena %arena%" targets: - inject dhunger_remove_player - run dhunger_check_end_of_game def:%arena% instantly - determine cancelled } on player breaks block in notable cuboid: - foreach { - if && { - if !]> { - determine cancelled - foreach stop } else { - run dhunger_task_block_track def:break|%value%|| - foreach stop } } } on player places block in notable cuboid: - foreach { - if && { - if !]> { - determine cancelled - foreach stop } else { - run dhunger_task_block_track def:place|%value%|| - foreach stop } } } on block ignites: - inject dhunger_task_block_change_check on block burns: - inject dhunger_task_block_change_check on block forms: - inject dhunger_task_block_change_check on block fades: - inject dhunger_task_block_change_check on block builds: - inject dhunger_task_block_change_check on entity spawns: - if ! queue clear - foreach { - if { - if { - if !contains { - determine cancelled } } } } dhunger_task_init: type: task debug: false script: - ^flag server dhg:! - inject dhunger_command_reload - ^foreach { - if { - define area - if == null { - note %area% as:dhg_%value% } } - run dhunger_check_end_of_game def:%value% } dhunger_dhg: type: command debug: false name: dhg description: dHunger Command usage: /dhg <<>arg1<&pipe>arg2...<>> aliases: - dhunger script: - if == 0 { - inject dhunger_command_help - queue clear } - define arg1 - define cmdList li@create|save|delete|spawn|rename|set|breakable|placeable|lock|unlock|resize|board|disable|enable|start|stop|quit|select|list|clear|reload|lobby|vote|tier1|tier2|scan_chests|reset_default|join|spawnable - if { - if || { - if li@placeable|breakable contains %arg1% inject dhunger_command_blockmgmt else if li@tier1|tier2 contains %arg1% inject dhunger_command_tier else inject dhunger_command_%arg1% - queue clear } else { - narrate "<&6>You do not have permission to use the dhunger command." - queue clear } } - inject dhunger_command_help dhunger_command_help: type: task debug: false script: - if narrate "<&6>/dhg create <<>arena name<>>" - if narrate "<&6>/dhg save" - if narrate "<&6>/dhg delete <<>arena name<>>" - if narrate "<&6>/dhg spawn <&lb>add<&rb>/<&lb>del <<>id<>><&rb>/<&lb>list<&rb>/<&lb>show<&rb>" - if narrate "<&6>/dhg breakable <&lb>add<&rb>/<&lb>del<&rb>/<&lb>list<&rb>/<&lb>clear<&rb>" - if narrate "<&6>/dhg placeable <&lb>add<&rb>/<&lb>del<&rb>/<&lb>list<&rb>/<&lb>clear<&rb>" - if narrate "<&6>/dhg tier1 <&lb>add<&rb>/<&lb>del<&rb>/<&lb>list<&rb>/<&lb>clear<&rb>" - if narrate "<&6>/dhg tier2 <&lb>add<&rb>/<&lb>del<&rb>/<&lb>list<&rb>/<&lb>clear<&rb>" - if narrate "<&6>/dhg set <<>setting<>> <<>value<>>" - if narrate "<&6>/dhg board <&lb>add<&rb>/<&lb>del<&rb>" - if narrate "<&6>/dhg lock <<>arena name<>>" - if narrate "<&6>/dhg unlock <<>arena name<>>" - if narrate "<&6>/dhg disable <<>arena name<>>" - if narrate "<&6>/dhg enable <<>arena name<>>" - if narrate "<&6>/dhg start <<>arena name<>>" - if narrate "<&6>/dhg stop <<>arena name<>>" - if narrate "<&6>/dhg select <<>arena name<>>" - if narrate "<&6>/dhg resize" - if narrate "<&6>/dhg reload" - if narrate "<&6>/dhg clear" - if narrate "<&6>/dhg reset_default" - if narrate "<&6>/dhg join <&lb>Arena Name<&rb>" - if narrate "<&6>/dhg list" - if narrate "<&6>/dhg quit" dhunger_command_create: type: task debug: false script: - if { - narrate "<&6>/dhg create <<>arena name<>>" - narrate "<&6>arena name - name for your arena" - queue clear } - define arg2 - if %arg2% != { - narrate "<&6>That value doesn't look right." - queue clear } - if { - narrate "<&6>Arena with that name already exists." - queue clear } - if li@help|false|true|null contains %arg2% { - narrate "<&6>That is not a valid arena name." - queue clear } - if { - narrate "<&6>You don't have an area selected with WorldEdit wand." - queue clear } - narrate "Creating new arena" - run dhunger_task_yaml_copy def:dhg.arenas.default|dhg.arenas.%arg2% instantly - inject dhunger_command_save - note as:dhg_%arg2% - flag player dhg.edit:%arg2% - narrate "Arena created." dhunger_command_save: type: task debug: false script: # - ^if narrate "Saving Hunger Games" - ^yaml savefile:dhunger_saves.yml id:dhunger_saves dhunger_command_delete: type: task debug: false script: - define arena >> - if %arena% == help { - narrate "<&6>/dhg delete <<>Arena Name<>>" - narrate "<&6>Either select an arena or provide an arena name" - queue clear } - if %arena% != { - narrate "<&6>That value doesn't look right." - queue clear } - narrate "Deleting selected arena." - yaml id:dhunger_saves set dhg.arenas.%arena%:! - flag player dhg.edit:! - note remove as:dhg_%arena% - inject dhunger_command_save dhunger_command_reset_default: type: task debug: false script: - narrate "Setting up default arena values." - ^yaml id:dhunger_saves set dhg.arenas.default:! - ^yaml id:dhunger_saves set dhg.arenas.default.settings.max_players:20 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.min_players:2 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.lightning:2 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.lightning_delay:60 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.locked:false - ^yaml id:dhunger_saves set dhg.arenas.default.settings.enable:false - ^yaml id:dhunger_saves set dhg.arenas.default.settings.timer:30 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.countdown:10 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.restock:0 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.placeable:|:m@melon_block|m@tnt|m@cake - ^yaml id:dhunger_saves set dhg.arenas.default.settings.spawnable:|:e@bat|e@pig|e@squid|e@villager|e@rabbit|e@sheep|e@cow|e@horse|e@chicken|e@donkey|e@wolf|e@ocelot|e@mule - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@leather_chestplate:|:25|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@carrot:|:25|5 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@rabbit:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@stone_sword:|:20|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@fishing_rod:|:25|3 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@iron_ingot:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@feather:|:20|5 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@gold_sword:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@wood_sword:|:25|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@pork:|:25|3 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@stick:|:25|5 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@leather_helmet:|:25|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@raw_beef:|:20|4 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@leather_boots:|:25|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@string:|:25|5 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@arrow:|:25|5 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@flint:|:15|5 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@leather_leggings:|:25|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@cookie:|:5|2 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@raw_fish:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@gold_ingot:|:10|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@raw_chicken:|:20|4 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@potato:|:15|5 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@bow:|:25|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@apple:|:25|3 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@pumpkin_pie:|:5|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier1.i@baked_potato:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@cooked_chicken:|:20|2 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@cake:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@ender_pearl:|:20|2 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@cooked_rabbit:|:10|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@chainmail_chestplate:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@grilled_pork:|:20|3 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@gold_boots:|:20|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@melon_block:|:15|4 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@gold_leggings:|:20|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@iron_leggings:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@mushroom_soup:|:20|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@chainmail_helmet:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@iron_chestplate:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@nether_warts:|:5|5 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@iron_boots:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@diamond:|:5|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@chainmail_boots:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@flint_and_steel:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@golden_apple:|:10|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@golden_carrot:|:5|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@glass_bottle:|:10|5 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@iron_helmet:|:15|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@gold_helmet:|:20|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@gold_chestplate:|:20|1 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@cooked_beef:|:20|2 - ^yaml id:dhunger_saves set dhg.arenas.default.settings.tier2.i@chainmail_leggings:|:15|1 - narrate "Finished setting up Default File." - inject dhunger_command_save dhunger_command_reload: type: task debug: false script: - ^if yaml unload id:dhunger_saves - ^if { - announce "<&lb>dHunger<&rb> Loading Hunger Config File" - yaml load:dhunger_saves.yml id:dhunger_saves } else { - announce "<&lb>dHunger<&rb> Creating Hunger Config File" - yaml create id:dhunger_saves - yaml savefile:dhunger_saves.yml id:dhunger_saves - inject dhunger_command_reset_default } - flag server dhg.loaded dhunger_command_clear: type: task debug: false script: - yaml unload id:dhunger_saves - yaml create id:dhunger_saves - inject dhunger_command_save dhunger_command_select: type: task debug: false script: - if { - narrate "<&6>/dhg select <<>arena name<>>" - narrate "<&6>arena name - name for your arena" - queue clear } - if ]> { - narrate "<&6>That value doesn't look right." - queue clear } - define arg2 - if { - narrate "<&6>Selecting arena with name<&co> %arg2%" - flag player dhg.edit:%arg2% } else { - narrate "<&6>Arena with that name not found." } dhunger_command_resize: type: task debug: false script: - define arena >> - if %arena% == help { - narrate "<&6>/dhg resize <<>Arena Name<>>" - narrate "<&6>Either select an arena or provide an arena name" - queue clear } - if { - narrate "<&6>You don't have an area selected with WorldEdit wand." - queue clear } - narrate "Resizing arena %arena%" - yaml id:dhunger_saves set dhg.arenas..cuboid: - inject dhunger_command_save - note as:dhg_ - narrate "Arena resized." dhunger_command_quit: type: task debug: false script: - if ! { - narrate "You don't appear to be in a game." - queue clear } - define arena - narrate "Quitting arena game." - narrate " quit the arena." targets: - inject dhunger_remove_player - run dhunger_check_end_of_game def:%arena% dhunger_command_spawn: type: task debug: false script: - define arg2 - define arg3 - if %arg2% == help { - narrate "<&6>/dhg spawn add - add a new spawn" - narrate "<&6>/dhg spawn del <<>ID<>> - delete spawn at ID number (use list)" - narrate "<&6>/dhg spawn list - list all spawns" - narrate "<&6>/dhg spawn clear - clear all spawns" - narrate "<&6>/dhg spawn show - visually show spawns" - queue clear } - if ! { - narrate "You don't have an arena selected." - queue clear } - define arena - if li@add|del|list|show|clear contains %arg2% { - inject dhunger_spawn_%arg2% } else { - narrate "Invalid setting" } dhunger_spawn_add: type: task debug: false script: - if %arg3% == help { - narrate "<&6>/dhg spawn add" - narrate "<&6>Adds a spawnpoint to the selected arena." - queue clear } - narrate "Adding new spawnpoint." - define scount - define spawnpoint l@,,,,, - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint.:%spawnpoint% - inject dhunger_command_save dhunger_spawn_del: type: task debug: false script: - if %arg3% == help || %arg3% == 0 { - narrate "<&6>/dhg spawn del <<>spawnpoint<>>" - narrate "<&6>spawnpoint - ID Number for spawnpoint" - queue clear } - if { - narrate "Removing spawnpoint." - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint.%arg3%:! - foreach { - define spawnpoint - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint.%value%:! - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint.%loop_index%:%spawnpoint% } - inject dhunger_command_save } else { - narrate "Could not find that spawnpoint." } dhunger_spawn_list: type: task debug: false script: - narrate "Listing spawnpoints:" - foreach { - narrate "<<>%value%<>> " } dhunger_spawn_show: type: task debug: false script: - narrate "Showing spawnpoints:" - repeat 10 { - foreach { - playeffect effect:red_dust qty:15 } - wait 1s } dhunger_spawn_clear: type: task debug: false script: - yaml id:dhunger_saves set dhg.arenas.%arena%.spawnpoint:! - inject dhunger_command_save dhunger_command_tier: type: task debug: false script: - define arg2 - define arg3 - if ! { - narrate "You don't have an arena selected." - queue clear } - define arena - if %arg2% == help || ( li@add|del contains %arg2% && <= 0 ) || ( li@add|del|list|clear|help !contains %arg2% ) { - narrate "/dhg tier<&lb>1<&pipe>2<&rb> (add<&pipe>del) (item)(<&pc>percent)(<&ns>qty)" - narrate "<&sp><&sp><&sp>1 or 2 the tier you want to modify" - narrate "<&sp><&sp><&sp>add or del (optional<&cm> leaving it out overwites the whole list)" - narrate "<&sp><&sp><&sp>item the item to modify" - narrate "<&sp><&sp><&sp><&pc>value the chance item will be in chest (optional<&cm> default 25)" - narrate "<&sp><&sp><&sp><&ns>value the max quantity to be in a chest (optional<&cm> default 1)" - narrate "/dhg tier<&lb>1<&pipe>2<&rb> list" - narrate "/dhg tier<&lb>1<&pipe>2<&rb> clear" - queue clear } else if %arg2% == clear { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%:! - inject dhunger_command_save - queue clear } else if %arg2% == list { - narrate "%arg1% item list" - if ! queue clear - foreach { - define itemvals - narrate "<&sp><&sp><&sp><&sp><&pc><&sp>qty<&co>" } - queue clear } - foreach %arg3% { - define newitem - define percent - define qty - if { - narrate "%value% is %newitem% at %percent% qty %qty%" - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%.%newitem%:! - if %arg2% == add { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%.%newitem%:|:%percent%|%qty% } } else { - narrate "%newitem% is not a valid item" } } - inject dhunger_command_save dhunger_task_scan_chests: type: task debug: false script: - wait 1t - if && ! && { - narrate "<&6>/dhg locked <<>Arena ID<>>" - narrate "<&6>Either select an arena or provide an arena name" - queue clear } - if ! { - if { - define arena } else { - define arena } } - if %arena% != { - narrate "<&6>That value doesn't look right." - queue clear } - if && { - narrate "Processing chests in arena %arena" - define length ].abs> - define width ].abs> - define height ].abs> - define chunkie 100 - define chests li@ - repeat { - define x_tick - repeat { - define z_tick - repeat { - define y_tick - foreach li@x|y|z { - define %value%_min ]> - define %value%_max ]> - if > define %value%_max } - define subcuboid cu@%x_min%,%y_min%,%z_min%,|%x_max%,%y_max%,%z_max%, - define chests ]> - wait 1t } } } - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.tier1_chests:! - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.tier2_chests:! - foreach %chests% { - narrate "Chest %value% material " - if == chest { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.tier1_chests:->:%value% } else { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.tier2_chests:->:%value% } } - inject dhunger_command_save - narrate "found chests " } else { - narrate "<&6>Arena with that name not found." } - narrate "Chest processing for arena %arena% complete" dhunger_command_spawnable: type: task debug: false script: - define arg2 - define arg3 - if ! { - narrate "You don't have an arena selected." - queue clear } - define arena - if %arg2% == help || ( li@add|del contains %arg2% && <= 0 ) || ( li@add|del|list|clear|help !contains %arg2% ) { - narrate "/dhg spawnable (add<&pipe>del) (entity|entity)" - narrate "<&sp><&sp><&sp>entity the creature to allow spawning" - narrate "/dhg spawnable list" - narrate "/dhg spawnable clear" - queue clear } else if %arg2% == clear { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.spawnable:! - narrate "Spawnable list cleared for arena %arena%" - inject dhunger_command_save - queue clear } else if %arg2% == list { - narrate "Spawnable item list" - if queue clear - foreach { - narrate "<&sp><&sp><&sp>" } - queue clear } - foreach %arg3% { - define entity - if { - narrate "%value% is %entity%" - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.spawnable:<-:%entity% - if %arg2% == add { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.spawnable:->:%entity% } } else { - narrate "%entity% is not a valid item" } } - inject dhunger_command_save dhunger_command_blockmgmt: type: task debug: false script: - define arg2 - define arg3 - if %arg2% == help || ( li@add|del contains %arg2% && <= 0 ) { - narrate "<&6>/dhg %arg1% add - add block(s) to list" - narrate "<&6>/dhg %arg1% del - delete block(s) from list" - narrate "<&6>/dhg %arg1% list - list all blocks" - narrate "<&6>/dhg %arg1% clear - clear all blocks in list" - queue clear } - if ! { - narrate "You don't have an arena selected." - queue clear } - define arena - define settings li@add|del|list|clear - if inject dhunger_blockmgmt_%arg2% else narrate "Invalid %arg1% command" dhunger_blockmgmt_add: type: task debug: false script: - define arena > - define arg1 > - define arg3 > - if %arg3% == help { - narrate "<&6>/dhg %arg1% add <<>value<&pipe>value<&pipe>...<>>" - narrate "Where <&dq>value<&dq> is a <&pipe> separated list of block or material IDs." - queue clear } - foreach { - define newmat - if { - narrate "%value% is %newmat%" - if ! { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%:->:%newmat% - narrate "Added blocks to %arg1% list for %arena%" } else { - narrate "Item already in list" } } else { - narrate "%value% is not a valid block or item" } } - inject dhunger_command_save dhunger_blockmgmt_del: type: task debug: false script: - if %arg3% == help { - narrate "<&6>/dhg %arg1% del <<>value<&pipe>value<&pipe>...<>>" - narrate "Where <&dq>value<&dq> is a <&pipe> separated list of block or material IDs." - queue clear } - foreach { - define newmat - if { - narrate "%newmat% is valid" - if { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%:<-:%newmat% - narrate "Deleted blocks from %arg1% list for %arena%" } } else { - narrate "%value% is not a valid block or item" } } - inject dhunger_command_save dhunger_blockmgmt_list: type: task debug: false script: - if > 0 { - define blocklist - narrate "%blocklist%" } dhunger_blockmgmt_clear: type: task debug: false script: - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.%arg1%:! - narrate "Cleared blocks from %arg1% list for %arena%" - inject dhunger_command_save dhunger_command_rename: type: task debug: false script: - if || { - narrate "<&6>/dhg rename <<>arena name<>>" - narrate "<&6>arena name - name for your arena" - queue clear } - if ]> || ]> { - narrate "<&6>That value doesn't look right." - queue clear } - define arg2 - define arg3 - if li@help|false|true|null|%arg2% contains %arg3% { - narrate "<&6>That is not a valid arena name." - queue clear } - if { - narrate "<&6>Renaming arena with name<&co> %arg2% to<&co> %arg3%" - run dhunger_task_yaml_copy def:dhg.arenas.%arg2%|dhg.arenas.%arg3% instantly - run dhunger_command_delete def:%arg2% instantly - note as:dhg_%arg3% - inject dhunger_command_save } else { - narrate "<&6>Arena with that name not found." } dhunger_command_lock: type: task debug: false script: - if && ! { - narrate "<&6>/dhg locked <<>Arena ID<>>" - narrate "<&6>Either select an arena or provide an arena name" - queue clear } - if define arena else define arena - if %arena% != { - narrate "<&6>That value doesn't look right." - queue clear } - if { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.locked:true - narrate "<&6>Locking arena with name: %arena%" - inject dhunger_task_scan_chests - inject dhunger_command_save } else { - narrate "<&6>Arena with that name not found." } dhunger_command_unlock: type: task debug: false script: - if && ! { - narrate "<&6>/dhg locked <<>Arena ID<>>" - narrate "<&6>Either select an arena or provide an arena name" - queue clear } - if define arena else define arena - if %arena% != { - narrate "<&6>That value doesn't look right." - queue clear } - if { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.locked:false - narrate "<&6>Unlocking arena with name: %arena%" - inject dhunger_command_save } else { - narrate "<&6>Arena with that name not found." } dhunger_command_enable: type: task debug: false script: - if && ! { - narrate "<&6>/dhg enable <<>Arena ID<>>" - narrate "<&6>Either select an arena or provide an arena name" - queue clear } - if define arena else define arena - if %arena% != { - narrate "<&6>That value doesn't look right." - queue clear } - if { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.enable:true - narrate "<&6>Enabling arena with name: %arena%" - inject dhunger_command_save } else { - narrate "<&6>Arena with that name not found." } dhunger_command_disable: type: task debug: false script: - if && ! { - narrate "<&6>/dhg enable <<>Arena ID<>>" - narrate "<&6>Either select an arena or provide an arena name" - queue clear } - if define arena else define arena - if %arena% != { - narrate "<&6>That value doesn't look right." - queue clear } - if { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.enable:false - narrate "<&6>Disabling arena with name: %arena%" - inject dhunger_command_save } else { - narrate "<&6>Arena with that name not found." } dhunger_command_list: type: task debug: false script: - foreach { - narrate "<&6>Arena: %value%" } dhunger_command_set: type: task debug: false script: - define arg2 - define arg3 - if %arg2% == help { - narrate "<&6>/dhg set <<>setting<>> <<>value<>>" - narrate "<&6>setting - setting to change" - narrate "<&6><&sp><&sp><&sp>restock" - narrate "<&6><&sp><&sp><&sp>min_players" - narrate "<&6><&sp><&sp><&sp>max_players" - narrate "<&6><&sp><&sp><&sp>lightning" - narrate "<&6><&sp><&sp><&sp>lightning_delay" - narrate "<&6><&sp><&sp><&sp>countdown" - narrate "<&6><&sp><&sp><&sp>timer" - narrate "<&6>value - value to assign to setting" - queue clear } - if ! { - narrate "You don't have an arena selected." - queue clear } - define arena - define settings li@restock|min_players|max_players|lightning|lightning_delay|countdown|timer - if { - inject dhunger_setting_%arg2% } else { - narrate "Invalid setting" - queue clear } dhunger_setting_restock: type: task debug: false script: - if %arg3% != help && ( %arg3% matches integer && %arg3% > 0 ) { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.restock:%arg3% - narrate "<&6>Changing RESTOCK on arena <<>%arena%<>> with value: %arg3%" - inject dhunger_command_save } else { - narrate "<&6>/dhg set restock <<>value<>>" - narrate "Where <&dq>value<&dq> is the number of seconds between restocks." - narrate "Use 0 for no restocking." } dhunger_setting_min_players: type: task debug: false script: - if %arg3% matches integer && %arg3% >= 2 { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.min_players:%arg3% - narrate "<&6>Changing MIN_PLAYERS on arena <<>%arena%<>> with value: %arg3%" - inject dhunger_command_save } else { - narrate "<&6>/dhg set min_players <<>value<>>" - narrate "Where <&dq>value<&dq> is the minimum number of players for a game." - narrate "Default is 2." } dhunger_setting_max_players: type: task debug: false script: - if %arg3% matches integer && %arg3% >= { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.max_players:%arg3% - narrate "<&6>Changing MAX_PLAYERS on arena <<>%arena%<>> with value: %arg3%" - inject dhunger_command_save } else { - narrate "<&6>/dhg set max_players <<>value<>>" - narrate "Where <&dq>value<&dq> is the maximum number of players for a game." - narrate "Default is 20." } dhunger_setting_lightning: type: task debug: false script: - define allowed li@always|2|off - if { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.lightning:%arg3% - narrate "<&6>Changing LIGHTNING on arena <<>%arena%<>> with value: %arg3%" - inject dhunger_command_save } else { - narrate "<&6>/dhg set lightning <<>value<>>" - narrate "<&6>Available values are: always, 2 or off" - narrate "<&6>Always = Use lightning through the whole game" - narrate "<&6>2 = Use lightning when game is down to 2 players" - narrate "<&6>off = Don't use lightning at all" } dhunger_setting_lightning_delay: type: task debug: false script: - if { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.lightning_delay:%arg3% - narrate "<&6>Changing LIGHTNING_DELAY on arena <<>%arena%<>> with value: %arg3%" - inject dhunger_command_save } else { - narrate "<&6>/dhg set lightning_delay <<>value<>>" - narrate "<&6>value = Seconds between lightning strikes." - narrate "<&6>Available values are numbers > 0 " } dhunger_setting_countdown: type: task debug: false script: - if { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.countdown:%arg3% - narrate "<&6>Changing COUNTDOWN on arena <<>%arena%<>> with value: %arg3%" - inject dhunger_command_save } else { - narrate "<&6>/dhg set countdown <<>value<>>" - narrate "<&6>Number = Seconds to countdown at start of game." - narrate "<&6>Available values are numbers > 0 " - narrate "<&6>Default is 10" } dhunger_setting_timer: type: task debug: false script: - if { - yaml id:dhunger_saves set dhg.arenas.%arena%.settings.timer:%arg3% - narrate "<&6>Changing TIMER on arena <<>%arena%<>> with value: %arg3%" - inject dhunger_command_save } else { - narrate "<&6>/dhg set countdown <<>value<>>" - narrate "<&6>Number = Timer to wait for players to join." - narrate "<&6>Available values are numbers > 0 " - narrate "<&6>Default is 30" } dhunger_command_board: type: task debug: false script: - if ! { - narrate "You don't have an arena selected." - queue clear } - define arena - define arg2 - define settings li@add|del|reset - if { - if inject dhunger_help_board_%arg2% else inject dhunger_board_%arg2% } else { - narrate "<&6>/dhg board <&lb>add<&rb><&pipe><&lb>del<&rb><&pipe><&lb>reset<&rb>" - narrate "add - Add a sign board" - narrate "del - Delete the arena sign configuration" - narrate "reset - Reset a board" } dhunger_board_add: type: task debug: false script: - define signs - if { - narrate "Found your sign" - define sdir - define slist li@ - define signs - narrate "Direction %sdir%" # West - foreach %signs% { - define nsign %value% - define found false - foreach { - if ]> { - define slist ]> - define found true - foreach stop } # West Facing else if { - if ]> { - define slist ]> - define found true - foreach stop } } # East Facing else if { - if ]> { - define slist ]> - define found true - foreach stop } } # North Facing else if && ]> { - if ]> { - define slist ]> - define found true - foreach stop } } # South Facing else if { - if ]> { - define slist ]> - define found true - foreach stop } } } - if ! { - if || { - define slist ]> } else { - define slist ]> } } } - yaml id:dhunger_saves set dhg.arenas.%arena%.board:%slist% - inject dhunger_command_save - inject dhunger_board_reset } else { - narrate "sign wall missing or not big enough" } dhunger_board_del: type: task debug: false script: - define sign - foreach %sign% { - sign type:automatic "" %value% } - yaml id:dhunger_saves set dhg.arenas.%arena%.board:! - inject dhunger_command_save - narrate "The board in arena %arena% was removed." dhunger_board_reset: type: task debug: false script: - ^define sign - ^if > 2 { - define p_list ]:||li@> - define p_count - define alive # Set panel 1 - sign type:automatic "Hunger Game|%arena%|<<>Click to Join<>>" # Set panel 2 - sign type:automatic "%arena%|%p_count%<&0>/<&2>%alive%<&0>/<&4><&0>/<&0>" # Clear remaining boards - define dead_list - define p_sign li@ - foreach ]> { - if = 0 { - sign type:automatic "" %value% - foreach next } - define l_sign %value% - define p_sign - foreach p_sign { - if define p_sign %value%].at[%loop_index%]> } - define p_list - sign type:automatic "%p_sign%" %l_sign% } } dhunger_command_lobby: type: task debug: false script: - yaml id:dhunger_saves set dhg.lobby:l@,,,,, - inject dhunger_command_save dhunger_command_join: type: task debug: false script: - define arena > - narrate "Joining game %arena%" - if %arena% == help { - narrate "<&6>/dhg join <<>Arena Name<>>" - narrate "<&6>Either select an arena or provide an arena name" - queue clear } - if %arena% != { - narrate "<&6>That value doesn't look right." - queue clear } - if { - narrate "That game has already started" - queue clear } - define spawnpoints - define order - define ingame false - if { - while > 0 { - define randomnum ]> - define spawnpt ]> - if == 0 { - define ingame true - while stop } - define spawnpoints } } else { - foreach %spawnpoints% { - define spawnpt - if == 0 { - define ingame true - foreach stop } } } - if ! { - narrate "Game spawns are full" } else { - flag server dhg.%arena%.players:->: - inject dhunger_task_prep_player - define state up - inject dhunger_task_barricade - teleport %spawnpt% - adjust gamemode:survival - narrate " is joining the game." targets:]||li@> - inject dhunger_board_reset - if { - flag server dhg.%arena%.timer: } else { - run dhunger_game_check_start def:%arena% } } dhunger_game_check_start: type: task debug: false script: - wait 1t - ^define arena %1% - ^define timer - ^flag server dhg.%arena%.timer:%timer% - ^define steps li@%timer%|15|10|5|1 - ^if { - repeat { - define steps ].at[0]> } - define steps } - ^while { - if == 0 { - run dhunger_check_end_of_game def:%arena% - while stop } - ^if ]> { - if >= { - narrate "Game will start in: seconds" targets: } else { - narrate "Waiting for players... seconds to go." targets: } } else if { - if ]> { - define state down - foreach { - define spawnpt - inject dhunger_task_barricade } - narrate "Not enough players, cancelling game" targets: - run dhunger_check_end_of_game def:%arena%|cancelled - flag server dhg.%arena%:! - while stop } - run dhunger_game_start def:%arena% - while stop } - ^flag server dhg.%arena%.timer:-- - wait 1s } dhunger_game_start: type: task debug: false script: - ^define arena %1% - ^define timer - ^repeat %timer% { - define count - narrate "Beginning in %count%" targets: - wait 1s } - ^run dhunger_stock_chests def:%arena% instantly - ^define state down - ^flag server dhg.%arena%.started:true - ^foreach { - define spawnpt - inject dhunger_task_barricade } - ^narrate "GO!" targets: - ^if == always { - run dhunger_game_lightning def:%arena% id:dhg_lightning_%arena% } - ^if > 0 { - run dhunger_game_restock def:%arena% id:dhg_restock_%arena% } dhunger_task_prep_player: type: task debug: false script: #- ^if narrate "Remove Inventory" - ^define equipment - ^yaml id:dhunger_saves set 'dhg.player..equipment:' - ^yaml id:dhunger_saves set 'dhg.player..inventory:' - ^yaml id:dhunger_saves set 'dhg.player..gamemode:' - ^inventory clear d: - ^equip 'boots:' 'legs:' 'chest:' 'head:' - inject dhunger_command_save dhunger_task_cleanup_player: type: task debug: false script: #- ^if narrate "Replace Inventory" - ^inventory clear d: - ^define equipment .equipment]||li@> - ^equip 'boots:' 'legs:' 'chest:' 'head:' - ^inventory set 'd:' 'o:.inventory]||li@>' - ^adjust gamemode:.gamemode]||survival]> - ^yaml id:dhunger_saves set 'dhg.player.:!' - ^inject dhunger_command_save - ^flag player dhg.play:! - ^adjust health:20 - ^adjust food_level:100 - ^adjust saturation:100 dhunger_remove_player: type: task debug: true script: - ^define arena - ^if { - drop - ^teleport > } - ^define sound ]:||FIREWORK_LARGE_BLAST> - ^if playsound sound:%sound% volume:10 custom else playsound sound:%sound% volume:10 - ^if == 2 { - run dhunger_game_lightning def:%arena% } - ^flag server dhg.%arena%.dead:->: - inject dhunger_board_reset - ^if inject dhunger_task_cleanup_player dhunger_check_end_of_game: type: task debug: false script: - ^define arena %1% - ^if && != cancelled { - define winner - announce " has won the hunger game in %arena%" } - ^foreach { - run dhunger_remove_player player:%value% instantly } - ^run dhunger_task_block_rollback def:%arena% - ^remove - if queue queue:dhg_lightning_%arena% stop - if queue queue:dhg_restock_%arena% stop - ^flag server dhg.%arena%:! - inject dhunger_board_reset #- announce "Finished end_of_game" dhunger_stock_chests: type: task debug: false script: - ^define arena %1% - ^foreach li@tier1|tier2 { - define tier %value% - if ! foreach next - if ! foreach next - foreach { - define chest %value% - inventory clear d:%chest% - define additems li@ - foreach { - define itemvals - if ]> { - define additems ]>]].at[1]> } } - define additems - if %additems% == null { - narrate "error finding items for chests" - queue clear } - foreach %additems% { - define item %value% - while true { - define slot - if == i@air while stop } - inventory set d:%chest% o:%value% slot:%slot% } } } dhunger_task_block_track: type: task debug: false script: - ^define action %1% - ^define arena %2% - ^define location %3% - ^define mat %4% - ^yaml id:dhunger_saves set dhg.arenas.%arena%.track.%action%:->:li@%location%|%mat% - inject dhunger_command_save dhunger_task_block_rollback: type: task debug: false script: - ^define arena %1% - ^if { - if { - foreach { - modifyblock } } - if { - foreach { - modifyblock m@air } } - yaml id:dhunger_saves set dhg.arenas.%arena%.track:! - inject dhunger_command_save } dhunger_task_barricade: type: task debug: false script: - ^define barricade li@ - ^define blocktype - ^foreach li@0|1|2 { - define y %value% - foreach li@-1|0|1 { - define x %value% - foreach li@-1|0|1 { - define z %value% - if %x% == 0 && %z% == 0 { - foreach next } - define block - if ( && ) || ( && ) { - define barricade } } } } - ^if modifyblock %barricade% ]:m@air||%blocktype%> no_physics dhunger_game_lightning: type: task debug: false script: - ^define arena %1% - ^define timer - ^while { - wait %timer% - foreach { - strike no_damage } } dhunger_game_restock: type: task debug: false script: - ^define arena %1% - ^define timer - ^if %timer% == 0 queue stop - ^while { - wait %timer% - inject dhunger_stock_chests %arena% } dhunger_task_yaml_copy: type: task debug: false script: - define sourcekey %1% - define destkey %2% - if { - narrate "Source invalid for yaml copy" - queue stop } - if > 0 { - foreach { - run dhunger_task_yaml_copy def:%1%.%value%|%2%.%value% instantly } } else { - if { - foreach { - yaml id:dhunger_saves set %2%:->:%value% } } else { - yaml id:dhunger_saves set %2%: } } dhunger_task_block_change_check: type: task debug: false script: - if ! queue clear - foreach { - if determine cancelled }