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

Add Treetops #70643

Closed
wants to merge 77 commits into from
Closed

Add Treetops #70643

wants to merge 77 commits into from

Conversation

worm-girl
Copy link
Contributor

@worm-girl worm-girl commented Jan 4, 2024

Summary

Features "Adds treetops and makes trees climbable"

Purpose of change

Our trees are big enough to block all movement through their tile, but weren't climbable.

Describe the solution

  • Adds a "roof" to every tree's json entry, either a treetop, a dead treetop, or an evergreen treetop. These are very basic UNSTABLE and TRANSPARENT floor tiles
  • Adds a flag, CLIMBABLE_ADJACENT, that lets you climb a tree if you're standing next to it
  • Adds a flag, SINGLE_SUPPORT, that always destroys a tile if the tile under it triggers a collapse, even if there are other adjacent SUPPORTS_ROOF or WALL tiles
  • Makes the tinymap created during faction camp tree-cutting jobs extend one Z level higher so it can get rid of treetops when you clear-cut or cut logs from a forest tile via the faction camp billboard
  • Makes BIRD_LEGS resist the unstable ground effect, 'cause birds perch in trees irl.

Describe alternatives you've considered

Out of scope for now, but it probably wouldn't be too hard to make trees have variable heights. Then you'd scale them with something like the WALL_CLING ability that would be available to anyone, so z+1 would be you clinging to the side of the trunk, and at z+2 you'd be on the treetop, etc.

Making it so that some types of trees aren't climbable, or are only climbable with special equipment or mutation flags would also be easy.

There are only 4 forms of treetops right now, and they're all identical except their colors. The base kind is for all deciduous trees, evergreen, dead, and mega_fern are obviously for trees fitting those descriptions. I'm assuming this will be enough for spriters. If not, it's trivial to add more types of treetops in future PRs.

Testing

  • Climbed a tree
  • Fell out of a tree
  • Cut down a few trees
  • Used the zone menu to cut down some more trees
  • Used the zone menu to make an NPC cut down some more trees
  • Started a faction camp and ordered a clear-cut
  • Ordered a log-cutting mission at the camp as well

Additional context

image

Standing-Storm and others added 30 commits January 3, 2024 17:33
* update_toys.json

Added the plushies!!

* Update toy.json

* Update data/json/items/toy.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update toy.json

* Update data/json/items/toy.json

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

* Update data/json/items/toy.json

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

* Update data/json/items/toy.json

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

* Update data/json/items/toy.json

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

* Update data/json/items/toy.json

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

* Update data/json/items/toy.json

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

* Update data/json/items/toy.json

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

* Update data/json/items/toy.json

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

* YlUpdate data/json/items/toy.json

Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: TheShadowFerret <99621099+TheShadowFerret@users.noreply.github.com>
* Update robofac_gun.json

* Update locations_commercial.json

* Update music.json
* Remove gutter alias

* Readd the alias until mods are done in separate PR

* Corrections

* Linted

* Update mall_second_floor.json

* Update mall_second_floor.json

* Remove NoHope mall variants

They're really outdated and make minor changes and I don't fancy combing the -655 +514 line difference to update it correctly while keeping said minor changes.

* Realised I can just separate NoHope palettes for now

* Xedra tweak

* Final check
Prevents segfault that previously happened when pouring liquid to ground
from AIM using "examine" menu.

Previous segfault being fixed:
```
 #0  __gnu_cxx::__atomic_add_dispatch () at /usr/include/c++/13/ext/atomicity.h:111
 #1  std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_add_ref_copy () at /usr/include/c++/13/bits/shared_ptr_base.h:152
 #2  0x00005652b2df5540 in std::shared_ptr<item_location::impl>::shared_ptr () at /usr/include/c++/13/bits/shared_ptr.h:204
 #3  item_location::item_location () at src/item_location.h:30
 #4  item_location::impl::item_in_container::item_in_container () at src/item_location.cpp:612
 #5  item_location::item_location () at src/item_location.cpp:767
 #6  0x00005652b27fa6b1 in unload_activity_actor::unload () at src/activity_actor.cpp:3232
 #7  0x00005652b32eed69 in player_activity::do_turn () at src/player_activity.cpp:383
 #8  0x00005652b2b553e7 in do_turn () at src/do_turn.cpp:487
 #9  0x00005652b25ea589 in main () at src/main.cpp:798
```

