Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tales of MajEyal
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tome
Tales of MajEyal
Commits
832a6520
There was a problem fetching the pipeline summary.
Commit
832a6520
authored
5 years ago
by
DarkGod
Browse files
Options
Downloads
Patches
Plain Diff
plop
parent
8fa37de2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
game/engines/default/engine/generator/map/MapScript.lua
+1
-0
1 addition, 0 deletions
game/engines/default/engine/generator/map/MapScript.lua
game/engines/default/engine/tilemaps/Tilemap.lua
+25
-3
25 additions, 3 deletions
game/engines/default/engine/tilemaps/Tilemap.lua
with
26 additions
and
3 deletions
game/engines/default/engine/generator/map/MapScript.lua
+
1
−
0
View file @
832a6520
...
...
@@ -67,6 +67,7 @@ function _M:regenerate()
end
function
_M
:
redo
()
util
.
show_backtrace
()
self
.
force_redo
=
true
end
...
...
This diff is collapsed.
Click to expand it.
game/engines/default/engine/tilemaps/Tilemap.lua
+
25
−
3
View file @
832a6520
...
...
@@ -405,10 +405,14 @@ function _M:hasResult()
end
--- Locate a specific tile
function
_M
:
locateTile
(
char
,
erase
)
function
_M
:
locateTile
(
char
,
erase
,
min_x
,
min_y
,
max_x
,
max_y
)
local
res
=
{}
for
i
=
1
,
self
.
data_w
do
for
j
=
1
,
self
.
data_h
do
min_x
=
min_x
or
1
min_y
=
min_y
or
1
max_x
=
max_x
or
self
.
data_w
max_y
=
max_y
or
self
.
data_h
for
i
=
min_x
,
max_x
do
for
j
=
min_y
,
max_y
do
if
self
.
data
[
j
][
i
]
==
char
then
res
[
#
res
+
1
]
=
self
:
point
(
i
,
j
)
if
erase
then
self
.
data
[
j
][
i
]
=
erase
end
...
...
@@ -419,6 +423,22 @@ function _M:locateTile(char, erase)
return
rng
.
table
(
res
),
res
end
--- Find the number of the given tiles in the neighbourhood
function
_M
:
countNeighbours
(
where
,
kind
,
replace
)
if
type
(
kind
)
==
"table"
then
kind
=
table
.
reverse
(
kind
)
else
kind
=
{[
kind
]
=
true
}
end
local
pos
=
{}
for
i
=
-
1
,
1
do
for
j
=
-
1
,
1
do
if
i
~=
0
and
j
~=
0
then
local
p
=
where
+
self
:
point
(
i
,
j
)
local
c
=
self
:
get
(
p
)
if
c
and
kind
[
c
]
then
pos
[
#
pos
+
1
]
=
p
if
replace
then
self
:
put
(
p
,
replace
)
end
end
end
end
end
return
#
pos
,
pos
end
--- Finds a random location with enough area available
function
_M
:
findRandomArea
(
from
,
to
,
w
,
h
,
made_of
,
margin
,
tries
)
if
not
tries
then
tries
=
500
end
...
...
@@ -1467,6 +1487,7 @@ function _M:tunnelAStar(from, to, char, tunnel_through, tunnel_avoid, config)
local
score
=
1
if
config
.
weight_erraticness
>
0
then
score
=
score
+
rng
.
float
(
0
,
config
.
weight_erraticness
)
end
if
config
.
weights
[
nc
]
then
score
=
score
+
config
.
weights
[
nc
]
end
if
config
.
weights_fct
then
score
=
score
+
config
.
weights_fct
(
nx
,
ny
,
nc
)
end
if
self
.
tunnels_map
[
ny
][
nx
]
then
score
=
score
+
config
.
weight_tunnel
end
local
tent_g_score
=
g_score
[
node
]
+
score
-- we can adjust here for difficult passable terrain
local
tent_is_better
=
false
...
...
@@ -1494,6 +1515,7 @@ function _M:tunnelAStar(from, to, char, tunnel_through, tunnel_avoid, config)
if
node
==
stop
then
return
self
:
astarCreatePath
(
came_from
,
from
,
to
,
stop
,
id
,
char
,
config
,
tunnel_through
)
end
if
not
node
then
return
end
open
[
node
]
=
nil
closed
[
node
]
=
true
local
x
,
y
=
self
:
astarToDouble
(
node
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment