|
|
|
|
Reply From: |
Bartosz |
To make encounters random proceed like with all random stuff e.g. use pseudorandom number generator (PRNG) e.g. randi()
To have some probability in encounter creation check if randi() % 100 < chance_in_percents
is true, if it is, use below solution to generate random encounter.
you can use dictionaries as base of rolling out some encounters:
var encounter = {
"encounter_type": [ "Battle with", "Quest from"],
"encounter_person": [ "Bandit", "Dragon", "Knight", "Rat", "Talking Sword" ],
"encounter_person_kind": [ "drunk", "poor", "hungry", "bald", "old" ],
"encounter_reason": [ "wrong place wrong type", "you looked tasty", "you're not batman", "that's the way thinks work around here" ]
}
then you can use function similar to this one to generate new encounter
func roll(something):
var result = {}
for k in something.keys():
var values = something[k]
result[k] = values[randi() % values.size()]
return result
here working demo containing above code in my godot-recipes
project
To make it “continual” either measure distance player travels through area and after do “chance-check” in predefined intervals. Alternatively split areas in to multiple smaller - more areas will be the more continuous effect.
Man, I ask for a pebble, you give a gem… May you receive the same in your all your requests!
when you finish your game remember to mention in credits really helpful godot community XD
Bartosz | 2018-03-26 22:11
Sure, with special mention for Bartosz!