mirror of
https://github.com/SWG-Source/dsrc.git
synced 2026-07-31 00:15:54 -04:00
144 lines
4.2 KiB
Plaintext
144 lines
4.2 KiB
Plaintext
include library.utils;
|
|
include library.combat;
|
|
|
|
trigger OnAttach()
|
|
{
|
|
obj_id[] me = new obj_id[]{self};
|
|
playClientEffectObj(me, "appearance/pt_special_attack_volley_fire.prt", self, "", new transform(), combat.ID_VOLLEY_FIRE_PARTICLE);
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnInitialize()
|
|
{
|
|
detachScript(self, "systems.combat.volleytarget");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
void notifyVolleyTargetDone()
|
|
{
|
|
//LOG("combat", "notifyVolleyTargetDone()");
|
|
obj_id self = getSelf();
|
|
Vector groups = utils.getResizeableObjIdBatchScriptVar(self, combat.VAR_VOLLEY_GROUPS);
|
|
utils.removeScriptVar(self, combat.VAR_VOLLEY_GROUPS);
|
|
|
|
// message all the group objects that I've died (which, in turn, will message all the group members)
|
|
for(int i = 0; i < groups.size(); i++)
|
|
{
|
|
notifyVolleyTargetDone((obj_id)groups.get(i));
|
|
}
|
|
}
|
|
|
|
void notifyVolleyTargetDone(obj_id group)
|
|
{
|
|
//LOG("combat", "notifyVolleyTargetDone(" + group + ")");
|
|
dictionary parms = new dictionary();
|
|
parms.put("objTarget", getSelf());
|
|
//LOG("combat", "Messaging group " + group + " with 'volleyTargetDone'");
|
|
messageTo(group, "volleyTargetDone", parms, 0, false);
|
|
}
|
|
|
|
// For player targets
|
|
messageHandler handlePlayerDeath()
|
|
{
|
|
//LOG("combat", "player volley target died. killing particle playing on " + self + " for client " + self);
|
|
// Stop playing the target particle on me
|
|
stopClientEffectObjByLabel(new obj_id[]{self}, self, combat.ID_VOLLEY_FIRE_PARTICLE);
|
|
notifyVolleyTargetDone();
|
|
|
|
// detach target script
|
|
//LOG("combat", "detaching volley fire target from " + self);
|
|
detachScript(self, "systems.combat.volleytarget");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// For NPC targets
|
|
trigger OnIncapacitated(obj_id killer)
|
|
{
|
|
if(isPlayer(self))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
stopClientEffectObjByLabel(new obj_id[]{self}, self, combat.ID_VOLLEY_FIRE_PARTICLE);
|
|
notifyVolleyTargetDone();
|
|
|
|
// detach target script
|
|
detachScript(self, "systems.combat.volleytarget");
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Sent by a squad leader when the target is marked by the group
|
|
messageHandler msgMarkedByGroup()
|
|
{
|
|
//LOG("combat", "" + self + " received msgMarkedByGroup");
|
|
obj_id group = params.getObjId("objGroup");
|
|
//LOG("combat", "marked by group " + group);
|
|
if(!isIdValid(group))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
Vector groups = new Vector();
|
|
if(utils.hasScriptVar(self, combat.VAR_VOLLEY_GROUPS))
|
|
{
|
|
groups = utils.getResizeableObjIdBatchScriptVar(self, combat.VAR_VOLLEY_GROUPS);
|
|
}
|
|
//LOG("combat", "Currently have " + groups.size() + " groups targeting me");
|
|
if(groups.indexOf(group) > -1)
|
|
{
|
|
//LOG("combat", "group " + group + " is already in grouplist. not adding again.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
groups.add(group);
|
|
//LOG("combat", "Now have " + groups.size() + " groups targeting me.");
|
|
utils.setBatchScriptVar(self, combat.VAR_VOLLEY_GROUPS, groups);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
// Arrives when the target is unmarked by the group
|
|
messageHandler msgUnmarkedByGroup()
|
|
{
|
|
//LOG("combat", "received msgUnmarkedByGroup()");
|
|
obj_id group = params.getObjId("objGroup");
|
|
//LOG("combat", "Unmarked by group " + group);
|
|
if(!isIdValid(group))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
Vector groups = new Vector();
|
|
if(utils.hasScriptVar(self, combat.VAR_VOLLEY_GROUPS))
|
|
{
|
|
groups = utils.getResizeableObjIdBatchScriptVar(self, combat.VAR_VOLLEY_GROUPS);
|
|
}
|
|
|
|
//LOG("combat", "Currently " + groups.size() + " groups in target list.");
|
|
if(groups.indexOf(group) < 0)
|
|
{
|
|
//LOG("combat", "unable to find group " + group + " in target list. Shouldn't happen.");
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
groups.remove(group);
|
|
//LOG("combat", "Removed group from list, now " + groups.size() + " groups left in target list.");
|
|
if(groups.size() < 1)
|
|
{
|
|
//LOG("combat", "Removing all group target scriptvars.");
|
|
utils.removeScriptVar(self, combat.VAR_VOLLEY_GROUPS);
|
|
//LOG("combat", "Stopping client effect playing on " + self + " playing for client " + self);
|
|
stopClientEffectObjByLabel(self, self, combat.ID_VOLLEY_FIRE_PARTICLE);
|
|
// client,objectPlayingEffect,
|
|
detachScript(self, "systems.combat.volleytarget");
|
|
}
|
|
else
|
|
{
|
|
utils.setBatchScriptVar(self, combat.VAR_VOLLEY_GROUPS, groups);
|
|
}
|
|
|
|
notifyVolleyTargetDone(group);
|
|
return SCRIPT_CONTINUE;
|
|
} |