Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: lobby colliding issues, entity cramming, lobby messaging, and pl… #14

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 4 additions & 2 deletions scripts/game_server_scripts/items/explosives.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ fort_explosive_handler:
- foreach stop
- wait 1t

on player left clicks block with:fort_item_impulse_grenade flagged:!fort.item_dropped:
on player left clicks block with:fort_item_impulse_grenade flagged:!fort.item_dropped|!using_impulse_grenade:
- define i <context.item>
- define eye_loc <player.eye_location>
- define origin <[eye_loc].relative[-0.25,0,0.35]>
- define target_loc <[eye_loc].ray_trace[default=air;range=100]>
- define points <[origin].points_between[<[target_loc]>].distance[0.75]>

- flag <player> fort.using_impulse_grenade expire:2s
- playsound <player> sound:ENTITY_SNOWBALL_THROW pitch:0.9

- take slot:<player.held_item_slot>
Expand Down Expand Up @@ -67,13 +68,14 @@ fort_explosive_handler:
- foreach <[entities]> as:e:
- adjust <[e]> velocity:<[e].location.above[1].sub[<[grenade_loc]>]>

on player left clicks block with:fort_item_grenade flagged:!fort.item_dropped:
on player left clicks block with:fort_item_grenade flagged:!fort.item_dropped|!fort.using_grenade:
- define i <context.item>
- define eye_loc <player.eye_location>
- define origin <[eye_loc].relative[-0.25,0,0.35]>
- define target_loc <[eye_loc].ray_trace[default=air;range=100]>
- define points <[origin].points_between[<[target_loc]>].distance[0.75]>

- flag <player> fort.using_grenade expire:1.5s
- playsound <player> sound:ENTITY_SNOWBALL_THROW pitch:0.9

#item:<[item]> doesn't work for some reason
Expand Down
31 changes: 23 additions & 8 deletions scripts/game_server_scripts/items/guns.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fort_gun_handler:

#if gun is empty when picking it up, reload
- define loaded_ammo <server.flag[fort.temp.<[gun_uuid]>.loaded_ammo]>
- if <[loaded_ammo]> == 0:
- if <[loaded_ammo]> <= 0:
- run fort_gun_handler.reload def:<map[gun=<[gun]>]>

on player drops gun_*:
Expand Down Expand Up @@ -322,6 +322,7 @@ fort_gun_handler:
- flag player fort.<[gun_name]>.cooldown duration:<[gun].flag[cooldown]>s

- flag player is_shooting
- flag player fort.reloading_gun:!
- while <player.has_flag[gun_holding_down]> && <player.is_online> && <player.item_in_hand.flag[uuid]||null> == <[gun_uuid]>:
#do 1 instead of 0 so there's no delay on the first shot
- if <[loop_index].mod[<[ticks_between_shots]>]> == <[mod_value]>:
Expand Down Expand Up @@ -769,7 +770,7 @@ fort_gun_handler:
#run, not inject, since there are waits in it
- run update_hud

- if <[loaded_ammo]> == 0:
- if <[loaded_ammo]> <= 0:
- run fort_gun_handler.reload def:<map[gun=<[gun]>]>
- while stop

Expand Down Expand Up @@ -833,13 +834,15 @@ fort_gun_handler:

- define auto_reload <[data].get[auto_reload]||false>

- if <[total_ammo]> == 0:
# disallow player to reload if negative or equal to 0 ammo
- if <[total_ammo]> <= 0:
# ensure the player has 0 ammo and not negative ammo
- flag player fort.ammo.<[ammo_type]>:0
#auto reload just makes it so the "no reload" text doesn't appear every time you hold the item
- if !<[auto_reload]>:
- cast FAST_DIGGING amplifier:9999 duration:1s no_icon no_ambient hide_particles
- title "subtitle:<&c>No reload ammo." fade_in:0 stay:1 fade_out:15t
- title "subtitle:<&c>No ammo to reload with." fade_in:0 stay:1 fade_out:15t
- playsound <player> sound:UI_BUTTON_CLICK pitch:1.8

