HentHighSchool Development Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

collapse
* Recent Posts
Re: Feature requests, wishlists by Hans_Wurst
[Today at 02:17:13 am]


Re: Experimental patch - Modified perk trees and autorest by kite80
[Today at 01:35:30 am]


Re: Hans_Wurst┬┤s questions by Hans_Wurst
[Yesterday at 11:42:10 pm]


Re: Gameplay and design discussion by doujin
[Yesterday at 10:43:19 pm]


Re: Girl packs by HeyThereHomie
[Yesterday at 09:18:23 pm]


Pages: [1]   Go Down

Author Topic: Trait King Mod  (Read 1784 times)

_neronero

  • Newbie
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Trait King Mod
« on: March 15, 2019, 08:43:56 pm »


Trait King adds more traits, gives girls a "potential"-value that adjusts the potency of traits
and makes girls spawn with different combinations of gold, positive and negative traits.

I'm not much of a programmer, but I like this game and I've been trying to mod it a little bit. I've reached a point where I need some help/feedback. Sadly I wasn't able to contain its to its own .rpy file. I had to modify BKgirlclass.rpy and BKfunctions.rpy as well. Let me know if there's a better way to do what I tried to do, or if this is just a limitation of how this mod system works (it seems ideal for events/story mods, but less suited for modifying existing gameplay elements)

Goals:
  • Make girls feel more unique
  • Make growth of girls more unpredictable, stimulating the player to sell disappointing girls and invest in new talent

