Sauerworld Forum

Script to fix playerstarts and flag after mirroring a CTF map you work on

pix

  • **
  • 86
  • +9/-1
    • A Cube 2: Sauerbraten Knowledge Base by pix
So this annoyed me enough to finally write a script that solves it for me:

After copy-n-pasting one half of the map over to the other side (and rotating the geometry accordingly), playerstarts and the flag will retain their direction and team attributes, meaning one team has neither a flag nor spawns, and the other team has two flags and spawns in both bases, facing the wrong direction.

Here it is:

Code: [Select]
// fixes team and direction of playerstart and flag after mirroring
alias fixctfents [
entcancel
entfindinsel playerstart
entfindinsel flag

entloop [
entattr 0 (mod (+ 180 (entattr 0)) 360)
entattr 1 (+ 1 (mod (entattr 1) 2))
]
]

Simply copy and paste this snippet into your autoexec.cfg. Note: this only works for 180° point-symmetrical maps (e.g. reissen and forge, but not l_ctf)!

Mirror one side using the following steps (looks harder than it is...):

  • select a full side or only part of it
  • use /entselect insel to add all the entities inside the selection to the selection
  • press C in edit mode
  • paste it on the other side using V
  • rotate pasted stuff using R (entity positions will change with geometry)
  • keep the pasted stuff selected!
  • do /fixctfents
  • profit

I may add teleport and teledest fixing at some point when I need it.