- stop

- flag player fort.reloading_gun
Expand All @@ -851,7 +854,12 @@ fort_gun_handler:
- cast SLOW_DIGGING amplifier:255 duration:9999999s no_icon no_ambient hide_particles if:<[gun_name].equals[rocket_launcher].not>
- repeat <[reload_time].div[3]>:

#if they hold it and it's, it'll auto reload
# check if the player has stopped reloading during the sequence
- if !<player.has_flag[fort.reloading_gun]>:
- define cancelled True
- repeat stop

# if they hold it and it's, it'll auto reload
- if <player.item_in_hand.flag[uuid]||null> != <[gun_uuid]>:
- define cancelled True
- repeat stop
Expand All @@ -875,10 +883,18 @@ fort_gun_handler:
- define new_loaded_ammo <[mag_size]>
- define new_total_ammo <[total_ammo].sub[<[mag_size].sub[<[current_loaded_ammo]>]>]>

# ensure that new_loaded_ammo is 0 and not negative.
- if <[new_loaded_ammo]> < 0:
- define <[new_loaded_ammo]> 0

# ensure that new_total_ammo is 0 and not negative.
- if <[new_total_ammo]> < 0:
- define <[new_total_ammo]> 0

- flag server fort.temp.<[gun_uuid]>.loaded_ammo:<[new_loaded_ammo]>
- flag player fort.ammo.<[ammo_type]>:<[new_total_ammo]>

#"return" rocket into gun
# "return" rocket into gun
- if <[gun].script.name.after[gun_]> == rocket_launcher:
- inventory adjust slot:<player.held_item_slot> custom_model_data:20

Expand All @@ -892,7 +908,6 @@ fort_gun_handler:
- cast SLOW_DIGGING remove
- flag player fort.reloading_gun:!


shoot_fx:
#default origin
- define particle_origin <proc[gun_particle_origin].context[<[gun_name]>]>
Expand Down
16 changes: 11 additions & 5 deletions scripts/game_server_scripts/items/pickaxe.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,19 @@ fort_pic_handler:
- define block <context.location>
- define mat <[block].material.name>

- if <[mat].contains_any_text[oak|spruce|birch|jungle|acacia|dark_oak|mangrove|warped|barrel|bamboo]>:
- define tool netherite_axe
- if <[mat].contains_any_text[sand]>:
- define tool netherite_shovel
- else:
- define tool netherite_pickaxe
- if <[mat].contains_any_text[wool]>:
- define tool shears
- else:
- if <[mat].contains_any_text[oak|spruce|birch|jungle|acacia|dark_oak|mangrove|warped|barrel|bamboo]>:
- define tool netherite_axe
- else:
- define tool netherite_pickaxe

- if <[i].material.name> != <[tool]>:
- inventory adjust slot:<player.held_item_slot> material:<[tool]>
- if <[i].material.name> != <[tool]>:
- inventory adjust slot:<player.held_item_slot> material:<[tool]>

#in case they switched from another item
- cast FAST_DIGGING remove
Expand Down
73 changes: 34 additions & 39 deletions scripts/lobby_scripts/lobby_menu.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ test:
type: task
debug: false
script:
- define msg "<n><&c><&l>[!] Resourcepack download failed.
<n><n><&f>Sup nerd, the Nimnite resourcepack is <&n>required<&r> to play.
- define msg "<n><&c><&l>RESOURCE PACK FAILED TO APPLY
<n><n><&f>Uh oh, the Nimnite resourcepack is <&n><&l>required<&r> to play!
<n><n><n><n>If you think this is a <&c>bug<&r>, please report it in our <&9><&l><&n>Discord<&r> server!
<n><n><&b><&n>https://discord.gg/RB5a7WvHeP<&r>
<n><n>(idk how to make the link clickable rip)"
<n><n><&b><&n>https://discord.gg/nimsy<&r>"
- kick <player> reason:<[msg]>

