Page 1 of 1
Autoplace entities and map
Posted: Sat Nov 02, 2013 11:52 am
by Dysoch
I noticed the problem with f-mod (small scale) and now with my own mod.
I added a rubber tree. Placed ingame by the autoplace group forest. But they show up as red dots on the minimap. Its quite annoying because the autoplace adds alot of them. So the map is quite filled with red dots, and thus not showing correctly if they ar enemys.
screen:
How to change this?
Re: Autoplace entities and map
Posted: Sat Nov 02, 2013 12:06 pm
by ssilk
Naive answer: the trees are shown as enemy, because they are enemies?
Re: Autoplace entities and map
Posted: Sat Nov 02, 2013 12:34 pm
by Dysoch
Code: Select all
data:extend(
{
{
type = "container",
inventory_size = 1,
name = "rubber-tree",
icon = "__base__/graphics/icons/dry-tree.png",
flags = {"placeable-neutral", "placeable-off-grid", "breaths-air"},
emissions_per_tick = -0.0010,
minable = {
mining_particle = "wooden-particle",
mining_time = 1,
result = "raw-wood",
count = 1,
},
max_health = 10,
collision_box = {{-0.7, -0.8}, {0.7, 0.8}},
selection_box = {{-0.8, -2.2}, {0.8, 0.8}},
drawing_box = {{-0.8, -2.8}, {0.8, 0.8}},
picture ={
filename = "__DyTech__/graphics/entity/rubber-tree/big-tree-01.png",
priority = "extra-high",
width = 155,
height = 118,
shift = {1.1, -1}
},
autoplace =
{
sharpness = 0.5,
control = "forest",
peaks =
{
{
influence = 0.2,
water_optimal = 0.3,
water_range = 0.2,
water_max_range = 0.4
},
{
influence = 0.9,
noise_layer = "trees",
noise_persistence = 0.5,
}
}
}
},
}
)
this it the entity code. i cant change it to tree, because then it wont load.
and its flagged as neutral
Re: Autoplace entities and map
Posted: Sat Nov 02, 2013 1:15 pm
by rk84
I believe "placeable-neutral" -flag is used just for map editor. So it is listed in neutral entity list.
Dysoch wrote:I cant change it to tree, because then it wont load.

Re: Autoplace entities and map
Posted: Sat Nov 02, 2013 4:07 pm
by FreeER
rk84 wrote:I believe "placeable-neutral" -flag is used just for map editor. So it is listed in neutral entity list.
This is correct
Dysoch wrote:I cant change it to tree, because then it wont load.
Why won't it load? I know trees have a 'pictures' rather than 'picture' field but...
As to the initial question, perhaps try adding map_color = {r=0, g=0, b=0} or making sure that you didn't give it a map_color somehow elsewhere...
Re: Autoplace entities and map
Posted: Sat Nov 02, 2013 6:59 pm
by drs9999
I am not sure if this still exist, but if you use game.createentity in previous versions and do not specify the force the default is enemy, maybe the same happens here when they are autoplaced. So the red color on the map is correct, because actually this trees are your enemy

Re: Autoplace entities and map
Posted: Sat Nov 02, 2013 7:37 pm
by FreeER
drs9999 wrote:I am not sure if this still exist, but if you use game.createentity in previous versions and do not specify the force the default is enemy, maybe the same happens here when they are autoplaced. So the red color on the map is correct, because actually this trees are your enemy

