mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-16 01:11:28 +00:00
Add foreachmap.lua module 'colenemy', allow passing module name to findmaps.sh.
The 'colenemy' module searches for colored enemies in maps, excluding pal-21 liztroops. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@4056 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
14467dec24
commit
f64fdf3384
2 changed files with 116 additions and 2 deletions
102
polymer/eduke32/source/lunatic/util/colenemy.lua
Normal file
102
polymer/eduke32/source/lunatic/util/colenemy.lua
Normal file
|
@ -0,0 +1,102 @@
|
|||
|
||||
-- Search for enemies with nonzero pal.
|
||||
-- foreachmap module.
|
||||
|
||||
local build = require("build")
|
||||
local D = build.readdefs("../../names.h") or error("Need ../../names.h")
|
||||
|
||||
local assert = assert
|
||||
local print = print
|
||||
local string = require("string")
|
||||
|
||||
local io = require("io")
|
||||
|
||||
local function printf(fmt, ...)
|
||||
print(string.format(fmt, ...))
|
||||
end
|
||||
|
||||
|
||||
module(...)
|
||||
|
||||
|
||||
local ENEMY_NAME = {
|
||||
[D.BOSS1] = "BOSS1",
|
||||
[D.BOSS1STAYPUT] = "BOSS1STAYPUT",
|
||||
[D.BOSS2] = "BOSS2",
|
||||
[D.BOSS3] = "BOSS3",
|
||||
[D.BOSS4] = "BOSS4",
|
||||
[D.BOSS4STAYPUT] = "BOSS4STAYPUT",
|
||||
[D.COMMANDER] = "COMMANDER",
|
||||
[D.COMMANDERSTAYPUT] = "COMMANDERSTAYPUT",
|
||||
[D.DRONE] = "DRONE",
|
||||
[D.GREENSLIME] = "GREENSLIME",
|
||||
[D.LIZMAN] = "LIZMAN",
|
||||
[D.LIZMANFEEDING] = "LIZMANFEEDING",
|
||||
[D.LIZMANJUMP] = "LIZMANJUMP",
|
||||
[D.LIZMANSPITTING] = "LIZMANSPITTING",
|
||||
[D.LIZMANSTAYPUT] = "LIZMANSTAYPUT",
|
||||
[D.LIZTROOP] = "LIZTROOP",
|
||||
[D.LIZTROOPDUCKING] = "LIZTROOPDUCKING",
|
||||
[D.LIZTROOPJETPACK] = "LIZTROOPJETPACK",
|
||||
[D.LIZTROOPJUSTSIT] = "LIZTROOPJUSTSIT",
|
||||
[D.LIZTROOPONTOILET] = "LIZTROOPONTOILET",
|
||||
[D.LIZTROOPRUNNING] = "LIZTROOPRUNNING",
|
||||
[D.LIZTROOPSHOOT] = "LIZTROOPSHOOT",
|
||||
[D.LIZTROOPSTAYPUT] = "LIZTROOPSTAYPUT",
|
||||
[D.OCTABRAIN] = "OCTABRAIN",
|
||||
[D.OCTABRAINSTAYPUT] = "OCTABRAINSTAYPUT",
|
||||
[D.ORGANTIC] = "ORGANTIC",
|
||||
[D.PIGCOP] = "PIGCOP",
|
||||
[D.PIGCOPDIVE] = "PIGCOPDIVE",
|
||||
[D.PIGCOPSTAYPUT] = "PIGCOPSTAYPUT",
|
||||
[D.RAT] = "RAT",
|
||||
[D.ROTATEGUN] = "ROTATEGUN",
|
||||
[D.SHARK] = "SHARK",
|
||||
}
|
||||
|
||||
local uniq = false
|
||||
|
||||
function init(args)
|
||||
if (#args == 1) then
|
||||
local wr = function(s) io.stderr:write(s) end
|
||||
wr("Usage: "..args[0].." "..args[1].." [-u] *.map ...\n")
|
||||
wr(" -u: print only one pal-x-tilenum combination\n")
|
||||
end
|
||||
|
||||
if (args[2]:sub(1,1)=="-") then
|
||||
assert(args[2]=="-u", "Unknown option "..args[2])
|
||||
uniq = true
|
||||
return 3
|
||||
end
|
||||
end
|
||||
|
||||
function success(map, fn)
|
||||
-- Have one at all?
|
||||
local haveone = false
|
||||
|
||||
-- Have pal-x-tile combination?
|
||||
-- [tile*256 + pal] = true
|
||||
local havept = {}
|
||||
|
||||
for i=0,map.numsprites-1 do
|
||||
local spr = map.sprite[i]
|
||||
local picnum, pal = spr.picnum, spr.pal
|
||||
local name = ENEMY_NAME[picnum]
|
||||
|
||||
if (name and pal~=0) then
|
||||
if (not (name:match("^LIZTROOP") and pal==21)) then -- those are handled by CON
|
||||
if (not uniq or not havept[picnum*256 + pal]) then
|
||||
if (not haveone) then
|
||||
printf("%s:", fn)
|
||||
haveone = true
|
||||
end
|
||||
printf("%5d %3d %s", i, pal, name)
|
||||
havept[picnum*256 + pal] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if (haveone) then
|
||||
print("")
|
||||
end
|
||||
end
|
|
@ -9,7 +9,7 @@ if [ -z "$2" ]; then
|
|||
fi
|
||||
|
||||
if [ -z "$ok" ]; then
|
||||
echo "Usage: $0 <dir> <code for foreachmap.lua -e>"
|
||||
echo "Usage: $0 <dir> <some_foreachmap_module.lua | code for foreachmap.lua -e>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -19,4 +19,16 @@ if [ "$idx" != 0 ]; then
|
|||
LOPT=
|
||||
fi
|
||||
|
||||
find $LOPT "$1" -iname '*.map' -print0 | xargs -0 ./foreachmap.lua "-e$2"
|
||||
FN="$1"
|
||||
ARG="$2"
|
||||
|
||||
idx=$(expr match "$ARG" '.*lua$')
|
||||
if [ "$idx" == 0 ]; then
|
||||
ARG="-e$ARG"
|
||||
find $LOPT "$FN" -iname '*.map' -print0 | xargs -0 ./foreachmap.lua "$ARG"
|
||||
else
|
||||
shift
|
||||
# So that you can e.g. do
|
||||
# ./findmaps.sh ~/.eduke32 ./colenemy.lua -u
|
||||
find $LOPT "$FN" -iname '*.map' -print0 | xargs -0 ./foreachmap.lua "$@"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue