Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email [email protected]
It is currently Sat May 25, 2013 6:01 am

All times are UTC - 5 hours [ DST ]


Forum rules


Ask questions about one topic per thread, and use a descriptive subject. "NotImplemented error in script.rpy" is a good subject, "Tom's problems" is not. Remember to include all of traceback.txt or error.txt when reporting a problem, as well as the relevant lines of script. Use the [code] tag to format scripts.



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Mar 23, 2012 6:40 am 
Veteran
User avatar

Joined: Thu May 01, 2008 1:12 pm
Posts: 353
Location: Estonia
Projects: Winter, winter
I suddenly got this urge to try my hand at making a really casual RPG. The kind where instead of choosing attack or defend, combat resolves automatically and the game happily let's you know whether you were strong enough to overcome the challenge.

But now I ran into the question of random encounters. It would be easy to just list them and jump to a random one. But is there a way to code these up without manually assigning labels? Something like putting the encounters in an array and doing 'jump encounters[random()]'?


Top
 Profile Send private message  
 
PostPosted: Fri Mar 23, 2012 7:05 am 
Crawling Chaos
User avatar

Joined: Mon Feb 13, 2012 5:37 am
Posts: 1118
Location: Kimashi Tower, Japan
Completed: SMAR,AAA
Projects: DMC
There's many way to do. one example is
Code:
python:
    enemy_list = ["slime", "goblin", ....]
    if renpy.random.random() < 0.2: #the encounter rate is 20%
        renpy.jump(renpy.random.choice(enemy_list))

This is a code I'm using in my game

_________________


Top
 Profile Send private message  
 
PostPosted: Fri Mar 23, 2012 8:00 am 
Veteran
User avatar

Joined: Thu May 01, 2008 1:12 pm
Posts: 353
Location: Estonia
Projects: Winter, winter
nyaatrap wrote:
There's many way to do. one example is
Code:
python:
    enemy_list = ["slime", "goblin", ....]
    if renpy.random.random() < 0.2: #the encounter rate is 20%
        renpy.jump(renpy.random.choice(enemy_list))

This is a code I'm using in my game

That's the easiest way, so I'll go with that.

But I seem to have forgotten what the case was with local variables in Ren'py. If I want to be able to remove something from the list (a rare encounter that can only be visited once), how should I declare the enemy_list?


Top
 Profile Send private message  
 
PostPosted: Fri Mar 23, 2012 8:15 am 
Crawling Chaos
User avatar

Joined: Mon Feb 13, 2012 5:37 am
Posts: 1118
Location: Kimashi Tower, Japan
Completed: SMAR,AAA
Projects: DMC
This ;D
Code:
enemy_list.remove("rare_animal")

_________________


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group