Yes this still exists. Easy test is to hover over tree and use "game.player.print(game.player.selected.force.name)", though it seems unlikely that autoplace would create entities as enemy (especially for the forest control...).
Would be interesting to have trees that are actually your enemy though (like creating vines to trap you when you get too close or something) lol
edit: just tested and no the force is still neutral, but every tree has turned red...not just the rubber trees lol
edit2: well, the rubber trees are enemy force but every tree has turned red on mine lol (and all regular trees are still neutral)
edit3:
SOLVED change the type to tree and the picture node to pictures (surround the picture data inside of another table) and it works as expected, though using the tree-a01 image the selection/collision boxes are off. lol Wonder why containers are assumed to be enemies? And why it made every tree (including neutral) red for me... Devs?
Code: Select all
data:extend(
{
{
type = "tree",
inventory_size = 1,
name = "rubber-tree",
icon = "__base__/graphics/icons/dry-tree.png",
flags = {"placeable-neutral", "placeable-off-grid", "breaths-air"},
emissions_per_tick = -0.0010,
minable = {
mining_particle = "wooden-particle",
mining_time = 1,
result = "raw-wood",
count = 1,
},
max_health = 10,
collision_box = {{-0.7, -0.8}, {0.7, 0.8}},
selection_box = {{-0.8, -2.2}, {0.8, 0.8}},
drawing_box = {{-0.8, -2.8}, {0.8, 0.8}},
pictures = {
{
filename = "__base__/graphics/entity/tree/tree-a01.png",
priority = "extra-high",
width = 155,
height = 118,
shift = {1.1, -1}
}
},
autoplace =
{
sharpness = 0.5,
control = "forest",
peaks =
{
{
influence = 0.2,
water_optimal = 0.3,
water_range = 0.2,
water_max_range = 0.4
},
{
influence = 0.9,
noise_layer = "trees",
noise_persistence = 0.5,
}
}
}
},
}
)
Re: Autoplace entities and map
Posted: Sat Nov 02, 2013 8:04 pm
by ficolas
Maybe since containers dont naturally spawn as neutral entities, the game uses the red color.
But making all trees red doesnt fit with my theory.
But if you want to insert rubber into the tree, you cant if its entity type is tree, since it doesmt have inventory.
Re: Autoplace entities and map
Posted: Sat Nov 02, 2013 11:03 pm
by drs9999
ficolas wrote:Maybe since containers dont naturally spawn as neutral entities, the game uses the red color.
I think that too.
Anyway a (not that bad) workaround could be to use the tree-type, but if you harvest them you will get a different kind of wood. This can be processed into rubber.
Re: Autoplace entities and map
Posted: Sun Nov 03, 2013 12:20 am
by kovarex
drs9999 wrote:ficolas wrote:Maybe since containers dont naturally spawn as neutral entities, the game uses the red color.
I think that too.
Anyway a (not that bad) workaround could be to use the tree-type, but if you harvest them you will get a different kind of wood. This can be processed into rubber.
Exactly, just change the minable properties, this is the most natural way to do it.
To clear the speculations:
- Container is EntityWithOwner (unlike entity with force, it has the force of the owner, like furnace), this is to have the owner in logistic containers.
- The default force in autoplacer is enemy, but it isn't used when the entity type isn't based on EntityWithOwner or EntityWith force (resources/trees etc).
- The autoplacer should provide way to specify the force of the entity created, I added this to issues for 0.8
Re: Autoplace entities and map
Posted: Sun Nov 03, 2013 1:26 am
by Dysoch
Great kovarex, ill hold of until 0.8 for rubber trees. Have a few more things planned for my next update, so work enough.
Thx all for helping, appreciate it!
Re: Autoplace entities and map
Posted: Sun Dec 15, 2013 1:35 pm
by Dysoch
is it possible to add a random chance to the richness base of a resource?
something like this:
Code: Select all
autoplace =
{
control = "gemstones",
sharpness = 0,
richness_multiplier = 1000,
richness_base = math.random(32),
peaks = {
{
that way we never have the same amount of resources to small resource deposits.
(i dont want to make the multiplier higher, because then the deposit would have far to much

)
Re: Autoplace entities and map
Posted: Sun Dec 15, 2013 2:00 pm
by Dysoch
Code: Select all
autoplace =
{
control = "gemstones",
sharpness = 0,
richness_multiplier = math.random(1500),
richness_base = math.random(32),
peaks = {
this is what i use now, but i want to have it so that every resource tile placed is calculated differently. right now it calculates a number at the start of a map, and it sticks with that the entire map.
how to change this?
Re: Autoplace entities and map
Posted: Sun Dec 15, 2013 2:40 pm
by cube
Well ... in general you can't, but you can do something simillar.
Try to add a new peak that has zero influence, but nonzero richness_influence and a set noise_layer. This way you won't change how the deposits are placed, only change their richness. For every tile already containing a resource this will add (noise value) * richness_influence * richness_multiplier units of the resource.
Value of the noise has approximately gaussian distribution centered around zero and a range approximately from -1.5 to 1.5.
Code: Select all
autoplace =
{
control = "gemstones",
sharpness = 0,
richness_multiplier = 12345,
richness_base = 12345,
peaks = {
{
influence = 0,
richness_influence = 1.2,
noise_layer = "gemstones-richness"
}, --- ....
.... The autoplace mechanism is pretty strong,but tuning the parameters is hard. Good luck

Re: Autoplace entities and map
Posted: Sun Dec 15, 2013 3:08 pm
by Dysoch
cube wrote:Well ... in general you can't, but you can do something simillar.
Try to add a new peak that has zero influence, but nonzero richness_influence and a set noise_layer. This way you won't change how the deposits are placed, only change their richness. For every tile already containing a resource this will add (noise value) * richness_influence * richness_multiplier units of the resource.
Value of the noise has approximately gaussian distribution centered around zero and a range approximately from -1.5 to 1.5.
Code: Select all
autoplace =
{
control = "gemstones",
sharpness = 0,
richness_multiplier = 12345,
richness_base = 12345,
peaks = {
{
influence = 0,
richness_influence = 1.2,
noise_layer = "gemstones-richness"
}, --- ....
.... The autoplace mechanism is pretty strong,but tuning the parameters is hard. Good luck

hahaha thx.
im now getting some pretty awesome results

im getting everything between 100 and 100.000 randomly chosen

I LIKE IT!!!!
thx very much
edit: i tried this:
Code: Select all
{
control = "sand",
sharpness = 0.8,
richness_multiplier = math.random(75000),
richness_base = math.random(5000,15000),
peaks = {
{
influence = 0,
richness_influence = 1.2,
noise_layer = "random"
}, --rest
edit2: its just awesome to see a resource of 40.000 something and only a few meters away there is 1 with only 900

Re: Autoplace entities and map
Posted: Mon Dec 16, 2013 7:17 am
by kovarex
P.S. Using math.random in the prototype definition should be forbidden for obvious reasons (determinism->multiplayer + replays).
Re: Autoplace entities and map
Posted: Mon Dec 16, 2013 8:56 am
by Dysoch
kovarex wrote:P.S. Using math.random in the prototype definition should be forbidden for obvious reasons (determinism->multiplayer + replays).
well i think it adds a great function.
by never having the same amount in a deposit, the replay value of the game just went up (my opinion.)
what was around 40.000 sand in a deposit could now be 500 or 50.000, thus you having to adapt to the situation.
the same goes for multiplayer, you always have to adapt to the situation.
(this and i had to test for around 4-6 hours yesterday to get it right xD)
Re: Autoplace entities and map
Posted: Tue Dec 17, 2013 6:39 pm
by ficolas
Wont using math.random decide how deposits will be when loading the game?
Re: Autoplace entities and map
Posted: Tue Dec 17, 2013 8:29 pm
by Dysoch
ficolas wrote:Wont using math.random decide how deposits will be when loading the game?
True, but by adding another peak, you get completly random numbers everywhere. It calculates every resource differently, but keeps a chunk of resources near the same levels.