add batch map conversion tools and more editing scripts

convmap is a toolset to convert hundreds of maps mostly automatically
to map format 10. Old media paths from akimbo and from before AC 1.2 are
automatically converted to AC 1.2 and akimbo2 paths.

The additional editing scripts mostly help with further optimisation of
existing maps (mainly to reduce the number of clipped entities).

If convmap is loaded after mapeditscripts, one additional conversion
stage is unlocked.
This commit is contained in:
ac-stef
2016-11-07 16:57:18 +01:00
parent 551a501546
commit c5065cddaa
4 changed files with 1677 additions and 1 deletions
+3
View File
@@ -700,6 +700,9 @@ menuitemcheckbox "Show mapmodel clippings: " "$showmodelclipping" [ showmodelcl
menuitemcheckbox "Show ladder entities: " "$showladderentities" [ showladderentities $arg1 ]
menuitemcheckbox "Show all playerstarts (spawn points): " "$showplayerstarts" [ showplayerstarts $arg1 ]
menuitemslider "Fly speeds multiplier: " 1 5 "$flyspeed" 1 [] [ flyspeed $arg1 ]
menuitem "" -1
menuitem "Load batch map conversion tools" load_convmap
menuitem "Load extra map editing scripts" load_mapeditscripts
// opt/autosave.cfg may add some entries
newmenu [Editing keys]
File diff suppressed because it is too large Load Diff
+201
View File
@@ -0,0 +1,201 @@
// opt/mapeditscripts
// fringe mapediting scripts
echo "\f0Extra map editing scripts:"
// list entity-sparklies with identical positions
echo "\fs\f2doublesparklies [enttype]\fr\t\tlist entity-sparklies with identical positions"
tempalias doublesparklies [
if $editing [
push eee $arg1
if (! (strlen $eee)) [ eee = (listoptions ents) ]
echo list entity sparklies with identical x, y and z coordinates "(" $eee ")"
looplist $eee ot [
looplist (enumentities $ot) oi [
push oee (editentity $oi)
push oex (at $oee 1)
looplist $eee it [
looplist (enumentities $it) ii [
if (&& (< $ii $oi) (= $oex (at (editentity $ii) 1))) [
push iee (editentity $ii)
if (&& (= (at $iee 2) (at $oee 2)) (= (at $iee 3) (at $oee 3))) [
echo $ii : $iee --- $oi : $oee
]
pop iee
]
]
]
pop oee oex
]
]
pop eee
][
echo edit mode required
]
]
// list identical models on the same position
echo "\fs\f2doublemodels\fr\t\tlist identical models on the same position"
tempalias doublemodels [
if $editing [
push res 0
echo "list doubled mapmodels (same position, model and elevation)"
looplist (enumentities mapmodel) oi [
push oee (editentity $oi)
push oex (at $oee 1)
looplist (enumentities mapmodel) ii [
if (&& (< $ii $oi) (= $oex (at (editentity $ii) 1))) [
push iee (editentity $ii)
if (&& (= (at $iee 2) (at $oee 2)) (&& (strcmp (mapmodelslotname (at $iee 5)) (mapmodelslotname (at $oee 5))) (= (at $iee 6) (at $oee 6)))) [
echo $ii : $iee --- $oi : $oee
addtodoentity $oi (concat double model $ii : $iee --- $oi : $oee) ]
+= res 1
]
pop iee
]
]
pop oee oex
]
if $res [ showmenu "TODO entities" ]
result (pop res)
][
echo edit mode required
]
]
// get cube info of a certain cube
// getcubedata x y attr
// (loses current selection)
tempalias getcubedata [
select $arg1 $arg2 1 1
push res (concatword sw_ $arg3)
selectionwalk [res = $$res]
resetselections
result (pop res)
]
// adjust mapmodel sparklie positions to a fixed offset over ground + mapmodel elevation + modelslot elevation
// mm_z slot z-offset
echo "\fs\f2mm_z slot z-offset\fr\tadjust mapmodel sparklie positions to a fixed offset over ground + mapmodel elevation + modelslot elevation"
tempalias mm_z [
if $editing [
push es (editmapmodelslot $arg1)
echo set z-coordinate of the entity sparklies of all mapmodels of slot # (escape $arg1) to floor + elevation + (at $es 2) + (escape $arg2)
if (strlen $arg1) [
looplist (enumentities mapmodel) i [
push ee (editentity $i)
if (= $arg1 (at $ee 5)) [
push nh (+ (getcubedata (at $ee 1) (at $ee 2) floor) (at $ee 6) $arg2 (at $es 2))
if (strlen $arg2) [editentity $i "" "" $nh]
echo $ee -> (pop nh) -> (editentity $i)
]
pop ee
]
][
echo usage: mm_z mmslotnumber heightoffset
]
pop es
][
echo edit mode required
]
]
// adjust clipent sparklie positions to the middle of the clip
// clip_z
echo "\fs\f2clip_z\fr\t\t\tadjust clipent sparklie positions to the middle of the clip"
tempalias clip_z [
if $editing [
echo set z-coordinate of the entity sparklies of all clip and plclip to the middle of the clips
looplist (concat (enumentities clip) (enumentities plclip)) i [
push ee (editentity $i)
push nh (+ (getcubedata (at $ee 1) (at $ee 2) floor) (at $ee 4) (div (at $ee 7) 2))
editentity $i "" "" $nh
echo clip_z: $ee -> (pop nh) -> (editentity $i)
pop ee
]
][
echo edit mode required
]
]
// duplicate all clipped model slots with an unclipped version - then sort the slots
// (after running this, reducing the slot number of any clipped mapmodel by one will remove the clip)
// doubleclippedslots
echo "\fs\f2duplicateclippedslots\fr\t\tduplicate all clipped model slots with an unclipped version, then sort the slots"
tempalias duplicateclippedslots [
if $editing [
echo double all clipped model slots with an unclipped version, then sort the slots
loop i 256 [
push info (editmapmodelslot $i)
if (|| (at $info 0) (at $info 1)) [
mapmodel 0 0 (at $info 2) (at $info 3) (at $info 4)
]
pop info
]
sortmapmodelslots
echo "\f4When done, use duplicateclippedslots_cleanup."
][
echo edit mode required
]
]
// clean up after using doubleclippedslots: sort&merge mapmodel slots, then delete all unused mapmodel slots
// (after running this, reducing the slot number of any mapmodel will remove the clip)
// doubleclippedslots_cleanup
echo "\fs\f2duplicateclippedslots_cleanup\fr\tremove all unnecessary mapmodel slots"
tempalias duplicateclippedslots_cleanup [
if $editing [
sortmapmodelslots mergeused
loop ii 256 [ push i (- 255 $ii) ; if (&& (strlen (mapmodelslotname $i)) (strcmp "" (mapmodelslotusage $i))) [deletemapmodelslot $i] ; pop i]
echo all unnecessary mapmodel slots removed
][
echo edit mode required
]
]
// un-clip models that are fully in tagclipped areas
// (after running this, reducing the slot number of any mapmodel will remove the clip)
// uncliptagclippedmodels
echo "\fs\f2uncliptagclippedmodels\fr\tun-clip models that are fully in tagclipped areas"
tempalias uncliptagclippedmodels [
if $editing [
push res 0
looplist (enumentities mapmodel) i [
push entinfo (editentity $i)
push slotinfo (editmapmodelslot (at $entinfo 5))
if (|| (at $slotinfo 0) (at $slotinfo 1)) [
push radius (at $slotinfo 0)
if (= $radius 0) [ radius = 1 ] // FIXME
select (- (at $entinfo 1) $radius) (- (at $entinfo 2) $radius) (* $radius 2) (* $radius 2)
push unclipped 0
selectionwalk [ if (&& (! (&b 0x40 $sw_tag)) $sw_type) [ += unclipped 1 ] ]
if (&& (! (at $slotinfo 0)) (< $unclipped 4)) [ unclipped = 0 ] // radius 0 is fine, if there is at least 1 tagclip
if (! $unclipped) [
push uinfo (concat 0 0 (at $slotinfo 2) (at $slotinfo 3) (escape (at $slotinfo 4)))
loop j 256 [
if (strcmp (editmapmodelslot $j) $uinfo) [
addtodoentity $i (concatword "changed from mapmodel slot #" (at $entinfo 5) " to slot #" $j)
editentity $i "" "" "" "" $j
unclipped = -1
break
]
]
if (! $unclipped) [
editentity $i "" "" "" "" (mapmodel 0 0 (at $slotinfo 2) (at $slotinfo 3) (at $slotinfo 4))
addtodoentity $i (concatword "changed from mapmodel slot #" (at $entinfo 5) " to newly created slot #" (at (editentity $i) 5))
]
pop uinfo
+= res 1
]
pop unclipped radius
]
pop entinfo slotinfo
]
resetselections
echo un-clipped $res mapmodel entities
pop res
][
echo edit mode required
]
]
+3 -1
View File
@@ -62,7 +62,7 @@ const fullscreentoggle [ fullscreen (! $fullscreen) ]
const editsvar [ inputcommand $$arg1 (concatword "push q (addpunct $cmdbuf) ; " $arg1 " (at $q 0) ; pop q") (concatword "edit " $arg1 :) ]
const editmapmsg [ editsvar mapmsg ]
const return [ result $arg1 ]
const run [ exec (concatword config/ $arg1 .cfg) ]
const run [ push n (concatword "exec config/" $arg1 ".cfg ") ; loop i (- $numargs 1) [ n = (concat $n (getalias (concatword "arg" (+ $i 2)))) ] ; n ; pop n]
const closecurmenu [ closemenu (curmenu) ]
const resetcurmenu [ delmenu (curmenu) ; newmenu (curmenu) ]
@@ -571,5 +571,7 @@ tempalias load_compatibility [ run opt/compatibility ; alias load_compatibility
tempalias load_survival [ load_compatibility ; run opt/survival ; alias load_survival [] ]
tempalias load_parsestring [ run opt/parsestring ; alias load_parsestring [] ]
tempalias load_faq [ run opt/faq ; alias load_faq [] ]
tempalias load_convmap [ saycommand "/run opt/convmap " ]
tempalias load_mapeditscripts [ run opt/mapeditscripts ]
persistidents 1