The problem before was that the reference to `target` in
`unload_activity_actor::unload` was an invalid reference. This was
caused by:
  1. `unload_activity_actor::finish` calls `act.set_to_null()`.
  2. That sets the player activity to `null` type (=no current activity)
  3. `unload_activity_actor::unload` is `static`, and takes `target` as
     a reference.
  4. `::unload` calls `Character::add_or_drop_with_msg` which leads to
     call chain: `liquid_handler::consume_liquid` -> `get_liquid_target`
     -> `choose_adjacent` -> `choose_direction`
     -> `temp_hide_advanced_inv` -> `advanced_inventory::temp_hide`
     -> `advanced_inventory::do_return_entry`
  5. `advanced_inventory::do_return_entry` assigns a new
     `ACT_ADV_INVENTORY` activity. This invalidates the previous
     `unload_activity_actor` because of pt 2 above.
  6. When static method `unload_activity_actor::unload` resumes after
     its call to `add_or_drop_with_msg`, the reference to `target` is
     invalid because of pt 5.

This commit attempt to fix the issue with invalidated `target` reference
by copying its value before invalidating the activity.
When you read a map, we now keep track of what overmap tiles the map
revealed to you, so that we can blink them in the map view. I’ve
changed it from a vector of coordinates to an unordered_set, so that
membership testing is O(1), greatly improving performance.

fixes #70540
Fixes an issue where only the charges from one nearby smoking rack would
be counted to the crafting inventory, even if there were other smoking
racks nearby that had sufficient charges to perform a selected crafting
recipe.

The issue before was:
1. Part of building crafting inventory calls `inventory::form_from_map`
2. `inventory::form_from_map` has the following checks for pseudo tools
   from furniture:
   ```
   const furn_t &f = m.furn( p ).obj();
   if( item *furn_item = provide_pseudo_item( f.crafting_pseudo_item ) ) {
        const itype *ammo = f.crafting_ammo_item_type();
   ```
3. `inventory::provide_pseudo_item` returns `nullptr` if the crafting
   inventory already has a tool of the same type:
4. So `inventory::form_from_map` would only get a pseudo tool back in
   `furn_item` for the first furniture that was examined.
5. The ammo amount being calculated in `inventory::form_from_map` would
   therefore only be for that furniture.

This commit instead changes `inventory::provide_pseudo_item` so that if
a pseudo tool is provided more than once, the second call will return
the pseudo tool from the first call, instead of `nullptr` as before.
This makes it possible for `inventory::form_from_map` to keep adding
ammo (charcoal charges) to the same pseudo smoking rack as it builds up
the crafting inventory. In effect, if there are two smoking racks with
charges nearby, the crafting inventory will now still contain only one
pseudo tool for smoking rack, but its ammo will be the sum of all nearby
smoking racks' charges.
* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update data/json/items/book/spiritual.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update data/json/items/book/spiritual.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update spiritual.json

* Update stashes.json

* Update books.json

* Update books.json

* Update books.json

* Update spiritual.json

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Update character.cpp

* monsters too

* betterfix

* Update monmove.cpp

* Update character.cpp

* Update monmove.cpp

* fixes

* blaaargh

* fixes

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update vehicle_parts.json

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Initial (and probably final) commit

* ellipsis
* Everything but Speech.json

Third times the charm

* Update speech.json

Keeping speech.json to its own commit.
Less crowded this time.

* Spelling fixes

Correct typos and add terms to dictionary

* Update dictionary.txt

One more dictionary entry

* Update speech.json

Add more generic sounds for wailing treefrogs

* Update speech.json

