Jump to content

[Mod][XCL] [0.21] stochastic's Spike Weights Adjustments


Recommended Posts

Posted

[XCL] [0.21] stochastic's Spike Weights Adjustments


Want to see more Show-Off pills? Tired of getting pilled with Resistance all the time? Only want to get Bimbo pills?

 

Adjust the relative weights of the different pills you get spiked with in the bar, the office, and the club. Doesn't affect the base game's logic for Breeder pills or sexual reputation at the office.

 

Other mods can add new pills by adding entries to the $spike_weights datamap.


 

Posted

It doesn't really work:

image.thumb.png.06186201a3e72bb686a4bf6d711cc91f.png

 

The scene plays through, but the value of $pill_taken is 'none'.
The culprit seem to be this line:
 

(set:$repeats to it + (repeated:$spike_weights's _pill, _pill))

 

Apparently it can't handle the temp variable. I tried to figure out how to fix it, and the only thing that seems to work so far was to use a non-temporary variable in place of the first _pill.

 

With the following change the errors disappeared (I am not sure why the temp variable is unacceptable, I haven't done anything in Harlowe before.):

(set:$test_name to _pill)
(set:$repeats to it + (repeated:$spike_weights's $test_name, _pill))


However, it still isn't perfect, as the result of 

(set:$select to (twirl:$repeats))

is that $select has the whole content of $repeats, not only one element, but the whole array because $twirl doesn't look into the variables, it returns one of the variables after the `:`  and there is only one variable.

 

Changing that line to the following fixes the problem.

(set:$select to (either: ...$repeats))


So in the end the code looks like this and it works:

 

:: spike weight adjust select
{
    (set:$repeats to (a:))
    (for:each _pill, ...(dm-names:$spike_weights))[
		(set:$temp_weighted_pill_name to _pill)
		(set:$repeats to it + (repeated:$spike_weight's $temp_weighted_pill_name, _pill))
	]
	(set:$select to (either: ...$repeats))
}


It is annoying that the `(for:` requires a temporary variable which can't be used with `$spike_weight's`  and I ended up with 2 variables.
Maybe someone smarter can find a better solution, I never wrote anything in Harlowe, and couldn't find any explanation for the different handling of the temporary/non-temporary variables in this case.

 

But at least it doesn't throw any errors now, and the $pill_taken value is set properly.

Posted

The reason for the silly long name ($temp_weighted_pill_name) is to avoid any accidental clash with anything. Nothing else.

Posted

Poked around a bit more, and figured out that `twirl:` works just needs the `...` in front of `$repeats`

 

:: spike weight adjust select
{
    (set:$repeats to (a:))
    (for:each _pill, ...(dm-names:$spike_weights))[
		(set:$temp_weighted_pill_name to _pill)
		(set:$repeats to it + (repeated:$spike_weights's $temp_weighted_pill_name, _pill))
	]
	(set:$select to (twirl: ...$repeats))
}

 

Still no idea why `_pill` doesn't work after `$spike_weights's`.

Posted
On 10/11/2024 at 7:16 PM, rrh said:

Poked around a bit more, and figured out that `twirl:` works just needs the `...` in front of `$repeats`

 

:: spike weight adjust select
{
    (set:$repeats to (a:))
    (for:each _pill, ...(dm-names:$spike_weights))[
		(set:$temp_weighted_pill_name to _pill)
		(set:$repeats to it + (repeated:$spike_weights's $temp_weighted_pill_name, _pill))
	]
	(set:$select to (twirl: ...$repeats))
}

 

Still no idea why `_pill` doesn't work after `$spike_weights's`.

 

I appreciate you doing some legwork on this; the new version I'm uploading in a bit should fix all this.

 

The answer to "why doesn't _pill work after $spike_weights?" turns out to be a bug in the version of Harlowe that XCL branched off of; it's fixed in the current version of Harlowe but XCL is unlikely to upgrade, so we have to work around it and use _pill of $spike_weights instead.

Posted
4 hours ago, stochastic_nsfw said:

The answer to "why doesn't _pill work after $spike_weights?" turns out to be a bug in the version of Harlowe that XCL branched off of; it's fixed in the current version of Harlowe but XCL is unlikely to upgrade, so we have to work around it and use _pill of $spike_weights instead.

 

Oh, it's a Harlowe version issue? I've been scared away from using temp variables in most cases, because it always seems like they don't work as intended.

I want to say that Aphrodite provided a macro for deleting variables, though, so they can be cleaned up...

Posted
On 10/16/2024 at 8:42 AM, emes said:

 

Oh, it's a Harlowe version issue? I've been scared away from using temp variables in most cases, because it always seems like they don't work as intended.

I want to say that Aphrodite provided a macro for deleting variables, though, so they can be cleaned up...

 

Initially, I was writing and testing code in the online Harlowe manual (v3.3.8) because the code testing window makes it very fast to test and iterate, then I'd copy the code over to VS Code and adapt as necessary; if there were no immediate error messages and everything was working correctly in the testing window, I (foolishly, I admit) assumed it was all good.

 

There was a long-standing bug that was fixed in one of the 3.3.x releases where

$dm's _temp

was being interpreted as meaning a datamap member named "_temp" instead of the member name being contained in the _temp variable. This bug only applied to temporary variables and not permanent ones, and didn't apply to the alternate syntax I've since switched to

_temp of $dm

which does the same thing. Since Aphrodite is not tracking Harlowe updates--for several good reasons--I don't know when or even if this will get fixed in XCL. It's possible that there are similar issues in other places with temporary variables, that may or may not have been fixed in more recent Harlowe releases, which would explain why you've had issues from time to time with them. It's important to note that certain constructs, like for loops, require a temporary variable and not a permanent one in specific places, so you can't always just go without.

  • 2 weeks later...
Posted (edited)

Hi, unfortunately this mod overrides bar spike occurs and club spike occurs, which conflicts with the Spike Fun mod. This means that it almost effectively disables the latter mod.

For my own use case, I made the passages in this to be [around], and display after passages at the end, so they will reactivate Club Spike's modded passages. I imagine it might also be possible to do this conditionally, using a mod check like

 

    (if:(passage:"__mods__")'s source contains "U666 Spike Fun")[ ... ]

 

For my code, I made it currently,

 

:: bar spike occurs [around]
{
(set: $seed to (newseed:))
(replace:?text)[(print:$spike_result)(nl:2)
(set:$breeder_spike_chance to (twist:1,10))
(set:$select to "Bar")
(display:"spike weight adjust select")
(if:$breeder_spike_chance is 1 or ($everyone_breeds is "Every NPC Mysteriously Wants to Breed You: Enabled" and $breeder_spike_chance <= 7))[(set:$select to "Breeder")](set:$take_card_disabled to "bar spike finish")(display:"spike transform")]
(display:_around)
}

 

Using (display: _around) will display the 'original' passage (or another mod's version of it, if other overrides exist).

Edited by mijhy
Posted
3 hours ago, mijhy said:

Hi, unfortunately this mod overrides bar spike occurs and club spike occurs, which conflicts with the Club Spikes mod. This means that it almost effectively disables the latter mod.

 

Yes, that's a downside. 
Looking at the code of both, I think the best place for this mod would be around spike pill selection if Spike Fun is installed. 
That way the Spike Fun logic works, only the pill type chances change.
Although it would make more sense for the other mods integrate this type of option given that there are other spiking mods and events. Bar Drugs, for sure, although not sure how active that is.
I made a modification where the Spike Fun code checks whether the Stochastic mod is installed and uses the result from it for the basic, not story related spiking.
Downside is that Spike Fun has more pills than Stochastic.

Posted
4 hours ago, mijhy said:

Hi, unfortunately this mod overrides bar spike occurs and club spike occurs, which conflicts with the Club Spikes mod. This means that it almost effectively disables the latter mod.

For my own use case, I made the passages in this to be [around], and display after passages at the end, so they will reactivate Club Spike's modded passages. I imagine it might also be possible to do this conditionally, using a mod check like

 

    (if:(passage:"__mods__")'s source contains "U666 Spike Fun")[ ... ]

 

For my code, I made it currently,

 

:: bar spike occurs [around]
{
(set: $seed to (newseed:))
(replace:?text)[(print:$spike_result)(nl:2)
(set:$breeder_spike_chance to (twist:1,10))
(set:$select to "Bar")
(display:"spike weight adjust select")
(if:$breeder_spike_chance is 1 or ($everyone_breeds is "Every NPC Mysteriously Wants to Breed You: Enabled" and $breeder_spike_chance <= 7))[(set:$select to "Breeder")](set:$take_card_disabled to "bar spike finish")(display:"spike transform")]
(display:_around)
}

 

Using (display: _around) will display the 'original' passage (or another mod's version of it, if other overrides exist).

 

I know how (display: _around) works--your approach here causes a problem because putting that at the end means the original passage (or whatever else has modified it) will likely stomp all over the spike weights adjustment. I might talk to U666 about making this mod work with Spike Fun, but fundamentally we're both trying to change the core spiking behavior, and since the passages in question compute a result and then call a passage that causes the transformation, you really need to overwrite the base game passage rather than try to work with it.

Posted (edited)
19 hours ago, stochastic_nsfw said:

 

 I might talk to U666 about making this mod work with Spike Fun, but fundamentally we're both trying to change the core spiking behavior, and since the passages in question compute a result and then call a passage that causes the transformation, you really need to overwrite the base game passage rather than try to work with it.

Would it make sense to agree on a standard "pill chance" passage that could be used by every mod that does something like this and could be used as a "hook" to hang the different decisions placed on and all it does is return the pills and drugs used in the transformation?

Stories or specific scenarios (smart guy wants a girlfriend, the foxhunt club, etc.) have their own decisions anyway, this is used for the generic randoms anyway.
I think it would be helpful to have the pill selection separated from the rest.
Obviously it isn't that simple, have to fit into the core game, people have to agree, etc., but would be worthwhile in the long run.

Edited by rrh
Posted
9 hours ago, rrh said:

Would it make sense to agree on a standard "pill chance" passage that could be used by every mod that does something like this and could be used as a "hook" to hang the different decisions placed on and all it does is return the pills and drugs used in the transformation?

Stories or specific scenarios (smart guy wants a girlfriend, the foxhunt club, etc.) have their own decisions anyway, this is used for the generic randoms anyway.
I think it would be helpful to have the pill selection separated from the rest.
Obviously it isn't that simple, have to fit into the core game, people have to agree, etc., but would be worthwhile in the long run.

 

In theory yes, but I suspect in practice the problem is that different people want different things & mechanics, and this leads to incompatible code in a lot of cases.

 

The next version of this mod will support Spike Fun though.

Posted

I'd imagine a universal passage would be quite an undertaking, since it'd need to be made in such a way as to allow modders and users to add in different modded pills and alter their chances of being used. (I'd also think that, eventually, people would want to be able to have different chances for the bar, work, the club, and wherever else spikes get added.)

Posted (edited)
On 11/4/2024 at 8:42 AM, stochastic_nsfw said:

 

I know how (display: _around) works--your approach here causes a problem because putting that at the end means the original passage (or whatever else has modified it) will likely stomp all over the spike weights adjustment. I might talk to U666 about making this mod work with Spike Fun, but fundamentally we're both trying to change the core spiking behavior, and since the passages in question compute a result and then call a passage that causes the transformation, you really need to overwrite the base game passage rather than try to work with it.

 

Yes, what I edited is mostly just a quick & dirty 'selfish' fix to get both things roughly working. Just pointed it out as a starting point in case it was useful. Since "getting spiked" has turned out to be a somewhat interesting major 'point of interest' mechanic of the game maybe in the future there could be something that allows multiple mods to hook additional functionality into this mechanic without having to step completely on all eachothers' toes.

Edited by mijhy
Posted (edited)
On 11/5/2024 at 2:28 PM, emes said:

I'd imagine a universal passage would be quite an undertaking, since it'd need to be made in such a way as to allow modders and users to add in different modded pills and alter their chances of being used. (I'd also think that, eventually, people would want to be able to have different chances for the bar, work, the club, and wherever else spikes get added.)

You could make it in a way that it uses a variable that is an array of pill:weight pairs and then the mods can do a (set:$pill_choice_array to $my_pill_weight_data) or something like that. 

I think the way this mod provides a way to set the weight values would be great as part of the core game, and the different mods can provide their own weights, like Spike Fun does now.

Obviously, it wouldn't be a 5 minute effort, but I don't think it would be a Mission Impossible level challenge. I will try to build a prototype - worst case I will learn more about Harlowe :D

Edited by rrh

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...