fort_lobby_handler:
Expand Down Expand Up @@ -108,6 +107,9 @@ fort_lobby_handler:
- waituntil <world[fort_lobby].if_null[false]> max:10s
#-in case the server crashed/it was incorrectly shut down

# prevents entity cramming of entities.
- gamerule <world[fort_lobby]> maxEntityCramming 0

- ~mongo id:nimnite_playerdata connect:<secret[nimbus_db]> database:Nimnite collection:Playerdata
- narrate "<&b>[Nimnite]<&r> Connected to Nimnite database."

Expand Down Expand Up @@ -146,6 +148,7 @@ fort_lobby_handler:
- adjust <player> fly_speed:0.02

- invisible state:true
- adjust <player> collidable:false

- inventory clear
- sidebar remove
Expand All @@ -156,12 +159,19 @@ fort_lobby_handler:
- run fort_lobby_handler.lobby_tp
- stop

#cancel the emote
# cancel the emote
- flag player fort.in_menu:!
- flag player fort.emote:!
- if <context.cause> == QUIT:
- stop

on player chats:
- determine passively cancelled

# This prevents players from being damaged in the lobby.
on player damaged:
- determine passively cancelled

#in case they hit a player and not click a block
on player damages entity flagged:fort.in_menu priority:-10:
- determine passively cancelled
Expand All @@ -172,26 +182,17 @@ fort_lobby_handler:
#the attack cooldown is removed via rp
- inject fort_lobby_handler.button_press


# - (temp whitelist) - #
on player prelogin:
- define name <context.name>
- if !<server.has_flag[whitelist]> || <server.flag[whitelist].contains[<[name]>]>:
- stop

- if <server.online_players.size> >= <script[nimnite_config].data_key[max_lobby_players]>:
- if <[name]> in Nimsy|Mwthorn:
- stop
- define msg "<&c>The server is currently full. Join back later!"
- determine passively KICKED:<[msg]>

#### - [ OPTIMIZE / PRETTIFY THIS CODE ] ###
on player join:
#player join message
- determine passively NONE
- define name <player.name>

- announce "<&chr[0001].font[denizen:announcements]> <&9><[name]>"
# hide player from other players.
- adjust <player> hide_from_players

## This shit is so annoying
# - announce "<&chr[0001].font[denizen:announcements]> <&9><[name]>"
- announce to_console "<&8><&lb><&a>+<&8><&rb> <&f><[name]>"

- teleport <player> <server.flag[fort.menu_spawn].above[0.5]>
Expand All @@ -200,7 +201,7 @@ fort_lobby_handler:
#used to prevent collision
- team name:lobby_player add:<player>

#-for test server
# for test server
- if <server.has_flag[is_test_server]>:
- run fort_lobby_setup.player_setup
- stop
Expand All @@ -224,54 +225,49 @@ fort_lobby_handler:
#- [ ! ] Warning: RP is being downloaded every time players join lobby server (even when returning from game)
#can be fixed with new snapshot stuff from 1/18/23

#

- define hash <server.flag[fort.resourcepack.hash]>
#add a rp prompt?
- resourcepack url:http://mc.nimsy.live:4000/latest.zip hash:<[hash]> forced

