[1.3.0] Hospitality

Started by Orion, March 13, 2015, 11:19:16 AM

Previous topic - Next topic

Orion

Quote from: 10001110 on February 09, 2016, 03:27:40 PM
Is it possible to change visitor behavior so they stay inside if there is a raid going on? They go right through locked doors (maybe this is more of an MVP thing), and are the main cause for reloads  ??? they leave right then and get murdered in crossfire. Storytellers seem to have a soft spot for raiding if visitors are going to be sandwiched somehow.
Interesting one... I always like it when my visitors leave during an attack, since they usually help with the fight or at least distract the enemy... but I guess I could make them stay longer. Definitely interesting during a siege, if you have a group of starving visitors over for a week, that either eat all your supplies or go crazy / starve on your turf.

AllenWL

Quote from: Orion on February 09, 2016, 02:08:22 PM
Quote from: AllenWL on February 08, 2016, 06:58:39 AM
Can visitors that die in your colony or somehow don't make it back lower reputations?
Because as of now, every time visitors come with something I want, I lock them up or hope they meet some trouble, then loot their corpses. I mean, I have a townsmen lying on the snow, bleeding out, and some of their buddies come over, see the dude, and just leave him when they walk out.
That's a good point. I don't play the game that way, but indeed, there should be an effect. Although it could be devastating for your relationship if a group of visitors gets wiped out on their way to or from your colony. I'm definitely open for good ideas. Capping the value of the visitors objects seems like a good first step, though.
True, those might be a bit annoying... but then again, those would be rare, and hey, technically, you're also at fault for not helping!
It would be interesting. If visitors get attacked by raiders(which, unless the raiders come out right as visitors are leaving, you would see coming first), you have the choice of letting them fight, and risking them getting hostile, or you can go out and try to help!
If aiding visitors gave bonuses, it would be sweet, but that's probably way too complicated.

Daman453

Having a weird bug with it, alpha 12 with some mods and for some reason, guests will not recruit. http://i.imgur.com/8dMfpCC.png
Quote from: StorymasterQ on February 02, 2016, 08:19:52 PM
For flu, try a cock. If that doesn't work, try boobmilk. Nice.


Grimandevil

ifaik, recruitment attempts start when they reach happy mood.
welcome to the Rimworld - a world full of cannibal drug-addicted psychos, but free of vegetarians.

skyarkhangel

#394
Found serious bug with Hospitality (last version) which can lead to a freezes. it would be hard to play on speed-3 after some time.

Target in IncidentParms - null!

Its leads to memory overflow.

And could be temporarily fixed with cleaning some data in savegame:
Need to search  "<queuedIncidents/>" or <queuedIncidents> and clean all in this case.
attached library with attempt to fix.



[attachment deleted by admin - too old]

Orion

Quote from: Daman453 on February 24, 2016, 10:28:05 AM
Having a weird bug with it, alpha 12 with some mods and for some reason, guests will not recruit. http://i.imgur.com/8dMfpCC.png
Yeah, like Grimandevil said, keep going. First they have to be happy, then there's a small chance that they'll join, with each attempt. One day I might improve this system. Feels clunky to me now.

Quote from: skyarkhangel on February 25, 2016, 08:04:28 AM
Found serious bug with Hospitality (last version) which can lead to a freezes. it would be hard to play on speed-3 after some time.
Thanks for pointing this out and attempting to fix it! I can't reproduce it, though. Could it be a clash with another mod? What did you change in the source to fix it?

skyarkhangel

#396
Quote from: Orion on February 25, 2016, 09:35:31 AM
Quote from: skyarkhangel on February 25, 2016, 08:04:28 AM
Found serious bug with Hospitality (last version) which can lead to a freezes. it would be hard to play on speed-3 after some time.
Thanks for pointing this out and attempting to fix it! I can't reproduce it, though. Could it be a clash with another mod? What did you change in the source to fix it?

we (some of players) began to find why sometimes occur freezes in Hardcore SK. And going to "dig" save game with this freeze problem  :)  And found a lot of unsuccessful attempts to execute incident by Hospitality in <queuedIncidents> case. Then we clean all data. Profit = freezes are gone. I think this isn't a persistent problem, but under certain conditions it can be started.

xwat

#397
Quote from: Orion on February 25, 2016, 09:35:31 AM
Thanks for pointing this out and attempting to fix it! I can't reproduce it, though. Could it be a clash with another mod? What did you change in the source to fix it?
TL;DR: The problem seems to be solved by adding an additional check
if(parms.target == null) return false; in IncidentWorker_VisitorGroup.TryExecute(...) just after the initial parms validation, but before the call to Spawn(...)

Long version:
Let me elaborate a bit on the issue -- since I was helping Sky and the hardcore-sk community with this.
Btw, exception trace, indicating that problem indeed starts withing hospitality. https://yadi.sk/i/-fhuU2Z0pJBSi

First, it is really not easily reproducible/often occurring problem. But when it DOES occur, the game is basically unplayable (in dev mode you can witness 4000+ exceptions per second). The problem is that a guest visit gets queued by a storyteller, and then when it is being executed, an exception occurs, and the event record is not removed from the incident queue (a bug in Rimworld, btw)! And on the next storyteller tick the game tries to execute it over and over (since the event is on the top of the queue, remember?), crippling the performance.

That is why removing the visitor visit record from queued events in a save file solves the problem for that particular instance of the event.

