Merge remote-tracking branch 'udb/master'

This commit is contained in:
spherallic 2024-03-13 18:39:54 +01:00
commit 77d45c78f9
4 changed files with 256 additions and 0 deletions

View file

@ -222,6 +222,26 @@ secact_flagsrename
}
}
pathnode_flagsrename
{
DoomMapSetIO
{
8 = "Transition";
}
HexenMapSetIO
{
8 = "Transition";
16384 = "Invert Size Check";
}
UniversalMapSetIO
{
ambush = "Transition";
standing = "Invert Size Check";
}
}
// Default sector brightness levels
sectorbrightness
{

View file

@ -1284,6 +1284,41 @@ zdoom
}
}
9022
{
title = "Path Node";
sprite = "internal:PathFollower";
class = "PathNode";
flagsrename { include("ZDoom_misc.cfg", "pathnode_flagsrename") }
radius = 16;
height = 56;
arg0
{
title = "TID 1";
type = 14;
}
arg1
{
title = "TID 2";
type = 14;
}
arg2
{
title = "TID 3";
type = 14;
}
arg3
{
title = "TID 4";
type = 14;
}
arg4
{
title = "TID 5";
type = 14;
}
}
9024
{
title = "Patrol Point";

View file

@ -0,0 +1,114 @@
/// <reference path="../../../udbscript.d.ts" />
`#version 4`;
`#name Connect Nodes`;
`#description Connects nodes to/from the first selected PathNode.`;
`#scriptoptions
direction
{
description = "Assignment Direction";
default = 2;
type = 11; // Enum
enumvalues {
0 = "To First";
1 = "From First";
2 = "Both";
}
}
doclear
{
description = "Clear first thing's arguments";
default = "False";
type = 3; // Boolean
}
`;
let things = UDB.Map.getSelectedThings();
if(things.length < 2)
UDB.die('You have to select at least 2 things.');
let dir = UDB.ScriptOptions.direction;
let clr = UDB.ScriptOptions.doclear;
let receiver = things[0];
let pos = 0;
let i = 0;
if (clr)
{
for (i; i < 5; i++)
receiver.args[i] = 0;
}
things.forEach(n =>
{
if (n != receiver)
{
if (dir > 0)
{
// look for the tid first, make sure it's not already assigned.
let found = false;
for (i = 0; i < 5; i++)
{
if (n.args[i] == receiver.tag)
{
found = true;
break;
}
}
// Not found, so assign it.
if (!found) for (i = 0; i < 5; i++)
{
if (n.args[i] == 0)
{
n.args[i] = receiver.tag;
break;
}
}
}
if ((dir == 0 || dir == 2) && (pos < 5 && n.tag != 0))
{
if (clr) // No special management necessary.
{
receiver.args[pos] = n.tag;
pos++;
}
else // Look for a free spot.
{
let found = false;
for (i = 0; i < 5; i++)
{
if (receiver.args[i] == n.tag)
{
found = true;
break;
}
}
if (!found)
{
for (i = pos; i < 5; i++)
{
if (receiver.args[i] == 0)
{
receiver.args[i] = n.tag;
pos = i;
found = true;
break;
}
}
}
}
}
}
});

View file

@ -0,0 +1,87 @@
/// <reference path="../../../udbscript.d.ts" />
`#version 4`;
`#name New Path Node`;
`#description Creates a new node and assigns it a TID. If a Path Node is already selected, connects the two automatically.`;
`#scriptoptions
gridsnap
{
description = "Grid Snap";
default = 1;
type = 11; // enum
enumvalues {
0 = "Disabled";
1 = "Enabled";
}
}
`;
let mpos = UDB.Map.mousePosition;
if(!mpos.isFinite())
UDB.die('Mouse cursor must be inside the map');
let nodetype = 9022;
let ntag = UDB.Map.getNewTag();
let things = UDB.Map.getSelectedThings();
let node = UDB.Map.createThing(mpos, nodetype);
if (UDB.ScriptOptions.gridsnap > 0)
node.snapToGrid();
node.tag = ntag;
let i = 0;
let count = 0;
if(things.length > 0)
{
things.forEach(n =>
{
if (n.type == nodetype)
{
// For the new node, assign the path IDs to it, up to max arguments.
if (n.tag != 0 && count < 5)
{
node.args[count] = n.tag;
count++;
}
// For the selected nodes, check for an empty slot.
let pos = -1;
for(i = 0; i < 5; i++)
{
if (n.args[i] != 0)
continue;
pos = i;
break;
}
// Check if the tag is already used first.
if (pos >= 0)
{
for (i = 0; i < 5; i++)
{
if (n.args[i] == ntag)
{
pos = -1;
break;
}
}
}
// Free slot, and unpresent. Set it in.
if (pos >= 0)
n.args[pos] = ntag;
}
});
}
UDB.Map.clearSelectedThings();
node.selected = true;