Features:
  • Changes the potency of traits by giving each girl a "realised potential" value that many traits scale with. Girls start with a random value of potential and unlike the usual scaling factors (such as rank) it can go both up and down (or stagnate) as your girls level up. It's slightly more likely to go up in general.
  • Due to the addition of potential most traits have been buffed, especially in the late game.
  • Adds 12 new gold, 9 new positive and 14 new negative traits to the game (I'm open to more suggestions or tweaks)
  • How many gold, positive and negative traits a girl spawns with is randomised. Original girls are still better on average, but clones also have a chance of spawning with a nice combination of traits. It makes them feel a lot more unique. Previously I would just ignore clone girls because it just seemed more prudent to only look for originals.
  • If a girl spawns with less than 3 traits, there is a small chance to discover "hidden talents" as you put the girl to work in your brothel. This unknown trait can be any gold, positive or negative trait.
  • Due to these changes, if you pluck a random girl off the street to work in your brothel, there's now more uncertainty about her traits and future potential that could add something to the emerging narrative of your game.

Download: Mega / Mediafire

(click to show/hide)


New patch out, should fix free girl love behavior.

http://www.mediafire.com/file/7212hi0ygq54yc3/game+patch+0.14+experimental.zip

The current mod uses BK 0.14 + Janaury 26th BK 0.14 Experimental patch shown above (I've picked a bad time to release this with all the 0.15 patches incoming), but I've done my best to add a "Trait King" comment to every part of the girlclass.rpy & functions.rpy code that has been modified, so you could copy over those modifications to whatever you're running.

Please let me know how to improve this mod. Not just content-wise, but also with how it's coded. Although the mod seems to run without errors (as far as I know), I've probably made a lot of rookie errors. I want to make sure I'm not needlessly slowing the game down! Also, how can I constrain the code to its own .rpy file as much as possible? Should I be trying to import certain functions to that file? I have no idea what I'm doing!

___________________

For future development:

Ideas for Trait King (these are fairly simple, probably doable even by a novice like me)
  • Make the potential stat & the trait-types she has (gold, pos, neg) impact a girl's market value - Added in v0.12
  • Add a value "effect" so that specific traits can directly impact a girl's market value - Added in v0.13
  • Make potential and maybe other stats deteriorate long-term (very slowly, in game it should feel like the girl is growing older and/or getting jaded)
  • Add more things/traits besides the "hidden talents" that can randomly pop up during gameplay (Maybe some sort of imaginary diseases? Maybe temporary buffs like "passions"?)
  • Add random events that positively or negatively impact a girl's potential
  • Add random events that are tied to having certain traits

Other/bigger ideas (Some of these may be beyond my abilities, or will take me a long time)
  • Add quests to the game world where merchants want to purchase girls with certain specific skills from you (like in Jack-O-Nine-Tails)
  • Add events where extremely satisfied high-rank customers sometimes want to purchase the girls they've been with at a premium
  • Overhaul girl/room inspection. (I want it to include more of the girl's personality, and I'd also like an inspection to be more like a narrated version of the stats screen)
  • Promote max-rank girls to become coaches in your brothel with random buffs.
  • Add rare random events that can introduce new girls to your brothel
  • Add an end-of-week summary screen that shows a list of your girls sorted by performance/earnings over the past week, highlighting the best girl
  • Overhaul the GUI and optimise it for a 1920x1080 resolution
« Last Edit: March 20, 2019, 02:18:40 pm by _neronero »
Logged

Goldo

  • Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 643
    • View Profile
Re: Trait King Mod
« Reply #1 on: March 15, 2019, 09:51:02 pm »

Thanks! If your release is stable (I'll wait until enough people have tested it), I can add the necessary 'hooks' in the vanilla game files to make it work as a mod.

As you guessed, the modding system is focused on adding events/stories, but most of the game mechanics are hard-coded.
Logged

_neronero

  • Newbie
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Trait King Mod
« Reply #2 on: March 16, 2019, 02:28:45 pm »

I think I should be able to use custom_scale in the modfile .rpy, but I can't get it to work so far.

In the current version of the mod I'm defining "potential" under get_scale_factor in BKfunctions.rpy, so that i can use it in exactly the same way as something like rank
Code: Python
  1.         elif scales_with == "potential": # Trait King: scaling with potential
  2.             factor = thing.potential
  3.         elif scales_with == custom_scale[0]: # Custom scale
  4.             factor = custom_scale[1]
  5.  

I've been trying to structure the trait definitions in various ways to instead use custom_scale, but I keep getting errors.
I have a feeling it should look something like this; and the game runs without exceptions like this, but all the potential-scaling effects are at a constant +10%, or +10, even if (like in the example below) the factor is something like 0.03.
Code: Python
  1. Trait("Name", verb="verb", eff1=Effect("effect", "target", 0.03, scales_with = custom_scale[0], custom_scale=("unlocked potential", potential)))


Edit:

I've got the market value additions working in my test build, just need to add the exact values to the traits list. Already very happy with this addition, it will make girls with gold traits feel much more special since you won't even be able to afford them in the early game. This was a needed change since it incentivised picking up free girls, even though their traits are unpredictable.

Also I made a mistake with the "Depressed" trait that will throw up an exception. I'll try to get a new build that fixes it out soon.
« Last Edit: March 16, 2019, 10:13:13 pm by _neronero »
Logged

Dragonblood

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1400
  • Code monkey
    • View Profile
Re: Trait King Mod
« Reply #3 on: March 17, 2019, 05:57:06 am »

I can see 2 potential (pun unintended) problems with how you are trying to use custom_scale. Firstly, you are feeding a value (the girl's "potential") into the "custom_scale" tuple when the effect is generated, and I don't think it would then be updated whenever the girl is changed (i.e., the effect is looking at the girl's potential at the time the effect was added, and not at the time the effect is being evaluated; this could be a problem if the effect is persistent, like in a trait). Additionally, even if it would work correctly when used in a trait definition, you aren't creating the tuple correctly. You are setting "scales_with" to an array containing only a zero, and then creating a separate tuple variable on the trait named custom_scale.

Try changing that trait definition to the following to see if it works any better:
Code: [Select]
Trait("Name", verb="verb", eff1=Effect("effect", "target", 0.03, scales_with = custom_scale("unlocked potential", potential)))

(Note: You'll probably still have issues with the effect not scaling correctly with potential as potential changes, but it should at least work correctly initially.)
Logged

_neronero

  • Newbie
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Trait King Mod
« Reply #4 on: March 17, 2019, 08:25:47 am »

Ok, so the first problem I had was that "custom_scale" and "potential" are not even defined yet at the point where the mod's script is loaded. And when I tried it with definitions for them at the beginning of the mod I got this error:
Code: [Select]
TypeError: 'tuple' object is not callable
I'll just forget about custom_scale for now, since I do need the value to be updated constantly anyway. Thanks for your help  ;D

I updated the mod to v0.12
(click to show/hide)
« Last Edit: March 17, 2019, 11:27:37 am by _neronero »
Logged

Dragonblood

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1400
  • Code monkey
    • View Profile
Re: Trait King Mod
« Reply #5 on: March 17, 2019, 04:33:42 pm »

Actually, now that I think about it, it would probably be easier to just make it so that all effects on a girl are modified by her potential, and handle that through the girl class's get_effect function.

The main issue with doing it that way would be that you could not affect most chance-based things (e.g. pickpocket, item drop, critical fail reroll, etc.).


...actually, you could probably just have an effect on the girl which gets removed and reapplied each day which acts as a modifier to the other effects. (For an example of how to remove an effect, look at the "use_item" function on the Main class in BKClasses; the line that starts with "calendar" is to remove the effect after a few days.) That might require a new effect type or two for the base game, but it would be a lot simpler and would have other potential uses as well.
Logged

_neronero

  • Newbie
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Trait King Mod
« Reply #6 on: March 17, 2019, 06:05:51 pm »

I'll have to think about that one. It does make a lot of sense and would automatically make sure that perks stay equally powerful to traits.

When I think of it as a daily refreshing effect instead of "innate talent", maybe it should also be tied to mood or certain milestones (eg: Girl got rid of a negative fixation, she's now inspired! +50% to all positive effects for 1 week)

Edit: After staring at the code for a while, I think it could be added in like this under get_effect (I commented out the code that already exists in its context)

Code: Python
  1.             #### APPLIES SCALING EFFECTS ####
  2.            
  3. #            if effect.scales_with:
  4. #                if effect.source: # This is used for scoped effects to track the original source and scale accordingly
  5. #                    factor = get_scale_factor(effect.source, effect.scales_with, custom_scale=custom_scale)
  6. #                else:
  7. #                    factor = get_scale_factor(thing, effect.scales_with, custom_scale=custom_scale)
  8.              elif thing in MC.girls or thing in farm.girls:
  9.                  factor = thing.potential
  10. #            else:
  11. #                factor = 1

It has the added benefit that you won't be able to tell what the girl's potential is in the slavemarket.
I'll also try adding it a bit later on instead; there (effect.value * factor) is used to calculate the final value. That way the integer that rolls out can become a bit more precise.

I think adding an effect type might be a bit too much of a challenge for me, but I'll keep fiddling with it.
« Last Edit: March 17, 2019, 10:04:29 pm by _neronero »
Logged

Goldo

  • Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 643
    • View Profile
Re: Trait King Mod
« Reply #7 on: March 18, 2019, 08:19:05 pm »

The main issue with doing it that way would be that you could not affect most chance-based things (e.g. pickpocket, item drop, critical fail reroll, etc.).

...actually, you could probably just have an effect on the girl which gets removed and reapplied each day which acts as a modifier to the other effects. (For an example of how to remove an effect, look at the "use_item" function on the Main class in BKClasses; the line that starts with "calendar" is to remove the effect after a few days.) That might require a new effect type or two for the base game, but it would be a lot simpler and would have other potential uses as well.

Sorry I haven't had time to read the whole thread so I might be off-topic, but I think this is what you're looking for:
Code: [Select]
"Tempting Fate" : Perk(name="Tempting Fate", type="level", perk_level=2, archetype="The Fox", effects=[Effect("special", "effect chance", 1)], pic = "fox2_2.jpg"),
Code: [Select]
Effect("special", "effect chance", 1) increases the chance for effects to proc by 100% (doubles it).

I bare no responsibility for OP multipliers or infinite loops created stacking the Tempting Fate perk with those (although hopefully, I wrote in a check in get_effect so that it doesn't happen)
Logged

Goldo

  • Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 643
    • View Profile
Re: Trait King Mod
« Reply #8 on: March 18, 2019, 08:28:45 pm »

Ok, so the first problem I had was that "custom_scale" and "potential" are not even defined yet at the point where the mod's script is loaded. And when I tried it with definitions for them at the beginning of the mod I got this error:
Code: [Select]
TypeError: 'tuple' object is not callable
I'll just forget about custom_scale for now, since I do need the value to be updated constantly anyway. Thanks for your help  ;D

The way to go would be to
I think I should be able to use custom_scale in the modfile .rpy, but I can't get it to work so far.

In the current version of the mod I'm defining "potential" under get_scale_factor in BKfunctions.rpy, so that i can use it in exactly the same way as something like rank
Code: Python
  1.         elif scales_with == "potential": # Trait King: scaling with potential
  2.             factor = thing.potential
  3.         elif scales_with == custom_scale[0]: # Custom scale
  4.             factor = custom_scale[1]
  5.  

I've been trying to structure the trait definitions in various ways to instead use custom_scale, but I keep getting errors.
I have a feeling it should look something like this; and the game runs without exceptions like this, but all the potential-scaling effects are at a constant +10%, or +10, even if (like in the example below) the factor is something like 0.03.
Code: Python
  1. Trait("Name", verb="verb", eff1=Effect("effect", "target", 0.03, scales_with = custom_scale[0], custom_scale=("unlocked potential", potential)))


Edit:

I've got the market value additions working in my test build, just need to add the exact values to the traits list. Already very happy with this addition, it will make girls with gold traits feel much more special since you won't even be able to afford them in the early game. This was a needed change since it incentivised picking up free girls, even though their traits are unpredictable.

Also I made a mistake with the "Depressed" trait that will throw up an exception. I'll try to get a new build that fixes it out soon.


Your problem is easy to fix:
Code: Python
  1. Trait("Name", verb="verb", eff1=Effect("effect", "target", 0.03, scales_with = "potential"))

This is fine:
Code: Python
  1.         elif scales_with == "potential": # Trait King: scaling with potential
  2.             factor = thing.potential
  3.         elif scales_with == custom_scale[0]: # Custom scale
  4.             factor = custom_scale[1]
  5.  
Logged

_neronero

  • Newbie
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Trait King Mod
« Reply #9 on: March 19, 2019, 09:57:13 pm »

Yeah, I was thinking maybe I wouldn't need to define potential as a seperate scale if I could use custom_scale, but you're right, the current way works fine. Just looking for ways to clean up the code. Speaking of which, adding a modifier straight into get_effects is working really well so far ;D so I think I'll move further in that direction.
 
Sorry I haven't had time to read the whole thread so I might be off-topic, but I think this is what you're looking for:
Code: [Select]
"Tempting Fate" : Perk(name="Tempting Fate", type="level", perk_level=2, archetype="The Fox", effects=[Effect("special", "effect chance", 1)], pic = "fox2_2.jpg"),
Code: [Select]
Effect("special", "effect chance", 1) increases the chance for effects to proc by 100% (doubles it).

I bare no responsibility for OP multipliers or infinite loops created stacking the Tempting Fate perk with those (although hopefully, I wrote in a check in get_effect so that it doesn't happen)
Ooooh that's very nice! I have one question about this. In the following piece of code, can you explain what exactly "iterate = iterate" means? Does that just say "use whatever number you find here"?
Code: Python
  1.             if target != "effect chance": # Applies boost to effect chance if there is one
  2.                 chance *= (1 + get_effect(thing, "special", "effect chance", iterate=iterate))
Logged

_neronero

  • Newbie
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Trait King Mod
« Reply #10 on: March 20, 2019, 02:21:17 pm »

Updated to v0.13:
- Added girl valuation trait effects, so for example, a girl who has a trait such as "Noble" is now priced like a noble.
- Potential now no longer scales seperate abilities, but it's used as a variable in an "effect modifier" that scales all effects from a girl in general. That means perks will also scale alongside traits.
- Mood is also a factor in this effect modifier
- Potential is no longer visible in the slavemarket.
- Added a UI element next to "Traits" in the bottom left corner (only visible when you've bought a girl) that gives you some insight into the effect modifier, with an exact value when you mouse over it.
- Added "Scroll of Appraisal" item that temporarily boost a girl's sell-price (Mainly for testing purposes, probably not worth purchasing at the moment unless you want to sell a very valuable girl)


Example of the UI addition (the icon changes when the modifier becomes extremely negative or positive)




Edit: Found a bug where every ~15 minutes of play, the game forces itself to reload all scripts and also resets settings, which automatically turns the mod off. There's no error message to speak of so I'm not sure where to search for answers. Does it indicate some sort of memory leak?
« Last Edit: March 20, 2019, 06:07:09 pm by _neronero »
Logged

Goldo

  • Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 643
    • View Profile
Re: Trait King Mod
« Reply #11 on: March 20, 2019, 09:53:39 pm »

I have one question about this. In the following piece of code, can you explain what exactly "iterate = iterate" means? Does that just say "use whatever number you find here"?
Code: Python
  1.             if target != "effect chance": # Applies boost to effect chance if there is one
  2.                 chance *= (1 + get_effect(thing, "special", "effect chance", iterate=iterate))

I'd have to look at the code in detail (not right now), but I'm guessing this is the safety check to avoid an infinite loop.

Edit: Found a bug where every ~15 minutes of play, the game forces itself to reload all scripts and also resets settings, which automatically turns the mod off. There's no error message to speak of so I'm not sure where to search for answers. Does it indicate some sort of memory leak?

Wow, I've never heard anything like that. Is it linked to a specific game event? Or is it just related to time spent in game?

I've noticed game preferences do not always save, seemingly at random, but the behavior you describe is extremely strange.
« Last Edit: March 20, 2019, 09:56:51 pm by Goldo »
Logged

_neronero

  • Newbie
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Trait King Mod
« Reply #12 on: March 21, 2019, 07:31:36 am »

It happened three times so far, usually while I was interacting with the UI in some way (hovering over answers in a menu for example) I know that's a very broad description, but from what I've seen so far it can happen when you're in the middle of a story event or when you're interacting with your girls in the brothel.

I suspect it will have something to do with the UI element I introduced right next to traits.
In log.txt I found this error, not sure if it's related but ProportionalScale is used on the effectsmodifier images so I suspect I'll need to fix something there.
Code: [Select]
AttributeError: 'StoreModule' object has no attribute 'ProportionalScale'
Loading persistent.

I do get this error right after the forced script-reload, but I suspect that just has to do with the mod suddenly being turned off on reload.
Quote
Full traceback:
  File "game/BKmain.rpy", line 839, in script
    $ game.update_mods()
  File "F:\ilx\BK14B\renpy\ast.py", line 862, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "F:\ilx\BK14B\renpy\python.py", line 1912, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/BKmain.rpy", line 839, in <module>
    $ game.update_mods()
  File "game/BKclasses.rpy", line 104, in update_mods
    elif mod.check_for_updates():
  File "game/BKclasses.rpy", line 5057, in check_for_updates
    if self.get_check() != persistent.mods[self.name]["check"]:
KeyError: u'Trait King'
Logged

Goldo

  • Moderator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 643
    • View Profile
Re: Trait King Mod
« Reply #13 on: March 22, 2019, 12:17:42 am »

Ok, you're definitely onto something.

I suspect it will have something to do with the UI element I introduced right next to traits.
In log.txt I found this error, not sure if it's related but ProportionalScale is used on the effectsmodifier images so I suspect I'll need to fix something there.
Code: [Select]
AttributeError: 'StoreModule' object has no attribute 'ProportionalScale'
Loading persistent.

This problem caused me lots of heartache when building the CG galleries: Whenever a picture that has been scaled is saved to a persistent variable, it breaks the persistent variable (including mods). You can read about it here: https://lemmasoft.renai.us/forums/viewtopic.php?f=8&t=50335

Now, this could come from your changes (are you saving any picture or an Object which has pictures as a persistent variable?), but it's just as likely that it comes from a lingering bug within the vanilla game.

I am extremely keen to get rid of this problem once and for all. Any additional information you can provide I'd be interested to get.
 
Logged

_neronero

  • Newbie
  • *
  • Offline Offline
  • Posts: 10
    • View Profile
Re: Trait King Mod
« Reply #14 on: March 23, 2019, 02:27:04 pm »

This problem caused me lots of heartache when building the CG galleries: Whenever a picture that has been scaled is saved to a persistent variable, it breaks the persistent variable (including mods). You can read about it here: https://lemmasoft.renai.us/forums/viewtopic.php?f=8&t=50335

Now, this could come from your changes (are you saving any picture or an Object which has pictures as a persistent variable?), but it's just as likely that it comes from a lingering bug within the vanilla game.

I am extremely keen to get rid of this problem once and for all. Any additional information you can provide I'd be interested to get.
I don't know why exactly, but I have not encountered the problem anymore. Maybe it was caused by some other small error in my code that I fixed without connecting the dots. For the ProportionalScale elements I mostly just copied and modified the code that is used for mood (get_mood_picture and get_mood_details)
I'll keep you updated if I ever encounter the same problem again.

In other news, I've encountered a pretty game ruining bug with buffing get_effects that will be fixed in a next version.
Preference increases and decreases & obedience targets also make use of get_effects and thus scale with potential and mood. The end result of this is that most girls as they grow dig themselves into a hole and become extremely reluctant to do any sex act.
Logged
Pages: [1]   Go Up
 


SimplePortal 2.3.3 © 2008-2010, SimplePortal