Running Action Specials as Numbers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Running Action Specials as Numbers
Is there a way that I can access [wiki=Action_specials]action specials[/wiki] within scripts by using numbers, and not mnemonics? For example I might need to create an ACS script whose argument is an action special number.
Re: Running Action Specials as Numbers
It's [wiki=A_CallSpecial]possible in DECORATE[/wiki], though it requires using a codepointer whose explicit use is strongly discouraged. But for ACS? No. It doesn't seem that simple to do because the engine does not use one single p-code for all action special calls, but many different ones depending on the number of arguments the special call uses, and whether it expects a result or not, and the like.
Just a quick scan of the PCD_LSPEC* listed in p_acs.h:
PCD_LSPEC1,
PCD_LSPEC2,
PCD_LSPEC3,
PCD_LSPEC4,
PCD_LSPEC5,
PCD_LSPEC1DIRECT,
PCD_LSPEC2DIRECT,
PCD_LSPEC3DIRECT,
PCD_LSPEC4DIRECT,
PCD_LSPEC5DIRECT,
PCD_LSPEC6,
PCD_LSPEC6DIRECT,
PCD_LSPEC1DIRECTB,
PCD_LSPEC2DIRECTB,
PCD_LSPEC3DIRECTB,
PCD_LSPEC4DIRECTB,
PCD_LSPEC5DIRECTB,
PCD_LSPEC5RESULT,
(The LSPEC6 ones are marked as being basically dummies that are never used, though.)
Just a quick scan of the PCD_LSPEC* listed in p_acs.h:
PCD_LSPEC1,
PCD_LSPEC2,
PCD_LSPEC3,
PCD_LSPEC4,
PCD_LSPEC5,
PCD_LSPEC1DIRECT,
PCD_LSPEC2DIRECT,
PCD_LSPEC3DIRECT,
PCD_LSPEC4DIRECT,
PCD_LSPEC5DIRECT,
PCD_LSPEC6,
PCD_LSPEC6DIRECT,
PCD_LSPEC1DIRECTB,
PCD_LSPEC2DIRECTB,
PCD_LSPEC3DIRECTB,
PCD_LSPEC4DIRECTB,
PCD_LSPEC5DIRECTB,
PCD_LSPEC5RESULT,
(The LSPEC6 ones are marked as being basically dummies that are never used, though.)
Re: Running Action Specials as Numbers
Why, exactly, is the use of [wiki]A_CallSpecial[/wiki] so frowned upon?
Re: Running Action Specials as Numbers
My guess is because you have to input the action special as a number, rather than by name. Using a name is much easier to read and understand what the code will do, rather than having to look up the number of the action special.Ceeb wrote:Why, exactly, is the use of [wiki]A_CallSpecial[/wiki] so frowned upon?
More importantly, by using the name of the action special, the internal number can be changed if necessary. If a number is used directly, and later the number is changed such that it isn't used to refer to that action special anymore for some reason, it will break compatibility.
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49234
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Running Action Specials as Numbers
Ceeb wrote:Why, exactly, is the use of [wiki]A_CallSpecial[/wiki] so frowned upon?
It's not supposed to be used directly. A_CallSpecial is just the internal function that is being used when you place an action special in a state. The export is just necessary to create a proper symbol table entry for it so that the parser can resolve it to working code.
It may even be removed once the scripting stuff is finalized. So better keep your hands off it if you don't want to get into trouble later.
Re: Running Action Specials as Numbers
These numbers aren't going to be changed because maps necessarily refer to specials by their numbers.Slasher wrote:More importantly, by using the name of the action special, the internal number can be changed if necessary. If a number is used directly, and later the number is changed such that it isn't used to refer to that action special anymore for some reason, it will break compatibility.
Re: Running Action Specials as Numbers
If you can't access action specials with numbers in acs, then you just need to make a function that does so :P
eg.
Edit: Gez beat me to it 
eg.
Code: Select all
#include "zcommon.acs"
function void RunSpecial(int number,int arg1,int arg2,int arg3,int arg4,int arg5)
{
Switch(number)
{
//1 Polyobj_StartLine
Case 2: Polyobj_RotateLeft (arg1, arg2, arg3); break;
Case 3: Polyobj_RotateRight (arg1, arg2, arg3); break;
Case 4: Polyobj_Move (arg1, arg2, arg3, arg4); break;
//5 Polyobj_ExplicitLine
Case 6: Polyobj_MoveTimes8 (arg1, arg2, arg3, arg4); break;
Case 7: Polyobj_DoorSwing (arg1, arg2, arg3, arg4); break;
Case 8: Polyobj_DoorSlide (arg1, arg2, arg3, arg4, arg5); break;
//9 Line_Horizon
Case 10: Door_Close (arg1, arg2); break; //no arg3 in ACC 1.49
Case 11: Door_Open (arg1, arg2, arg3); break;
Case 12: Door_Raise (arg1, arg2, arg3, arg4); break;
Case 13: Door_LockedRaise (arg1, arg2, arg3, arg4, arg5); break;
Case 14: Door_Animated (arg1, arg2, arg3); break; //no arg4 in ACC 1.49
Case 15: Autosave (); break;
//16 Transfer_WallLight
Case 17: Thing_Raise (arg1); break;
Case 18: StartConversation (arg1, arg2); break;
Case 19: Thing_Stop (arg1); break;
Case 20: Floor_LowerByValue (arg1, arg2, arg3); break;
//..about 235 more specials to go..
default:
PrintBold(s:"Unknown special!");
}
}

Last edited by Worst on Thu Apr 22, 2010 3:38 pm, edited 1 time in total.
Re: Running Action Specials as Numbers
Hexen format maps actually do not use a translator lump at all!Worst wrote:I think the numbers used are the same that you use with linedefs..so if those would be later on changed, it would break pretty much every doom/hexen format map that doesnt use its own translator lump for its linedef specials.
Re: Running Action Specials as Numbers
what about the polyobjects?
edit: nevermind.. cant see it now.. I just remember there being some trickery with polyobjects or maybe playerstarts in hexen
edit: nevermind.. cant see it now.. I just remember there being some trickery with polyobjects or maybe playerstarts in hexen

Re: Running Action Specials as Numbers
The numbers for extra player starts depend on the game, that's handled by the GameInfo section of MAPINFO.
PolyObject start points are handled outside of translators. Translators do not change map thing's editor numbers, so it's all a bunch of hardcoded stuff. There are plenty of them.
PolyObject start points are handled outside of translators. Translators do not change map thing's editor numbers, so it's all a bunch of hardcoded stuff. There are plenty of them.
Re: Running Action Specials as Numbers
Indeed, I'll just use switch-case. It's cleaner anyway.