ACS access to individual sectors/lines

Moderator: GZDoom Developers

Korshun
Posts: 52
Joined: Thu Dec 13, 2012 1:32 pm

ACS access to individual sectors/lines

Post 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!
Gez
 
 
Posts: 17938
Joined: Fri Jul 06, 2007 3:22 pm

Re: ACS access to individual sectors/lines

Post 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.
User avatar
GooberMan
Posts: 1336
Joined: Fri Aug 08, 2003 12:57 am
Location: Helsinki, Finland

Re: ACS access to individual sectors/lines

Post 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.
User avatar
Enjay
 
 
Posts: 26935
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: ACS access to individual sectors/lines

Post 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.
Korshun
Posts: 52
Joined: Thu Dec 13, 2012 1:32 pm

Re: ACS access to individual sectors/lines

Post 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.
Gez
 
 
Posts: 17938
Joined: Fri Jul 06, 2007 3:22 pm

Re: ACS access to individual sectors/lines

Post 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);"
Korshun
Posts: 52
Joined: Thu Dec 13, 2012 1:32 pm

Re: ACS access to individual sectors/lines

Post 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?
Monsterovich
Posts: 59
Joined: Sat Apr 12, 2014 11:10 am

Re: ACS access to individual sectors/lines

Post 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!
Last edited by Monsterovich on Sun Apr 13, 2014 6:08 am, edited 1 time in total.
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: ACS access to individual sectors/lines

Post 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
User avatar
zrrion the insect
Posts: 2432
Joined: Thu Jun 25, 2009 1:58 pm
Location: Time Station 1: Moon of Glendale

Re: ACS access to individual sectors/lines

Post by zrrion the insect »

Perhaps a mapinfo property to tell negative tags to be sestor /line ids could work?
User avatar
Xaser
 
 
Posts: 10774
Joined: Sun Jul 20, 2003 12:15 pm
Contact:

Re: ACS access to individual sectors/lines

Post 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.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49223
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: ACS access to individual sectors/lines

Post 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.
Monsterovich
Posts: 59
Joined: Sat Apr 12, 2014 11:10 am

Re: ACS access to individual sectors/lines

Post 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:
Last edited by Monsterovich on Thu Apr 17, 2014 4:33 am, edited 6 times in total.
User avatar
edward850
Posts: 5886
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: ACS access to individual sectors/lines

Post 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?
User avatar
GooberMan
Posts: 1336
Joined: Fri Aug 08, 2003 12:57 am
Location: Helsinki, Finland

Re: ACS access to individual sectors/lines

Post 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.
Locked

Return to “Closed Feature Suggestions [GZDoom]”