Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

[harlowe] How to get random npc generation to apply certain rules?

I have hit yet another brick wall on my skills. This time, on random npc generation of love interests for the player.

A npc has more or less skills depending on age, and I don't know how to apply this condition to a random generation sheet.

In an ideal solution, it would generate always an opposite sex npc, a random race, and distribute a certain amount of points between the skills on their sheet.

I know what I'm asking is rather complicated and possibly can't be done, but I like forcing the limits.
(set: $sex to (either: "male", "female"), $race to (either: "human", "elf", "half elf", "half orc", "dwarf", "halfling", "gnome", "half ogre"), $Bartering to (random: 5,10), $Computers to (random: 0,10), $Construction to (random: 0,10), $Cooking to (random: 0,10), $Driving to (random: 0,10))

Comments

  • I don't understand what's wrong. Is this code not working? What's the problem?
  • I'm trying to make a passage that assigns some points, let's say 15, at random to these skills. No skill can go beyond 10, and the total points assigned can't go beyond 15.

    The code I pasted works just fine, but it's just an example. It can't auto-assign the points at npc generation.

    Sorry for the lack of explanation. My mind is burned at this point.
  • I don't understand. From the look of it it looks like it should work, and you just said it works. What do you mean by auto-assign at npc generation? And sorry if this feels like an interrogation; I just need to understand to help. Don't reply yet if you have no idea what to write. Maybe try tommorrow. :smile:
  • Have you ever played an RPG that had a "random" function at character creation? Like the one on Cataclysm Dark Days Ahead.

    You click on the "random" option, and it creates a random, ready to play character for you.
  • The following uses a (live:) macro to loop through a $pool of points until the pool is empty, it takes a random $amount of point from the pool and assigns that amount to a randomly selected $stat. Once the pool is empty it first uses a (replace:) macro to show the current values in a named hook and then uses a (stop:) macro to stop the looping.

    The following also uses both Collapsing whitespace markup and Escaped line break markup to reduce the number of blank lines showing in the resulting page which are caused by using extra line-breaks to make the code more readable.
    (link-repeat: "Randomize Stats")[{
    	(set: $Bartering to (random: 5,10),
    		$Computers to (random: 0,10),
    		$Construction to (random: 0,10),
    		$Cooking to (random: 0,10),
    		$Driving to (random: 0,10)
    	)
    	(set: $pool to 15)
    	(live: 10ms)[
    		(set: $amount to (random: 0, $pool))
    		(if: $amount > 0)[
    			(set: $stat to (random: 1, 5))
    			(if: $stat is 1)[
    				(set: $Bartering to it + $amount)
    			] (else-if: $stat is 2)[
    				(set: $Computers to it + $amount)
    			] (else-if: $stat is 3)[
    				(set: $Construction to it + $amount)
    			] (else-if: $stat is 4)[
    				(set: $Cooking to it + $amount)
    			] (else:)[
    				(set: $Driving to it + $amount)
    			]
    			(set: $pool to it - $amount)
    		]
    		(if: $pool <= 0)[
    			(replace: ?stats)[Bartering: $Bartering; Computers: $Computers; Construction: $Construction; Cooking: $Cooking; Driving: $Driving]
    			(stop:)
    		]
    	]
    }]\
    
    Current stats:
    |stats>[]
    
  • edited August 2016
    I'm sorry but I don't think I can help. If this isn't what you mean then I don't know what you mean:

    (link: "Random")[(set: $sex to (either: "male", "female"), $race to (either: "human", "elf", "half elf", "half orc", "dwarf", "halfling", "gnome", "half ogre"), $Bartering to (random: 5,10), $Computers to (random: 0,10), $Construction to (random: 0,10), $Cooking to (random: 0,10), $Driving to (random: 0,10)) ] That's just the code that you said worked but didn't work, but it runs when someone clicks the random button. Sorry if this sounds offensive. I'm just confused.
  • greyelf wrote: »

    Thank you! your answer worked like a charm, with one exception: I modified the first part of the code to set the skills at 0 instead of being random, because otherwise the total skill points were higher than the pool, and some skills even went further than 10.
    (set: $Bartering to 0,
    		$Computers to 0,
    		$Construction to 0,
    		$Cooking to 0,
    		$Driving to 0
    	)
    

  • Rafe wrote: »
    I'm trying to make a passage that assigns some points, let's say 15, at random to these skills. No skill can go beyond 10, and the total points assigned can't go beyond 15.

    The code I pasted works just fine, but it's just an example. It can't auto-assign the points at npc generation.

    Sorry for the lack of explanation. My mind is burned at this point.

    I really don't understand. What's wrong with the code that works but doesn't work? Surely just put that in a link macro or something and it would work. It randomly assigns skills to people?
Sign In or Register to comment.