#put this inside the tick loop too, or nah
- cast BLINDNESS duration:infinite hide_particles no_icon no_ambient
- define subtitle "bare with me"
- while <player.is_online> && !<player.has_flag[fort.menu]> || <player.has_flag[]>:
- title "title:<&e>Downloading Resourcepack..." subtitle:<&7><[subtitle]> fade_in:1 stay:1 fade_out:1
- title "title:<&e><&l>DOWNLOADING RESOURCEPACK..." subtitle:<&7><[subtitle]> fade_in:1 stay:1 fade_out:1
- define subtitle <list[here's a shameless promo -<&gt> twitch.tv/flimsynimsy|you ever just realize how handsome nimsy is?|fun fact: 1 year of a degen<&sq>s life was spent on this|y are u still here|please donate me money PLEASE|isn<&sq>t nimsy like- the best?].random>
#wait 1s for a "flashing" effect
- wait 3s

on resource pack status:
#SUCCESSFULLY_LOADED, DECLINED, FAILED_DOWNLOAD, ACCEPTED
# SUCCESSFULLY_LOADED, DECLINED, FAILED_DOWNLOAD, ACCEPTED
- define status <context.status>
#-for test server
# - For test server
- define status SUCCESSFULLY_LOADED if:<server.has_flag[is_test_server]>
#
- choose <context.status>:
- case SUCCESSFULLY_LOADED:
#reset loading text
# Reset title and remove blindness.
- title title:<&sp> subtitle:<&sp> fade_in:1 stay:1 fade_out:1
- cast blindness remove
#in case they moved during rp load
# If the player moves while loading the resource pack, teleport them back to the middle.
- teleport <player> <server.flag[fort.menu_spawn].above[0.5]>
- inject fort_lobby_setup.player_setup
- wait 2s
#-non-vanilla client risk message
# Check if the player's client ruins the hud, if so we warn them.
- define client <player.client_brand>
- announce to_console "Player is using: <[client]>"
- define client_blacklist <list[Lunar|Feather|Badlion|unknown]>
- if <player.is_online> && <[client].contains_any_text[<[client_blacklist]>]>:
- playsound <player> sound:BLOCK_NOTE_BLOCK_PLING pitch:1.5
- define line <&8><element[<&sp>].repeat[80].strikethrough>
- narrate <[line]>
- narrate "<&c><&l>[!] Warning [!] <&c>You're running on a client that probably f**ks with your UI in-game."
- narrate "<&c><&l>Warning <&r><&c>You're using a client that could ruin your in-game HUD."
- narrate "<n><&7>Your client: <&c><player.client_brand>"
- narrate "<&8>Known clients that cause issues: <&7><[client_blacklist].separated_by[<&8>, <&7>]>"
- narrate <[line]>

- case DECLINED FAILED_DOWNLOAD:
- define msg "<n><n><n><&c><&l>[!] Resourcepack download failed.
<n><n><&f>Sup nerd, the Nimnite resourcepack is <&n>required<&r> to play.
<n><n><n><n>If you think this is a <&c>bug<&r>, please report it in our <&9><&l><&n>Discord<&r> server!
<n><n><&b><&n>https://discord.gg/RB5a7WvHeP<&r>
<n><n>(idk how to make the link clickable rip)"
- define msg "<n><n><n><&c><&l>RESOURCEPACK FAILED TO DOWNLOAD
<n><n><&f>Uh oh... The Nimnite resourcepack is <&c><&n><&l>required<&r> to play.
<n><n><n><n>If you think this is a <&c>bug<&r>, please report it in our <&9><&l><&n>DISCORD<&r> server!
<n><n><&b><&n>https://discord.gg/nimsy<&r>"
- kick <player> reason:<[msg]>

## - [ MAKE THIS CLEANER ] - ##
Expand Down Expand Up @@ -444,7 +440,7 @@ fort_lobby_handler:

- run fort_lobby_handler.match_info def.option:remove

- adjust <[name_text]> "text:<player.name><n><&c>Not ready" if:<[name_text].equals[null].not>
- adjust <[name_text]> "text:<player.name><n><&c>Not Ready" if:<[name_text].equals[null].not>

- playsound <player> sound:BLOCK_NOTE_BLOCK_BASS pitch:1
- flag player fort.in_queue:!
Expand Down Expand Up @@ -626,7 +622,6 @@ fort_lobby_setup:
debug: false
definitions: cube|loops|type|name
script:

#-reset previous entities
- foreach play|mode|vid as:button_type:
- if <server.has_flag[fort.menu.<[button_type]>_button_hitboxes]>:
Expand Down