How to create a new acs function?

General help and assistance forum.
Post Reply
User avatar
ibm5155
Addicted to Zandronum
Posts: 1641
Joined: Tue Jun 05, 2012 9:32 pm
Location: Somewhere, over the rainbow

How to create a new acs function?

#1

Post by ibm5155 » Sat Dec 28, 2013 11:26 pm

first:I know how to create a new function at doom builder, but now I want to know, how to create a new function that would do things that i wouldn't be able to make on a simple doom builder function...

I have visual studio 2010, and I watched the zdoom or zandronum code (actually the thing that I only get was the nodes functions that I already used, I saw the acs part of the code but for me it looks like a salad and I get lost on it :S

first to get how all that thing work I would create a something like, this

Code: Select all

int acs_test(){
 return 1;
}
Then, where should I put that ? :S and how to make acs compile it?

What I would like to do is a function that would return the player position (not the marine, but where you actually are, like if you're f12 someone, you would get the position where this guy're,...)
I know I could get this data from where id_mypos console command read, so it would be only a matter of pointers...

Well I hope I'm posting it on the right place :s
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!

<this post is proof of "Decline">

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: How to create a new acs function?

#2

Post by Ijon Tichy » Sun Dec 29, 2013 12:13 am

Code: Select all

function int acs_test(void)
{
    return 1;
}
it needs to be top-level (eg. not in a script or another function), but besides that it can be put anywhere
Last edited by Ijon Tichy on Sun Dec 29, 2013 12:16 am, edited 1 time in total.

User avatar
ibm5155
Addicted to Zandronum
Posts: 1641
Joined: Tue Jun 05, 2012 9:32 pm
Location: Somewhere, over the rainbow

RE: How to create a new acs function?

#3

Post by ibm5155 » Sun Dec 29, 2013 12:34 am

I mean something like this

Code: Select all

//============================================================================
//
// GiveInventory
//
// Gives an item to one or more actors.
//
//============================================================================

static void GiveInventory (AActor *activator, const char *type, int amount)
{
	const PClass *info;

	if (amount <= 0 || type == NULL)
	{
		return;
	}
	if (stricmp (type, "Armor") == 0)
	{
		type = "BasicArmorPickup";
	}
	info = PClass::FindClass (type);
	if (info == NULL)
	{
		Printf ("ACS: I don't know what %s is.\n", type);
	}
	else if (!info->IsDescendantOf (RUNTIME_CLASS(AInventory)))
	{
		Printf ("ACS: %s is not an inventory item.\n", type);
	}
	else if (activator == NULL)
	{
		for (int i = 0; i < MAXPLAYERS; ++i)
		{
			if (playeringame[i])
				DoGiveInv (players[i].mo, info, amount);
		}
	}
	else
	{
		DoGiveInv (activator, info, amount);
	}
}
But I would do someone just as a test

Code: Select all

//============================================================================
//
// TestFunction
//
// Return one
//
//============================================================================

static int TestFunction(){
	return 1; // It shouldn't be that simple
}
and then you go to doom builder do print(d:testfunction()); and it would show 1 on screen
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!

<this post is proof of "Decline">

Ijon Tichy
Frequent Poster Miles card holder
Posts: 901
Joined: Mon Jun 04, 2012 5:07 am

RE: How to create a new acs function?

#4

Post by Ijon Tichy » Sun Dec 29, 2013 12:39 am

... that's zandronum's source code.

how the shit do you expect that to work on any binary but yours

User avatar
ibm5155
Addicted to Zandronum
Posts: 1641
Joined: Tue Jun 05, 2012 9:32 pm
Location: Somewhere, over the rainbow

RE: How to create a new acs function?

#5

Post by ibm5155 » Sun Dec 29, 2013 12:44 am

Because I want to learn how people who work on zan/zdoom code make that acs codes to help on the future '-'
Also I could instead of ask for someone to make a new acs function for a new thing and wait some good guy with free time to make it or I could make it, test and see if people would like to see it on zan/zdoom
Last edited by ibm5155 on Sun Dec 29, 2013 12:46 am, edited 1 time in total.
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!

<this post is proof of "Decline">

User avatar
Torr Samaho
Lead Developer
Posts: 1543
Joined: Fri May 25, 2012 6:03 pm
Location: Germany

RE: How to create a new acs function?

#6

Post by Torr Samaho » Sun Jan 05, 2014 11:29 am

The easiest way would be to follow the implementation of the existing "ACSF" functions in p_acs.cpp. In addition to p_acs.cpp, you need to declare the functions in zspecial.acs so that acc knows about the new function.

Unless you have sufficient C/C++ experience I wouldn't recommend you to do so though. First, without knowing how the ZDoom engine works, you are very limited to what kind of ACS function you can create. Second, as Ijon already mentioned, even if you manage to implement a useful ACS function, you need to convince the ZDoom or Zandronum devs to include your function.

User avatar
ibm5155
Addicted to Zandronum
Posts: 1641
Joined: Tue Jun 05, 2012 9:32 pm
Location: Somewhere, over the rainbow

RE: How to create a new acs function?

#7

Post by ibm5155 » Sun Jan 05, 2014 11:53 am

hmm There's two years that I use/study c/c++, I did a c ansi pong and a kind of "engine" (a text engine xD)...
Hmm thanks for the tip, I'll take a look at it, on zdoom/zan engine the thing that I really understand was the nodes and tree functions, the rest are only objects, pointers,... (and the deep part of the code that is the render part for me D:)...
What I want is to make more complex codes, and also I wanted to make some new functions for zdoom/zan as experiments.
Yes I'll need, and I remember requesting some new things for zdoom was really hard to get acepted (even more on skulltag era, idk how is on zan)...
anyway, thanks for the help, I'll try to make that test function :)
Projects
Cursed Maze: DONE, V2.0
Zombie Horde - ZM09 map update: [3/15/13]
Need help with English? Then you've come to the right place!

<this post is proof of "Decline">

Post Reply