Page 1 of 1
How to create a new acs function?
Posted: Sat Dec 28, 2013 11:26 pm
by ibm5155
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
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
RE: How to create a new acs function?
Posted: Sun Dec 29, 2013 12:13 am
by Ijon Tichy
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
RE: How to create a new acs function?
Posted: Sun Dec 29, 2013 12:34 am
by ibm5155
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
RE: How to create a new acs function?
Posted: Sun Dec 29, 2013 12:39 am
by Ijon Tichy
... that's zandronum's source code.
how the shit do you expect that to work on any binary but yours
RE: How to create a new acs function?
Posted: Sun Dec 29, 2013 12:44 am
by ibm5155
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
RE: How to create a new acs function?
Posted: Sun Jan 05, 2014 11:29 am
by Torr Samaho
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.
RE: How to create a new acs function?
Posted: Sun Jan 05, 2014 11:53 am
by ibm5155
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 :)