Esempio n. 1
0
void C4Effect::AssignCallbackFunctions() {
  C4AulScript *pSrcScript = GetCallbackScript();
  // compose function names and search them
  char fn[C4AUL_MAX_Identifier + 1];
  sprintf(fn, PSF_FxStart, Name);
  pFnStart = pSrcScript->GetFuncRecursive(fn);
  sprintf(fn, PSF_FxStop, Name);
  pFnStop = pSrcScript->GetFuncRecursive(fn);
  sprintf(fn, PSF_FxTimer, Name);
  pFnTimer = pSrcScript->GetFuncRecursive(fn);
  sprintf(fn, PSF_FxEffect, Name);
  pFnEffect = pSrcScript->GetFuncRecursive(fn);
  sprintf(fn, PSF_FxDamage, Name);
  pFnDamage = pSrcScript->GetFuncRecursive(fn);
}
Esempio n. 2
0
C4Value C4Effect::DoCall(C4Object *pObj, const char *szFn, C4Value &rVal1,
                         C4Value &rVal2, C4Value &rVal3, C4Value &rVal4,
                         C4Value &rVal5, C4Value &rVal6, C4Value &rVal7) {
  // def script or global only?
  C4AulScript *pSrcScript;
  C4Def *pDef;
  if (pCommandTarget) {
    pSrcScript = &pCommandTarget->Def->Script;
    // overwrite ID for sync safety in runtime join
    idCommandTarget = pCommandTarget->id;
  } else if (idCommandTarget && (pDef = Game.Defs.ID2Def(idCommandTarget)))
    pSrcScript = &pDef->Script;
  else
    pSrcScript = &Game.ScriptEngine;
  // compose function name
  char fn[C4AUL_MAX_Identifier + 1];
  sprintf(fn, PSF_FxCustom, Name, szFn);
  // call it
  C4AulFunc *pFn = pSrcScript->GetFuncRecursive(fn);
  if (!pFn)
    return C4Value();
  return pFn->Exec(pCommandTarget,
                   &C4AulParSet(C4VObj(pObj), C4VInt(iNumber), rVal1, rVal2,
                                rVal3, rVal4, rVal5, rVal6, rVal7));
}