Custom Map Encounters

Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

This script allows you to customize random encounters on your maps during the game.

For example, initially there might be slime and rats wandering around the map, but after certain events take place in the game, the rats disappear and there will only be slime left.

To accomplish this, you would start with slime and rats as possible random encounters, but then afterwards you would remove the rat encounter from the list.

Download

Script: download here

Installation

In the script editor, place this script below Materials and above Main

Usage

Encounter ID

You will need to understand the concept of an “encounter ID”. This is basically a number or a name that you give to your encounters.

By default, this script uses numbers to assign ID’s. The encounters that you have assigned to the map in the editor are the
default encounters, and they are given ID’s based on the order they appear on the list. The first encounter is ID 1, the second is ID 2, and so on.

customMapEncounters1

Custom encounters are encounters that you add during the game via script calls. You can give them any ID you want. For example, if you have an encounter with two slimes, you can literally call it “two slimes”.

The purpose of the encounter ID is to make it easier for you to reference the encounter later on such as if you wanted to delete it.

Adding Encounters

To create an encounter, make the script call

add_encounter(enc_id, troop_id, weight)
add_encounter(enc_id, troop_id, weight, regions)
add_encounter(enc_id, troop_id, weight, regions, map_id)

`enc_id` is the ID of the encounter.

`troop_id` is the ID of the troop that the player will battle if they run into this encounter

`weight` is the chance that this encounter will be selected, as a weighted probability. For example, if one troop has a weight of 20 and another troop has a weight of 40, then the chance of encounter troop one is 20/60, where 60 is the sum of all the weights.

`regions` is a list of regions that this encounter will appear in. You can limit the encounter to only appear in the regions. If the regions are omitted, then it assumes you can encounter them anywhere on the map.

`map_id` is the map you want to add this encounter to. If this is omitted, it assumes you are adding it to the current map

Removing Encounters

To remove an encounter, make the script call

remove_encounter(enc_id)
 remove_encounter(enc_id, map_id)

This will remove the encounter specified by your enc_id. If the map ID is omitted, it assumes you are removing the encounter from the current map.

Example

Suppose your map initially has no encounters. You then decide to add troop 1 as an encounter, appearing only in the swamp (region 1) with a weight of 50 Let’s give it the ID “swamp_monster”. You would make the script call

add_encounter("swamp_monster", 1, 50, [1])

If you want to remove this encounter, you can make the script call

remove_encounter("swamp_monster")

And you will not encounter it again in the swamp.

Let’s say you wanted to add troop 2 as an encounter, appearing anywhere, with a weight of 20. The idea here is that if you’re walking in the swamp, there is a higher chance of encountering troop 1. We’ll just give it an ID of 12 because it’s a random number that is not taken.

add_encounter(12, 2, 20)

Here, we omitted the regions because we don’t need it. Again, if you want to remove this encounter, you can use the script call

remove_encounter(12)
Help spread the word!Share on FacebookShare on TumblrTweet about this on TwitterShare on Google+Share on LinkedInShare on RedditFlattr the author

You may also like...

2 Responses

  1. Arsist says:

    Omg, why didn’t I notice this one?

Leave a Reply

Your email address will not be published.

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax