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

feat: eggs from friendly wildlife critters spawn friendly offspring #4289

Merged
merged 1 commit into from
Mar 4, 2024

Conversation

ekaratzas
Copy link
Contributor

@ekaratzas ekaratzas commented Mar 3, 2024

It's tedious to require the player to keep taming offspring of the animals they have already tamed in the first place so this change addresses that, especially for chickens who multiply aggressively! Mostly meant as QoL change for farm players.

Purpose of change

This change is meant as a simple QoL improvement, mostly aimed at farm players. It's a continuation of the work in 729b2b5 and addresses the tamed wildlife that reproduces by laying eggs.

This change works well alongside generic culling process that already exists for pets: 8c42631

Describe the solution

Solution works by introducing a new flag that gets attached to the egg on the condition that the parent is friendly to the player + is wildlife creature. When it's time to spawn a monster from the egg, we check whether the flag is present and if so, we spawn the new monster as a friend of the player.

Describe alternatives you've considered

Just like with previous commit, I think it's safe to constrain this behavior to tamed wildlife for the time being.

Testing

Testing is tricky as you need to wait until the friendly critter (e.g. chicken) lays an egg and then wait until the egg 'rots' which has a chance to produce an offspring.

I'm using this hackish commit to facilitate testing by:

  • making the critter lay egg every time it's loaded in the submap
  • make the egg 'rot' ~100 turns after it's created
  • give 100% chance for the rot event to create an new monster, as long as there's no other monster in the same tile

With the above hack commit in place:

Make chicken. Don't tame chicken. Walk away and back (~e.g. 120 tiles). Submap gets reloaded and chicken lays egg. Wait ~100 turns and see that spawned chicklet is neutral to the player.

Make chicken. Tame chicken. Walk away and back (~e.g. 120 tiles). Submap gets reloaded and chicken lays egg. Wait ~100 turns and see that spawned chicklet is friendly to the player.
chicken_spawn_friendly

Also test that friendly spawned creature can be turned into proper pet the typical way by the use of appropriate food.

Additional context

Checklist

It's tedious to require the player to keep taming offspring of the
animals they have already tamed in the first place so this change
addresses that, especially for chickens who multiply aggressively!
Mostly meant as QoL change for farm players.
@github-actions github-actions bot added src changes related to source code. JSON related to game datas in JSON format. labels Mar 3, 2024
@scarf005
Copy link
Member

scarf005 commented Mar 3, 2024

also cc @KheirFerrum,
do we have existing means to spawn friendlies (e.g inactive bots)?

@KheirFerrum
Copy link
Collaborator

also cc @KheirFerrum,
do we have existing means to spawn friendlies (e.g inactive bots)?

Should ask Kenan and @chaosvolt, since both of them touch stuff like this.

@chaosvolt
Copy link
Member

One minor complication I'd like to note: the slaughter command was only added to the pet menu, not the friend menu (main reason is this would allow player ferals to execute friendly ferals just by examining, when they're really just supposed to be tolerating a player feral's presence and are only marked as friendly for not-breaking-gameplay reasons).

These changes spawn offspring as friendly far as I can tell, not as full-on pets. I'd need to check it out and compile-test to be 100% sure however, currently out and about on wifi so can't test just yet. Given that will block off access to all the other functions like milking, making sure they correctly spawn as full-on pets and not just generic friendlies might be good to double-check for.

@ekaratzas
Copy link
Contributor Author

@chaosvolt that's a good point. They actually spawn as friendly, not full-blown pets. Thanks for pointing that out.

Do you think this needs to get handled as part of this PR? I think the current change is still useful as is since as a chicken farmer you will no longer have to be careful to avoid auto-attacking your flock while going through the chicken coop.

Lemme know what you think.

@chaosvolt
Copy link
Member

Do you think this needs to get handled as part of this PR?

Since it'll also affect the other PR that got merged, it can probably wait to be implemented in a follow-up PR. If you feel it'd be easy enough to fit into this PR then go for it, but it's not urgent.

Implementation-wise it should be mostly just checking if the parent monster has the pet effect (seems to be how all cases of pet behavior are handled), and if so adding the effect to the new monster after it's spawned (possibly with an extra item flag being tracked in the case of eggs, in the event you feel it's worth tracking friendly eggs separate from friendly-and-also-pet eggs).

@ekaratzas
Copy link
Contributor Author

@chaosvolt I'm looking at it now and it seems that it's doable but it would have to be a more invasive change as the existing void add_spawn() API works on the binary notion of friendly/not friendly spawn.

For mammals as far as I can tell we'd have to extend that API. For eggs, simply changing this flag's behavior or adding a new flag seems like it'd work ok.

Personally I'd rather make iterative progress and get this in as it improves things and followup with another PR for full-blown-pet-conversion of spawns for both types of spawning. I was looking into fixing issue #3966 but I can context switch to this instead.

@ekaratzas
Copy link
Contributor Author

For the record, I did just test that you can turn a friendly spawned creature into a pet the regular way so it doesn't seem like this introduces a regression. I'll update the PR test plan.

@scarf005 scarf005 requested a review from chaosvolt March 4, 2024 00:55
Copy link
Member

@chaosvolt chaosvolt left a comment

Choose a reason for hiding this comment

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

Nice, that's a good way around it so. :>

@scarf005 scarf005 merged commit 95816f2 into cataclysmbnteam:main Mar 4, 2024
13 checks passed
@ekaratzas ekaratzas deleted the friendly-spawns-eggs branch March 10, 2024 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
JSON related to game datas in JSON format. src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants