Page 1 of 3

ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 9:23 am
by Korshun
This patch by Monsterovich allows all ACS functions that use sector tags or line IDs to work on individual sectors/lines. This extends the flexibility of ACS scripting and greatly reduces the need to assign a different tag to each sector when implementing complex effects because ACS scripts are not forced to use the restrictive "sector tag/line id" system.
Spoiler: The patch by Monsterovich
The idea is very simple: if tag/lineid given to any function is negative, it is a sector or line number. -1 is the first sector, -2 is the second, etc... This keeps compatibilty with all the functions that work on tags/lineids while adding new functionality.

To convert between simple sector/line numbers and "negative tags", the formula "-x - 1" is used. It is abbeviated as function num(int x), though the name should probably be changed. num(int x) converts both ways. num(num(x)) == x

Possible uses:
  • ACS gamemodes that grealy modify ANY MAP. Previously, it was possible to apply only one modification to the majority of sectors because they were all tagged 0. Now any sector can be modified individually.
  • Complex scripting effects are now a lot easier and don't require a lot of different tags. Want a huge city map with a lot of lit sectors (with different light levels) that can turn on/off? Tag them with ONE tag, then in the ACS iterate over all sectors, check if they have that tag, collect the list of such sectors. When switching the lights off, save their lightlevels. And when turning them back on, restore their light levels individually.
  • Just for fun: weapon that edit heights/lightlevels/colors/fog of ANY sector. Just like Sectorcraft but on ANY map!
Spoiler: A few simple examples
The list of additional functions that are implemented:
All sector and line numbers are in "negative tag" format. This is done so results could be passed straight to old sector/line functions that accept tags.
Probably, more functions should be added to take advantage of the new system.
Spoiler: New ACS functions
New functions in zspecial.acs:
Spoiler:
P.S. A similar patch for actor tags would be awesome!

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 9:40 am
by Gez
There are two main problems with this:
  1. Compatibility issue: negative tags are supported and, in fact, actually used in some cases. (I think CIF3 did, for example.)
  2. Design: tags exist to give arbitrary identifiers to sectors (and other map elements) instead of relying on index, which is a value that can be changed by simply deleting one element and saving the map back.

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 9:55 am
by GooberMan
Editors can incrementally tag ranges, so why do you need individual access to untagged sectors?

Seconding the problem alarm bells. This is only valid for a completed map that never changes.

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 10:11 am
by Enjay
Echoing what the others have said:

-ve tags are already in some released projects.
A simple edit to a map can change a large number of the sector/line identifiers.
Editors can apply tag ranges.
Even in older map formats, sector tags are unlikely to run out and in UDMF I believe that they are (virtually?) unlimited.

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 10:25 am
by Korshun
Gez wrote:Compatibility issue: negative tags are supported and, in fact, actually used in some cases. (I think CIF3 did, for example.)
O_o how does that even work? And why doesn't Doom Builder let me use negative tags then?
Gez wrote:tags exist to give arbitrary identifiers to sectors (and other map elements) instead of relying on index, which is a value that can be changed by simply deleting one element and saving the map back.
Direct access to sectors/lines is not supposed to be a replacement for tags. Sector/line numbers should not be hardcoded, they should be retrieved using functions like PointInSector. Or by iterating over all sectors and selecting the ones that match some criteria.

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 11:38 am
by Gez
Korshun wrote:O_o how does that even work? And why doesn't Doom Builder let me use negative tags then?
Maybe it uses unsigned variables. I think in CIF3's case, it's used for thing IDs, and the actors are given a negative TID by ACS rather than in the editor. Sure, things aren't lines or sectors, but they're all map elements and if something can be done to retrieve a line or sector in particular, there should be an equivalent function to retrieve things in the same way.
Korshun wrote:they should be retrieved using functions like PointInSector. Or by iterating over all sectors and selecting the ones that match some criteria.
Then WFDS I guess. Instead of using indices, I'd want to use objects for that. In pseudocode, not "int index = getsectornum(conditions); dostufftosectornum(index);" but "sector sec = getsector(conditions); dostufftosector(sec);"

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 11:58 am
by Korshun
I, too, want to use actual objects instead of numbers. But everything is an integer in ACS. And I, too, want the same feature for actors (like I said in the first post). But neither I nor Monsterovich have an idea on how to get actor numbers that don't change during the game.

what is WFDS?

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 12:11 pm
by Monsterovich
Gez wrote:Compatibility
Compatflag is a good way to make support for "negative tags", which used in mods like CIF3 (0.01% of mods).
Why ACS has no "#version" :? For example: GLSL has it!

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 1:15 pm
by Xaser
At first I was a bit iffy about this suggestion for the same reasons posted above (namely that sector/line numbers change like crazy and scrips are gonna super-break), but after some thought, this might actually have some potential since operations in the form of "get sector ID from tag, do stuff via sector ID" is change-safe and allows for things not doable before (e.g. the building window example in the OP). The feature would indeed allow folks to screw things up if used badly, but the same can be said about lots of features.

The implementation might be troublesome though (since negative tags exist), and this does seem like a very Doomscripty thing -- in fact, it almost feels like it'd be something you could do with it out of the box. I'm guessing, of course. :P

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 5:35 pm
by zrrion the insect
Perhaps a mapinfo property to tell negative tags to be sestor /line ids could work?

Re: ACS access to individual sectors/lines

Posted: Sat Apr 12, 2014 5:47 pm
by Xaser
Perhaps. If we're talking just sectors/lines, there's limited potential for use of these features in gameplay mods. All possibilities I can think of are either exceptionally weird or map-breaky things, though examples to the contrary would be good to know if anyone's got some.

Re: ACS access to individual sectors/lines

Posted: Sun Apr 13, 2014 12:58 am
by Graf Zahl
I honestly can't think of any real world use for this.
The only time I ever needed something like this was when I tried to apply a machine generated colored light table to an existing map - and these days with UDMF even that 's no longer necessary because it can be written directly to the map data.

For regular mapping this is of no use whatsoever and for gameplay mods even less.

Re: ACS access to individual sectors/lines

Posted: Thu Apr 17, 2014 4:10 am
by Monsterovich
Graf Zahl wrote:and for gameplay mods even less.
NO! That's wrong. That could be very useful for gameplay mods. We can choose any sector/line in ACS, using numbers as "negative tags", without "pain-in-ass" (seriously) tag marking. Also, I think, you didn't read this thread and just closed this suggestion, because you don't like.
Graf Zahl wrote:For regular mapping this is of no use whatsoever
Spoiler:

Re: ACS access to individual sectors/lines

Posted: Thu Apr 17, 2014 4:19 am
by edward850
Monsterovich wrote:NO! That's wrong. That could be very useful for gameplay mods. We can choose any sector/line in ACS, using numbers, without "pain-in-ass" tags. Also, I think, you didn't read this thread and just closed this suggestion.
Do... what... exactly? With which line/sector? There is absolutely zero frame of reference for any line/sector values, you know, being completely blind to how the map is structured. Or any map. You don't even know what map it's going to be on.

Edit: You edited your post, and somehow made it worse. Congrats.
Monsterovich wrote:using numbers as "negative tags", without "pain-in-ass" (seriously) tag marking
You can't use negative tags. They are already used for tagging lines/things and sectors as per normal. You can't just change the rules already in place, breaking a selection of mods, just because you want something else.
Monsterovich wrote:Also, I think, you didn't read this thread and just closed this suggestion, because you don't like.
You are going to have to explain this. A programmer doesn't like useless and uninformed implementations of features? Where the hell do I sign up?

Re: ACS access to individual sectors/lines

Posted: Thu Apr 17, 2014 4:46 am
by GooberMan
Monsterovich wrote:We can choose any sector/line in ACS, using numbers as "negative tags", without "pain-in-ass" (seriously) tag marking.
Which is no different to naming objects you want to manipulate in script. You know, like every major modern game engine forces you to do.
Monsterovich wrote:Sector/line numbers should not be hardcoded
...but this change encourages such things by giving direct access to sector/lines.
Monsterovich wrote:they should be retrieved using functions like PointInSector
And how does forcing sector/line numbers in to tag values fit in to this? You hate tags, so you want to change them? Good for you.
Monsterovich wrote:Or by iterating over all sectors and selecting the ones that match some criteria.
You're not a programmer by trade, I hope.