Adjusting overcrowded speech entries
* Npc retreat2 (#29)

* Expose NPC AI consts to options

I will probably need a little help with this

* Restore 'regroup on player'

Now it won't kick in if the NPC is already close to you

* Remove unnecessary messages

* Npc retreat2 (#30)

* Expose NPC AI consts to options

I will probably need a little help with this

* Restore 'regroup on player'

Now it won't kick in if the NPC is already close to you

* Remove unnecessary messages

* Update data/core/game_balance.json

* Update modinfo.json

* Update modinfo.json

* delete dirty commits from my master

I hate the web interface
* Initial commit

* Dodgeability changes

* Add effects

* Effects is an array
more drops, more tools, pocket trash, custom hard hats, and other things
* fix early returns and dead code

* Update character.cpp

* Update character.cpp

* Update character.cpp
* Line breaks to markdown

* Add powers

* Update nether attunement values

* Spelling

* Remove missed learn_spells fields

* re-add learning EoC for hobby
…70239)

* initial commit. Add ibuprofen/acetaminophen and introduce aspirin bleeding.

* initial commit. Add ibuprofen/acetaminophen and introduce aspirin bleeding.

* in-progress json effects

* It works now! Cleaned up and added reasonable values.

* It works now! Cleaned up and added reasonable values.

* conjunction

* added drugs to loot lists

* added some spawns I missed

* minor fixes

* more infrastracture + perspiration --> respiration (lol)

* woops

* astyle

* minor fix

* Update npc.cpp sorting

* Update inventory.cpp

* Update character_body.cpp

* Update character.h

* metaprolol first draft.

* made metaprolol go through stomach for 30 min delay

* minor comment and astyle

* updated new meds to use  new vit system

* forgot to add naproxen to new system

* compiler and test fixes.

* astyle :(

* minor balancing

* fix

* implemented venera's suggestion to make aspirin make bleeding last longer, with the associated json infrastructure.

* Very minor fixes

* woops

* clang tidy

* fixed percentages. Thanks  fungamer2-2

* also json comment fix

* fixed mod decay logic.

* Updated documentation.

* vomiting removes digesting drugs now

* vomit code deduplication

* further documentation

* documentation fix

* forgot one pkill!

* removed foreign code from PR.

* Update data/json/items/comestibles/med.json

Co-authored-by: I-am-Erk <45136638+I-am-Erk@users.noreply.github.com>

* Update data/json/effects.json

Co-authored-by: I-am-Erk <45136638+I-am-Erk@users.noreply.github.com>

* Update data/json/itemgroups/Clothing_Gear/clothing.json

Co-authored-by: I-am-Erk <45136638+I-am-Erk@users.noreply.github.com>

* erk's suggestions + renamed item groups to otc painkillers

* Update data/json/items/comestibles/med.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update src/character.cpp

Co-authored-by: I-am-Erk <45136638+I-am-Erk@users.noreply.github.com>

* Update inventory.cpp

* increased pill-based pkill duration based on Erk's suggestions

---------

Co-authored-by: I-am-Erk <45136638+I-am-Erk@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
src/faction_camp.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the astyled astyled PR, label is assigned by github actions label Jan 4, 2024
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added the astyled astyled PR, label is assigned by github actions label Jan 4, 2024
@Zireael07
Copy link
Contributor

Somehow you have LOTS of commits here, I suspect something went wrong with git

@worm-girl
Copy link
Contributor Author

Somehow you have LOTS of commits here, I suspect something went wrong with git

It did, and I fixed it. As you can see this PR only changes 10 files and then only with relatively minor updates.

@Rokharn
Copy link

Rokharn commented Jan 4, 2024

Maybe good idea to add some new animal spawn here (squirrels, birds, maybe spiders and so on) too as well for some loot like bird nests?

@worm-girl
Copy link
Contributor Author

worm-girl commented Jan 4, 2024

Maybe good idea to add some new animal spawn here (squirrels, birds, maybe spiders and so on) too as well for some loot like bird nests?

Not a bad idea, but I'm gonna call it out of scope for now. That's a big project.

@gkarfakis19
Copy link
Contributor

I am worried about balance concerns. This means that as long as you can climb a tree, you can practically dodge any zombie horde in a forest (due to the poor Z handling we have). Can you check to make sure this PR doesn't trivialize that part of the game?

@Procyonae
Copy link
Contributor

I am worried about balance concerns. This means that as long as you can climb a tree, you can practically dodge any zombie horde in a forest (due to the poor Z handling we have). Can you check to make sure this PR doesn't trivialize that part of the game?

The only major issue I see with this is that you can use a reach weapon, just going up to "escape" doesn't do much for you bc they'll still be able to see you and just chill waiting for you to come down no? I personally feel like reach weapons shouldn't work across z-levels given the difference in height we typically associate with 1 z level compared to the distance of 1 tile across. Doing any serious damage to a zed from the roof of a bungalow with even a really long spear seems pretty difficult. Obviously you could also shoot the zed but that would aggro more stuff so I don't see that as big of a deal.
Idk how UNSTABLE works rn but making it so attacks have a good chance for you to fall based on "recoil" could be good.

@worm-girl
Copy link
Contributor Author

worm-girl commented Jan 4, 2024

I am worried about balance concerns. This means that as long as you can climb a tree, you can practically dodge any zombie horde in a forest (due to the poor Z handling we have). Can you check to make sure this PR doesn't trivialize that part of the game?

There aren't zombie hordes in forests, and after the beginning of the game they can reach up and pull you down, or destroy your tree with you in it. And in the beginning of the game, ferals are throwing rocks at you or stabbing you with spears.

The only thing it's going to get you is surrounded by zombies with no escape route. If you try to hide from them in a tree you're going to die. You can already easily climb on top of any house in town, where the zombies are, and that hasn't caused any issues even though the fact that it can block LOS and doesn't cut off escape routes is way more advantageous than a one tile tree.

UNSTABLE making you fall would be fine, as would zombies stealing your spear if you're poking down below with it. Neither are in scope here.

@worm-girl
Copy link
Contributor Author

worm-girl commented Jan 4, 2024

Also you may not be aware of this, but climbing requires a free hand and there's a roll involved. You can also fall down and injure or kill yourself doing it. Speaking as someone who makes a living playing this game (I hate to bring that up to win an argument, but it's relevant here) I don't see a balance issue here outside of the one that already exists for reach weapons.

@GuardianDll
Copy link
Member

> you can practically dodge any zombie horde in a forest

Grabber zombies had an ability to grab enemy on another z-level - it was lost when grabs were reworked, but i think we can return it as one of multiple counters to roof chill

@sadenar
Copy link
Contributor

sadenar commented Jan 4, 2024

Also you may not be aware of this, but climbing requires a free hand and there's a roll involved. You can also fall down and injure or kill yourself doing it. Speaking as someone who makes a living playing this game (I hate to bring that up to win an argument, but it's relevant here) I don't see a balance issue here outside of the one that already exists for reach weapons.

