[Resource/Project] ACS-X

Sprites, textures, sounds, code, and other resources belong here. Share and share-alike!
Forum rules
Before posting your Resource, please make sure you can answer YES to any of the following questions:
  • Is the resource ENTIRELY my own work?
  • If no to the previous one, do I have permission from the original author?
  • If no to the previous one, did I put a reasonable amount of work into the resource myself, such that the changes are noticeably different from the source that I could take credit for them?
If you answered no to all three, maybe you should consider taking your stuff somewhere other than the Resources forum.

Consult the Resource/Request Posting Guidelines for more information.

Please don't put requests here! They have their own forum --> here. Thank you!
Post Reply
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

[Resource/Project] ACS-X

Post by The Zombie Killer »

ACS-X is an ACS library containing various useful functions and features, including basic pointer access.
This library requires GDCC-ACC, which is a drop-in replacement for ACC, with less bugs and more features. Your existing code will compile fine under GDCC-ACC.

New functions (see further down for functions added in updates)
  • ptr NewPtr(void): returns a new pointer
  • void SetPtr(ptr pointer, <any> value): sets the value of a pointer
  • void FreePtr(ptr pointer): frees the memory of a pointer
  • int astrtoi(str string): converts a string to an integer
  • float astrtof(str string): converts a string to a float
  • str astrlower(str string): converts a string to lowercase
  • str astrupper(str string): converts a string to uppercase
  • void FadeSoundIn(int tid, int channel, int tics): fades in the currently playing sound on a channel for a specified duration
  • void FadeSoundOut(int tid, int channel, int tics): fades out the currently playing sound on a channel for a specified duration
  • void ChangeFlag(int tid, str flag, bool set): enables/disables [wiki=Actor_flags]actor flags[/wiki] on an actor
  • int GetGame(void): returns the current game (see below for available values)
  • str GetGameName(void): returns the title of the current game
  • int GetSourceport(void): returns the current source port (PORT_ZDOOM, PORT_GZDOOM or PORT_ZANDRONUM)
  • int GetMaxPlayers(void): returns the maximum number of players supported in the current source port
Pointer casts
syntax: ptr_cast(type)(pointer)
example:

Code: Select all

ptr pointer = NewPtr();
SetPtr(pointer, 25);
int value = ptr_cast(int)(pointer);
FreePtr(pointer); 
Game constants

Code: Select all

GAME_UNKNOWN
GAME_DOOM
GAME_DOOM_BFG
GAME_DOOM_ULTIMATE
GAME_DOOM2
GAME_DOOM2_PLUTONIA
GAME_DOOM2_TNT
GAME_DOOM2_BFG
GAME_FREEDOOM_DEMO
GAME_FREEDOOM_PHASE1
GAME_FREEDOOM_PHASE2
GAME_FREEDOOM_FREEDM
GAME_HERETIC
GAME_HERETIC_SHADOW
GAME_BLASPHEMER
GAME_HEXEN
GAME_HEXEN_DEATHKINGS
GAME_STRIFE
GAME_CHEX
GAME_CHEX3
GAME_URBANBRAWL
GAME_HACX
GAME_HACX2
GAME_HARMONY
GAME_SQUARE_SQUAREWARE
GAME_SQUARE
Example usage

Code: Select all

#pragma define raw on // preprocessor macros
#pragma fixed on      // fixed point type

#include "zcommon.acs"
#include "acsx.h"

script "ACS-X Demo" enter
{
    // Game name
    PrintBold(s:"Currently playing: ", s:GetGameName(), s:" (id: ", d:GetGame(), s:")");
    
    // Port detection
    switch (GetSourceport())
    {
        case PORT_ZDOOM:     PrintBold(s:"Currently playing in ZDoom."); break;
        case PORT_GZDOOM:    PrintBold(s:"Currently playing in GZDoom."); break;
        case PORT_ZANDRONUM: PrintBold(s:"Currently playing in Zandronum."); break;
        default:             PrintBold(s:"Port detection failed."); break;
    }
    
    // Pointers
    ptr string_pointer = NewPtr();
    ptr int_pointer = NewPtr();
    
    SetPtr(string_pointer, "Hello World");
    Log(s:"Pointer ", d:string_pointer, s:" is: ", s:ptr_cast(str)(string_pointer));
    SetPtr(string_pointer, "Goodbye World");
    Log(s:"Pointer ", d:string_pointer, s:" is: ", s:ptr_cast(str)(string_pointer));
    
    SetPtr(int_pointer, 25);
    Log(s:"Pointer ", d:int_pointer, s:" is: ", d:ptr_cast(int)(int_pointer));
    
    FreePtr(string_pointer);
    FreePtr(int_pointer);
    string_pointer = NULL;
    int_pointer = NULL;
    
    // FadeSound
    PlaySound(0, "brain/sight", CHAN_BODY);
    FadeSoundIn(0, CHAN_BODY, 35 * 2); // 2 second fadein
    Log(s:"Fading in for two seconds...");
    
    Delay(35 * 2);
    FadeSoundOut(0, CHAN_BODY, 35 * 4); // 4 second fadeout
    Log(s:"Fading out in four seconds...");
}
 
