Running Action Specials as Numbers

Archive of the old editing forum
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.
Locked
User avatar
printz
Posts: 2649
Joined: Thu Oct 26, 2006 12:08 pm
Location: Bucharest, Romania
Contact:

Running Action Specials as Numbers

Post by printz »

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

Re: Running Action Specials as Numbers

Post by Gez »

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.)
User avatar
Ceeb
Posts: 5125
Joined: Wed Jun 11, 2008 4:07 pm
Location: Castle Wut

Re: Running Action Specials as Numbers

Post by Ceeb »

Why, exactly, is the use of [wiki]A_CallSpecial[/wiki] so frowned upon?
User avatar
Slasher
Posts: 1160
Joined: Sun Mar 16, 2008 11:17 pm
Location: California

Re: Running Action Specials as Numbers

Post by Slasher »

Ceeb wrote:Why, exactly, is the use of [wiki]A_CallSpecial[/wiki] so frowned upon?
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.

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

Re: Running Action Specials as Numbers

Post by Graf Zahl »

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

Re: Running Action Specials as Numbers

Post by Gez »

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.
These numbers aren't going to be changed because maps necessarily refer to specials by their numbers.
Worst
Posts: 115
Joined: Sat Apr 28, 2007 5:29 am
Location: finland
Contact:

Re: Running Action Specials as Numbers

Post by Worst »

If you can't access action specials with numbers in acs, then you just need to make a function that does so :P

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!");
    }
}
Edit: Gez beat me to it Image
Last edited by Worst on Thu Apr 22, 2010 3:38 pm, edited 1 time in total.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Running Action Specials as Numbers

Post by Gez »

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.
Hexen format maps actually do not use a translator lump at all!
Worst
Posts: 115
Joined: Sat Apr 28, 2007 5:29 am
Location: finland
Contact:

Re: Running Action Specials as Numbers

Post by Worst »

what about the polyobjects?

edit: nevermind.. cant see it now.. I just remember there being some trickery with polyobjects or maybe playerstarts in hexen :?
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: Running Action Specials as Numbers

Post by Gez »

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.
User avatar
printz
Posts: 2649
Joined: Thu Oct 26, 2006 12:08 pm
Location: Bucharest, Romania
Contact:

Re: Running Action Specials as Numbers

Post by printz »

Indeed, I'll just use switch-case. It's cleaner anyway.
Locked

Return to “Editing (Archive)”