Second, it seems that the problem does not END in hospitality: something goes haywire deep inside rimworld codebase (code for creating pawns, obviously). And this something complains about dereferencing of a null object.

Upon analyzing of a savefile, provided by a player, I spotted that in the queued event a parameter -- target is set to null -- I have no idea what it denotes -- but it should not be null! Moreover, parms validation from IncidentWorker_NeutralGroup does not touch target at all.

Thus I added a line (see TL;DR) in your code. After this fix a player confirmed, that the game is running smoothly now. I am not sure, how a null ended in the target field in the first place; but from what I can tell that code is only called by the IncidentQueue in the core Rimworld codebase.

I hope now you have a better understanding of the situation

Grimandevil

Quote from: Orion on February 25, 2016, 09:35:31 AM
Quote from: Daman453 on February 24, 2016, 10:28:05 AM
Having a weird bug with it, alpha 12 with some mods and for some reason, guests will not recruit. http://i.imgur.com/8dMfpCC.png
Yeah, like Grimandevil said, keep going. First they have to be happy, then there's a small chance that they'll join, with each attempt. One day I might improve this system. Feels clunky to me now.
personally, i just lock the perimeter and press my recruiter(s) to work non-stop, if there is a really good candidate.
welcome to the Rimworld - a world full of cannibal drug-addicted psychos, but free of vegetarians.

StorymasterQ

Always check for null!

"This should never be null" shall never be accepted as an excuse not to check for null.
I like how this game can result in quotes that would be quite unnerving when said in public, out of context. - Myself

The dubious quotes list is now public. See it here

Orion

#400
Quote from: xwat on February 25, 2016, 12:12:08 PM
TL;DR: The problem seems to be solved by adding an additional check
if(parms.target == null) return false; in IncidentWorker_VisitorGroup.TryExecute(...) just after the initial parms validation, but before the call to Spawn(...)
Thanks for finding and posting the fix. I've updated version 1.09c to include the fix.

Quote from: xwat on February 25, 2016, 12:12:08 PM
[..]
I hope now you have a better understanding of the situation
I do! Thanks for the explanation.

Quote from: StorymasterQ on February 25, 2016, 07:51:19 PM
Always check for null!

"This should never be null" shall never be accepted as an excuse not to check for null.
This is nonsense. If you'd check every reference for null at every corner you get a lot of convoluted code, that possibly even hides actual problems by "failing gracefully" even when input data is wrong. If I have (example)
string visitorTitle = visitor.story.adulthood.title; and I know it always has to be set, I'm not going to turn it into
if(visitor == null) throw new Exception("Visitor is null");
if(visitor.story == null) throw new Exception("Story is null");
if(visitor.story.adulthood == null) throw new Exception("Adulthood is null");
if(visitor.story.adulthood.title == null) throw new Exception("Title is null");
string visitorTitle = visitor.story.adulthood.title;

or return false, or whatever. If it doesn't throw an exception, the problem goes unnoticed. If it does throw an exception, what's the point? When you use the reference, the code throws an exception anyway, should it be null.

Orion

Quote from: xwat on February 25, 2016, 12:12:08 PM
Thus I added a line (see TL;DR) in your code. After this fix a player confirmed, that the game is running smoothly now. I am not sure, how a null ended in the target field in the first place; but from what I can tell that code is only called by the IncidentQueue in the core Rimworld codebase.
Sorry to say, but I have bad news for you. This is not the fix you are looking for.

It's perfectly fine for parms.target to be null. In fact, it's like that all the time. It's used for other events that actually have a a target. So what the check does is stop visitors from ever coming. Which of course, in a sort of way, solves the problem of queued up events. But it also makes this mod kind of pointless.

I've put a try/catch around spawning pawns. Hopefully that will help find the problem. Until then, back to the drawing board.

xwat

Quote from: Orion on February 26, 2016, 11:04:34 AM
I've put a try/catch around spawning pawns. Hopefully that will help find the problem. Until then, back to the drawing board.

Well, I am not that familiar with the Rimworld codebase and have no deep understanding of every param in every def.

In fact, this try/catch should be placed  not in your mod, but rather in IncidentQueue.IncidentTick -- so that incidents throwing exceptions for whatever reason stop being spammed indefinitely like they do now. But that's Tynan's part.

Orion

I went through a fixing spree and implemented every item I had on my wishlist. Vacation is awesome ;)

Changelog
1.10 - 26.02.2016
- quality of stay affects relationship change
- various tweaking
- fix: guests coming or leaving can't be interacted with
- fix: put cap on value of visitor gifts
- fix: visitors won't leave when relationship is maxed out
- guest beds can now be forbidden from colonists
- guests take off headgear when arriving

Enjoy!

Beathrus

Quote from: Orion on February 26, 2016, 03:31:42 PM
I went through a fixing spree and implemented every item I had on my wishlist. Vacation is awesome ;)

Changelog
1.10 - 26.02.2016
- quality of stay affects relationship change
- various tweaking
- fix: guests coming or leaving can't be interacted with
- fix: put cap on value of visitor gifts
- fix: visitors won't leave when relationship is maxed out
- guest beds can now be forbidden from colonists
- guests take off headgear when arriving

Enjoy!

Anyway to get my guests to actually go near/to the beds? Like... they just wander around the edge of my Home Zone... And completely ignore the lil shack I made them with guest beds.