[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!

[Resource/Project] ACS-X

Postby The Zombie Killer » Sat May 07, 2016 11:58 am

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 actor flags 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 allExpand view
ptr pointer = NewPtr();
SetPtr(pointer, 25);
int value = ptr_cast(int)(pointer);
FreePtr(pointer); 


Game constants
Code: Select allExpand view
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 allExpand view
#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 allExpand view
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
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [Resource/Project] ACS-X

Postby Kinsie » Sat May 07, 2016 12:31 pm

Impressive. Most impressive!
User avatar
Kinsie
A Concept Utterly Obsolete
 
Joined: 22 Oct 2004
Location: MAP33
Discord: Find Me...

Re: [Resource/Project] ACS-X

Postby The Zombie Killer » Sat May 07, 2016 1:06 pm

Updated, now supports arrays!
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [Resource/Project] ACS-X

Postby Zhs2 » Sat May 07, 2016 1:07 pm

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
Zhs2
Power of meh.
 
Joined: 07 Nov 2008
Location: Maryland, USA, but probably also in someone's mod somewhere
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: ATI/AMD with Vulkan Support

Re: [Resource/Project] ACS-X

Postby The Zombie Killer » Sat May 07, 2016 1:18 pm

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
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [Resource/Project] ACS-X

Postby |ndußtrial » Sat May 07, 2016 1:44 pm

square/virus are also detected as iwads without tweaking!
User avatar
|ndußtrial
 
Joined: 17 Aug 2013
Location: Ivy Mercy Lyons
Discord: IvyMercyLyons#1691
Operating System: Windows 10/8.1/8 64-bit
Graphics Processor: Intel (Modern GZDoom)

Re: [Resource/Project] ACS-X

Postby The Zombie Killer » Sat May 07, 2016 1:50 pm

Added GetBaseGame()
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [Resource/Project] ACS-X

Postby The Zombie Killer » Fri May 20, 2016 2:34 am

Updated
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [Resource/Project] ACS-X

Postby Matt » Sat May 21, 2016 9:05 pm

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
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: [Resource/Project] ACS-X

Postby The Zombie Killer » Sat May 21, 2016 9:54 pm

the same folder as your source files would work. Alternatively, you can pass
Code: Select allExpand view
-i path/to/directory

to gdcc-acc when you compile
User avatar
The Zombie Killer
King of the Kangaroos
 
Joined: 14 Jul 2011
Location: Gold Coast, Queensland, Australia
Discord: Zombie#1795

Re: [Resource/Project] ACS-X

Postby Matt » Sat May 21, 2016 10:53 pm

Thanks, though it seems like a problem I'm having with GDCC generally in being unable to locate anything.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: [Resource/Project] ACS-X

Postby Silentdarkness12 » Mon Nov 07, 2016 10:28 am

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.
User avatar
Silentdarkness12
Level 7: ZScript Victim
 
Joined: 15 Aug 2013
Location: Plains of Pride


Return to Resources

Who is online

Users browsing this forum: Arybaryan2005 and 2 guests