I think this is good enough to make climbing a balanced action that can save you in a tight spot but implies some innate risk, especially when you're scared/exhausted/overloaded/sick/whatever.
Zomboid already does it very well in my opinion with the fence climbing checks (although treehouses in that game are a bit op)

@BlizzDA
Copy link
Contributor

BlizzDA commented Jan 4, 2024

Would some of the treetops provide shelter from the rain or sun (if albino) if standing under them, or would that be for a future PR?

@Rabadash94
Copy link

Will there be treehouses in the future?

Copy link
Member

@I-am-Erk I-am-Erk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fairyarmadillo note this has pretty much nothing to do with your code work, it is a project infrastructure block.

Heads up to mergers, I think we should probably set this as a 'branch' (hehe) point between the H-stable candidate and I-experimental. We should not be merging this into the stable candidate. Normally we'd be tagging it feature freeze but since we're going to try not to do that this time, I'm just setting this up to be blocked until we have the stable candidate.

I'll see about making a PR tag for this once I am sure I understand how that's going to work fully

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 4, 2024
@worm-girl
Copy link
Contributor Author

fairyarmadillo note this has pretty much nothing to do with your code work, it is a project infrastructure block.

It's showing that changes are requested but I don't see anything in conversations. Is there anything I need to do on my end?

Would some of the treetops provide shelter from the rain or sun (if albino) if standing under them, or would that be for a future PR?

Will there be treehouses in the future?

I don't see why not in the future, but both of these will probably require multi-tile trees, and we're not there yet.

@GuardianDll
Copy link
Member

fairyarmadillo note this has pretty much nothing to do with your code work, it is a project infrastructure block.

It's showing that changes are requested but I don't see anything in conversations. Is there anything I need to do on my end?

It's just to ensure this PR won't be merged accidentally, this would be merged after the 0.H would be released

@I-am-Erk I-am-Erk dismissed their stale review January 5, 2024 02:44

obsolete now that h branch is out

@I-am-Erk
Copy link
Member

I-am-Erk commented Jan 5, 2024

No action needed, I managed to get H branch out before it was relevant

@mqrause
Copy link
Contributor

mqrause commented Jan 5, 2024

Somehow you have LOTS of commits here, I suspect something went wrong with git

It did, and I fixed it. As you can see this PR only changes 10 files and then only with relatively minor updates.

Please note that there are still a bunch of commits listed that are not actually part of your PR. I assume this will cause some issues or side effects when it gets merged.

@worm-girl
Copy link
Contributor Author

I will probably need to make a new PR then.

@worm-girl
Copy link
Contributor Author

Continued in #70669

@worm-girl worm-girl closed this Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions Bionics CBM (Compact Bionic Modules) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. Crafting / Construction / Recipes Includes: Uncrafting / Disassembling <Documentation> Design documents, internal info, guides and help. <Enhancement / Feature> New features, or enhancements on existing EOC: Effects On Condition Anything concerning Effects On Condition Fields / Furniture / Terrain / Traps Objects that are part of the map or its features. Info / User Interface Game - player communication, menus, etc. Items: Ammo / Guns Ammunition for all kinds of weapons and these weapons themselves Items: Food / Vitamins Comestibles and drinks [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions Map / Mapgen Overmap, Mapgen, Map extras, Map display [Markdown] Markdown issues and PRs Mechanics: Enchantments / Spells Enchantments and spells Melee Melee weapons, tactics, techniques, reach attack Missions Quests and missions Mods: Mind Over Matter Mods: No Hope Relating to the mod No Hope Mods: Tamable Wildlife Mods: Xedra Evolved Anything to do with Xedra Evolved Mods Issues related to mods or modding Monsters Monsters both friendly and unfriendly. Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies NPC / Factions NPCs, AI, Speech, Factions, Ownership Player Faction Base / Camp All about the player faction base/camp/site SDL: Tiles / Sound Tiles visual interface and sounds. Spawn Creatures, items, vehicles, locations appearing on map Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging this pull request may close these issues.