mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
240 lines
5.3 KiB
Plaintext
240 lines
5.3 KiB
Plaintext
include library.utils;
|
|
include ai.ai_combat;
|
|
|
|
|
|
const int STOP_SEQUENCE = -1;
|
|
const int CHANGE_TABLE = -2;
|
|
obj_id getSequenceObject(string strIdentifier)
|
|
{
|
|
return getSequenceObject(getSelf(), strIdentifier);
|
|
|
|
}
|
|
obj_id getSequenceObject(obj_id self, string strIdentifier)
|
|
{
|
|
obj_id objMaster = getMasterSequenceObject(self);
|
|
if (!isIdValid(objMaster))
|
|
{
|
|
return null;
|
|
}
|
|
return utils.getObjIdScriptVar(objMaster, strIdentifier);
|
|
}
|
|
|
|
boolean registerSequenceObject(obj_id objObject, string strIdentifier)
|
|
{
|
|
obj_id objMaster = getMasterSequenceObject(objObject);
|
|
|
|
if(!isIdValid(objMaster))
|
|
{
|
|
return false;
|
|
}
|
|
utils.setScriptVar(objObject, "objMasterSequenceObject", objMaster);
|
|
utils.setScriptVar(objMaster, strIdentifier, objObject);
|
|
return true;
|
|
}
|
|
|
|
boolean registerSequenceObject(obj_id objObject)
|
|
{
|
|
if(hasObjVar(objObject, "strSequenceIdentifier"))
|
|
{
|
|
return registerSequenceObject(objObject, getStringObjVar(objObject, "strSequenceIdentifier"));
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
boolean cleanUpSequenceObject(obj_id objObject)
|
|
{
|
|
if(hasObjVar(objObject, "strSequenceIdentifier"))
|
|
{
|
|
return cleanUpSequenceObject(objObject, getStringObjVar(objObject,"strSequenceIdentifier"));
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
boolean cleanUpSequenceObject(obj_id objObject, string strIdentifier)
|
|
{
|
|
obj_id objMaster = getMasterSequenceObject(objObject);
|
|
return utils.removeScriptVar(objMaster, strIdentifier);
|
|
|
|
}
|
|
obj_id getMasterSequenceObject(obj_id objObject)
|
|
{
|
|
if(utils.hasScriptVar(objObject, "objMasterSequencerObject"))
|
|
{
|
|
return utils.getObjIdScriptVar(objObject, "objMasterSequenceObject");
|
|
}
|
|
// for now we only support interiors.
|
|
obj_id objMaster = getTopMostContainer(objObject);
|
|
LOG("npe", "objMaster is "+objMaster);
|
|
|
|
if (!isIdValid(objMaster))
|
|
{
|
|
return objObject;
|
|
}
|
|
|
|
return objMaster;
|
|
|
|
|
|
}
|
|
|
|
|
|
boolean isValidSequenceIdentifier(string strIdentifier)
|
|
{
|
|
obj_id objMaster = getMasterSequenceObject(getSelf());
|
|
if(isIdValid(objMaster))
|
|
{
|
|
return utils.hasScriptVar(objMaster, strIdentifier);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void walkToSequenceObject(obj_id objNPC, obj_id objSeq)
|
|
{
|
|
location locWalkTo = getLocation(objSeq);
|
|
pathTo(objNPC, locWalkTo);
|
|
}
|
|
|
|
void walkToSequenceObject(obj_id objNPC, string strObject)
|
|
{
|
|
obj_id objSeq = getSequenceObject(strObject);
|
|
walkToSequenceObject(objNPC, objSeq);
|
|
}
|
|
|
|
void runToSequenceObject(obj_id objNPC, obj_id objSeq)
|
|
{
|
|
location locWalkTo = getLocation(objSeq);
|
|
setMovementRun(objNPC);
|
|
pathTo(objNPC, locWalkTo);
|
|
}
|
|
void runToSequenceObject(obj_id objNPC, string strObject)
|
|
{
|
|
obj_id objSeq = getSequenceObject(strObject);
|
|
runToSequenceObject(objNPC, objSeq);
|
|
}
|
|
void doCombatAnimation(obj_id objNPC, obj_id objSeq, string strAnimation)
|
|
{
|
|
if (isDead(objNPC))
|
|
return;
|
|
|
|
if(!exists(objNPC))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (isIdValid(objNPC) && isIdValid(objSeq))
|
|
{
|
|
//doCombatResults(String animationId, attacker_results attackerResult, defender_results[] defenderResult);
|
|
attacker_results cbtAttackerResults = makeDummyAttackerResults(objNPC);
|
|
defender_results[] cbtDefenderResults = makeDummyDefenderResults(objSeq);
|
|
|
|
if (!isIdValid(cbtAttackerResults.id) || !isIdValid(cbtDefenderResults[0].id))
|
|
return;
|
|
|
|
//doCombatResults("fire_burst", cbtAttackerResults, cbtDefenderResults);
|
|
doCombatResults(strAnimation, cbtAttackerResults, cbtDefenderResults);
|
|
//doCombatResults("fire_5_single_medium_face", cbtAttackerResults, cbtDefenderResults);
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
void doCombatAnimation(obj_id objNPC, string strObject, string strAnimation)
|
|
{
|
|
obj_id objSeq = getSequenceObject(strObject);
|
|
doCombatAnimation(objSeq, objNPC, strAnimation);
|
|
}
|
|
|
|
|
|
void faceToSequenceObject(obj_id objNPC, string strObject)
|
|
{
|
|
obj_id objSeq = getSequenceObject(strObject);
|
|
faceTo(objNPC, objSeq);
|
|
return;
|
|
}
|
|
attacker_results makeDummyAttackerResults(obj_id objAttacker)
|
|
{
|
|
attacker_results cbtAttackerResults = new attacker_results();
|
|
cbtAttackerResults.id = objAttacker;
|
|
cbtAttackerResults.weapon = getCurrentWeapon(objAttacker);
|
|
LOG("npe", "weapon is "+getCurrentWeapon(objAttacker));
|
|
cbtAttackerResults.endPosture = getPosture(objAttacker);
|
|
|
|
return cbtAttackerResults;
|
|
}
|
|
defender_results[] makeDummyDefenderResults(obj_id objDefender)
|
|
{
|
|
defender_results[] cbtDefenderResults = new defender_results[1];
|
|
cbtDefenderResults[0] = new defender_results();
|
|
cbtDefenderResults[0].id = objDefender;
|
|
cbtDefenderResults[0].endPosture=0;
|
|
cbtDefenderResults[0].result = COMBAT_RESULT_HIT;
|
|
cbtDefenderResults[0].damageAmount =0;
|
|
cbtDefenderResults[0].hitLocation = 0;
|
|
|
|
return cbtDefenderResults;
|
|
|
|
}
|
|
|
|
|
|
defender_results[] makeDummyMissDefenderResults(obj_id objDefender)
|
|
{
|
|
defender_results[] cbtDefenderResults = new defender_results[1];
|
|
cbtDefenderResults[0] = new defender_results();
|
|
cbtDefenderResults[0].id = objDefender;
|
|
cbtDefenderResults[0].endPosture=0;
|
|
cbtDefenderResults[0].result = COMBAT_RESULT_MISS;
|
|
cbtDefenderResults[0].damageAmount =0;
|
|
cbtDefenderResults[0].hitLocation = 0;
|
|
return cbtDefenderResults;
|
|
}
|
|
|
|
|
|
|
|
void continueEventSequence(string strContinueTag)
|
|
{
|
|
obj_id self = getSelf();
|
|
obj_id objMaster = getMasterSequenceObject(self);
|
|
dictionary dctParams = new dictionary();
|
|
dctParams.put("strContinueTag", strContinueTag);
|
|
messageTo(objMaster, "doEvents", dctParams, 0, false);
|
|
return;
|
|
}
|
|
|
|
void stopSequence(obj_id objTarget)
|
|
{
|
|
messageTo(objTarget, "interruptSequence", null, 0, false);
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|