ACS_NamedExecuteWithResult

From ZDoom Wiki
(Redirected from CallACS)
Jump to: navigation, search

int ACS_NamedExecuteWithResult (string script, int s_arg1, int s_arg2, int s_arg3, int s_arg4)

Usage

Variant of ACS_ExecuteWithResult for named scripts.

There is both an ACS and a DECORATE version of this function. Both behave identically. The DECORATE version can also be called by the shorter alias CallACS in DECORATE expressions.

ACS_(Named)ExecuteWithResult has one small difference aside returning a value. They execute immediately once called, while the other types will usually wait a tic before acting.

However, it is not available as an action special: to call named scripts from a a line or thing special, you have to use the non-named variant (ACS_ExecuteWithResult) in UDMF, with the arg0str custom argument set to the name of the script — this will override the first parameter.

Parameters

  • script: Name of the script to execute
  • s_arg1: First argument passed to the script
  • s_arg2: Second argument passed to the script
  • s_arg3: Third argument passed to the script
  • s_arg4: Fourth argument passed to the script

Return value

Returns the return value of the executed script. See SetResultValue.

Examples

This example shows an item similar to Hexen's Mystic Ambit item: Checks which player class uses an item and having a different effect.

Decorate Item:

Actor ClassBoost : CustomInventory
{
  Inventory.MaxAmount 25
  Inventory.InterHubAmount 25
  +INVENTORY.INVBAR
  Inventory.Icon "ARTIHRAD"
  States
  {
  Spawn:
    HRAD ABCDEFGHIJKLMNOP 4 Bright
    Loop
  Use:
    TNT1 A 0 A_JumpIf(CallACS("CheckPlayerClass", 0, 0, 0) == 0, "NormalPlayer")
    TNT1 A 0 A_JumpIf(CallACS("CheckPlayerClass", 0, 0, 0) == 1, "AlternatePlayer")
    Fail
  NormalPlayer:
    TNT1 A 0 A_RadiusGive("Health", 256, RGF_PLAYERS | RGF_GIVESELF, random(50, 90))
    Stop
  AlternatePlayer:
    TNT1 A 0 A_RadiusGive("PowerImproveDamage", 256, RGF_PLAYERS | RGF_GIVESELF, 1)
    Stop
  }
}

ACS Script:

script "CheckPlayerClass" (void)
{
  if(CheckActorClass(0, "DoomPlayer"))
  {
    SetResultValue(0);
    terminate;
  }
  else if(CheckActorClass(0, "AlternateDoomPlayer"))
  {
    SetResultValue(1);
    terminate;
  }
}
Script functions
ACS_Execute ACS_NamedExecute
ACS_ExecuteWait ACS_NamedExecuteWait
ACS_ExecuteAlways ACS_NamedExecuteAlways
ACS_ExecuteWithResult ACS_NamedExecuteWithResult
ACS_LockedExecute ACS_NamedLockedExecute
ACS_LockedExecuteDoor ACS_NamedLockedExecuteDoor
ACS_Suspend ACS_NamedSuspend
ACS_Terminate ACS_NamedTerminate
ScriptWait NamedScriptWait
FS_Execute UsePuzzleItem