Random Events?
Moderator: Forum Moderators
Forum rules
- Please use [code] BBCode tags in your posts for embedding WML snippets.
- To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Random Events?
Does anyone know if there's a way of making use of the random number generator in your scenario to make certain events happen randomly?
Quite simple actualy
#define RANDOM_EVENT_1
[event]
<my event>
[/event]
#enddef
#define RANDOM_EVENT_2
[event]
<my event 2>
[/event]
#enddef
[event]
name=new turn
first_time_only=no
{RANDOM 1..<number of events>}
[if]
[variable]
name=random
equals=1
[/variable]
[then]
{RANDOM_EVENT_1}
[/then]
[/if]
[if]
[variable]
name=random
equals=2
[/variable]
[then]
{RANDOM_EVENT_2}
[/then]
[/if]
[/event]
That sets up two events to be performed randomly from turn two onwards. I'm quite sure you'll know how to expand it to your needs.
#define RANDOM_EVENT_1
[event]
<my event>
[/event]
#enddef
#define RANDOM_EVENT_2
[event]
<my event 2>
[/event]
#enddef
[event]
name=new turn
first_time_only=no
{RANDOM 1..<number of events>}
[if]
[variable]
name=random
equals=1
[/variable]
[then]
{RANDOM_EVENT_1}
[/then]
[/if]
[if]
[variable]
name=random
equals=2
[/variable]
[then]
{RANDOM_EVENT_2}
[/then]
[/if]
[/event]
That sets up two events to be performed randomly from turn two onwards. I'm quite sure you'll know how to expand it to your needs.
Somewhere, between the sacred silence and sleep.
Disorder.
Disorder.
Sweet thanks... So can you set the probability for each random event?
The plan behind it is that I'm working on a modification to A New Land and one of the things I changed is that forests are really valuable... So the beginning of the game is a rush to get the forests with some skirmishing... Only I didn't want the map to just instantly get cleared of trees so I was hoping to set up the scenario so that in the woods farther from peoples starting base there was a chance that wild woses would appear and attack the peasants trying to harvest the trees.
The plan behind it is that I'm working on a modification to A New Land and one of the things I changed is that forests are really valuable... So the beginning of the game is a rush to get the forests with some skirmishing... Only I didn't want the map to just instantly get cleared of trees so I was hoping to set up the scenario so that in the woods farther from peoples starting base there was a chance that wild woses would appear and attack the peasants trying to harvest the trees.
Thanks! You rock!
Oh and another question related to the same problem scenariowise but not WMLwise... About filters... I was reading on the Wiki and it's dreadfully unclear... Even to me and I'm a developer by trade... When a filter test is passed where does the next line execute and if it fails where?
Oh and another question related to the same problem scenariowise but not WMLwise... About filters... I was reading on the Wiki and it's dreadfully unclear... Even to me and I'm a developer by trade... When a filter test is passed where does the next line execute and if it fails where?
This basicaly works as elaborate and pretty fast [if]. If filter is passed for a given object (event, terrain tile, unit) the code the filter is embeded in is executed, if not that code is skipped altogether. Two quick examples :
[event]
[filter]
reads as
#if
[filter]
#then
[event]
#else
[null]
-------
[store_unit]
[filter]
reads as
#if
[filter]
#then
[store unit]
#else
[null]
[event]
[filter]
reads as
#if
[filter]
#then
[event]
#else
[null]
-------
[store_unit]
[filter]
reads as
#if
[filter]
#then
[store unit]
#else
[null]
Somewhere, between the sacred silence and sleep.
Disorder.
Disorder.
random really means random for everyone?
using the original code, wouldn't it have different possibilities for every in the game? so if lets say player 1 was to have x happen, couldn't the game logic say y happened instead for player 2, and so on...?
Well, I kinda got that in the sticky on the top of the forum, but I'm curious because I would like to utilize that code to make is so that "random battles" can occur like in a platform rpg. So far, I am putting in battles that will occur when someone lands on a space (only once).
Well, I kinda got that in the sticky on the top of the forum, but I'm curious because I would like to utilize that code to make is so that "random battles" can occur like in a platform rpg. So far, I am putting in battles that will occur when someone lands on a space (only once).