Adding ACS-X into a project
1. Download acsx-pub.zip
2. Put all of the files from the zip inside your project
3. Put acsx.h and acsx_import.h from the scripts folder somewhere where gdcc-acc can find them. You can do this in Slade 3 by going Edit -> Preferences -> Scripting -> ACS and adding an include path to somewhere containing those two files.
4. Add #include "acsx.h" below #include "zcommon.acs" in any source files you want to use ACS-X in.

Update 8th May 5:06 AM AEST
New functions
  • ptr NewPtrArray(int size): returns a new pointer array
  • ptr ResizePtrArray(ptr array, int size): reallocates a pointer array with a new size, and returns the new pointer
  • ptr GetPtrArray(ptr array, int element): returns a pointer to an element in an array
Update 8th May 5:50 AM AEST
New function
  • int GetBaseGame(void): returns the base game (see list below)
Base game constants

Code: Select all

BASEGAME_UNKNOWN
BASEGAME_DOOM
BASEGAME_HERETIC
BASEGAME_BLASPHEMER
BASEGAME_HEXEN
BASEGAME_STRIFE
BASEGAME_CHEX
BASEGAME_URBANBRAWL
BASEGAME_HACX
BASEGAME_HARMONY
BASEGAME_SQUARE
Update 20th May 6:34 PM AEST
  • Fixed astrtoi and astrtof
Download Now!
Last edited by The Zombie Killer on Fri May 20, 2016 2:34 am, edited 6 times in total.
User avatar
Kinsie
Posts: 7402
Joined: Fri Oct 22, 2004 9:22 am
Graphics Processor: nVidia with Vulkan support
Location: MAP33
Contact:

Re: [Resource/Project] ACS-X

Post by Kinsie »

Impressive. Most impressive!
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: [Resource/Project] ACS-X

Post by The Zombie Killer »

Updated, now supports arrays!
User avatar
Zhs2
Posts: 1300
Joined: Fri Nov 07, 2008 3:29 pm
Graphics Processor: ATI/AMD with Vulkan/Metal Support
Location: Maryland, USA, but probably also in someone's mod somewhere
Contact:

Re: [Resource/Project] ACS-X

Post by Zhs2 »

If the source port knows ACS but doesn't have GetPlayerAccountName or the dynamic light actor, it must be ZDoom rite?

Also, the LANGUAGE solution for game checking is extensive (and unfortunately necessary), but if you're going to go the whole way with that shebang might as well also allow checking based on game family (e.g. Game-Doom, Game-Heretic, Game-Hexen, Game-Strife, Game-Chex, and so forth) because a lot of features may be common enough to a single game family that checking for "GAME_DOOM2"|"GAME_DOOM2_PLUTONIA"|"GAME_DOOM2_TNT"|"GAME_DOOM2_BFG" is a mouthful to define, and for each family case...
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: [Resource/Project] ACS-X

Post by The Zombie Killer »

Zhs2 wrote:If the source port knows ACS but doesn't have GetPlayerAccountName or the dynamic light actor, it must be ZDoom rite?
I can account for other ports later on, although for now I'm only going for ZDoom and its mainstream derivatives.
Zhs2 wrote:Also, the LANGUAGE solution for game checking is extensive (and unfortunately necessary), but if you're going to go the whole way with that shebang might as well also allow checking based on game family (e.g. Game-Doom, Game-Heretic, Game-Hexen, Game-Strife, Game-Chex, and so forth) because a lot of features may be common enough to a single game family that checking for "GAME_DOOM2"|"GAME_DOOM2_PLUTONIA"|"GAME_DOOM2_TNT"|"GAME_DOOM2_BFG" is a mouthful to define, and for each family case...
I actually have that on my todo list, heh.
User avatar
|ndußtrial
Posts: 398
Joined: Sat Aug 17, 2013 11:39 am
Graphics Processor: Intel (Modern GZDoom)
Location: Ivy Mercy Lyons

Re: [Resource/Project] ACS-X

Post by |ndußtrial »

square/virus are also detected as iwads without tweaking!
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: [Resource/Project] ACS-X

Post by The Zombie Killer »

Added GetBaseGame()
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: [Resource/Project] ACS-X

Post by The Zombie Killer »

Updated
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: [Resource/Project] ACS-X

Post by Matt »

Put acsx.h and acsx_import.h from the scripts folder somewhere where gdcc-acc can find them.
And where might this be? Putting them in the same folder as gdcc-acc doesn't work.
User avatar
The Zombie Killer
Posts: 1528
Joined: Thu Jul 14, 2011 12:06 am
Location: Gold Coast, Queensland, Australia

Re: [Resource/Project] ACS-X

Post by The Zombie Killer »

the same folder as your source files would work. Alternatively, you can pass

Code: Select all

-i path/to/directory
to gdcc-acc when you compile
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: [Resource/Project] ACS-X

Post by Matt »

Thanks, though it seems like a problem I'm having with GDCC generally in being unable to locate anything.
User avatar
Silentdarkness12
Posts: 1555
Joined: Thu Aug 15, 2013 5:34 pm
Location: Plains of Pride

Re: [Resource/Project] ACS-X

Post by Silentdarkness12 »

Dunno if this is still being supported, but is there some way to make this work with SLADE?

I tried renaming the executable, but it throws the error of unknown source type. I've followed the SLADE instructions, but the error has not changed.
Post Reply

Return to “Resources”