mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
177 lines
4.0 KiB
Plaintext
177 lines
4.0 KiB
Plaintext
/**********************************************************************
|
|
|
|
*
|
|
* Title: player_dot
|
|
* Description: Script is attached to a target that has a dot effect
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
include library.buff;
|
|
include library.dot;
|
|
include library.utils;
|
|
include library.trial;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
|
|
/***** TRIGGERS ********************************************************/
|
|
trigger OnInitialize()
|
|
{
|
|
// Restart the dot messages for all dot_id's on the target.
|
|
string[] dot_ids = dot.getAllDots(self);
|
|
if (dot_ids != null)
|
|
{
|
|
for (int i = 0; i < dot_ids.length; i++)
|
|
{
|
|
string type = dot.getDotType(self, dot_ids[i]);
|
|
|
|
if(!type.equals(dot.DOT_DISEASE))
|
|
{
|
|
int pulse = dot.getDotPulse(self, dot_ids[i]);
|
|
dictionary d = new dictionary();
|
|
d.put("dot_id", dot_ids[i]);
|
|
d.put("pulse", pulse);
|
|
messageTo(self, "OnDotPulse", d, pulse, false);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
detachScript(self, dot.SCRIPT_PLAYER_DOT);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnDetach()
|
|
{
|
|
if (utils.hasScriptVar(self, dot.SCRIPT_VAR_DOT_GRACE))
|
|
utils.removeScriptVar(self, dot.SCRIPT_VAR_DOT_GRACE);
|
|
|
|
// Make sure all dot states are clear
|
|
setState(self, STATE_BLEEDING, false);
|
|
setState(self, STATE_POISONED, false);
|
|
setState(self, STATE_DISEASED, false);
|
|
setState(self, STATE_ON_FIRE, false);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnEnterSwimming()
|
|
{
|
|
//LOG("LOG_CHANNEL", "player_dot::OnEnterSwimming -- " + self);
|
|
|
|
// Swimming puts out fires.
|
|
if (dot.isOnFire(self))
|
|
{
|
|
dot.reduceDotTypeStrength(self, dot.DOT_FIRE, 10000);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
trigger OnAttribModDone(string modName, boolean isDead)
|
|
{
|
|
if(false)//modName.startsWith("dot.disease"))
|
|
{
|
|
string[] parts = split(modName, '.');
|
|
|
|
if(parts.length < 3)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
string dot_id = parts[2];
|
|
|
|
dot.removeDotEffect(self, dot_id, true);
|
|
}
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/***** MESSAGEHANDLERS *************************************************/
|
|
messageHandler OnDotPulse()
|
|
{
|
|
if (params == null)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
string dot_id;
|
|
if (params.containsKey("dot_id"))
|
|
dot_id = params.getString("dot_id");
|
|
else
|
|
return SCRIPT_CONTINUE;
|
|
|
|
int pulse;
|
|
if (params.containsKey("pulse"))
|
|
pulse = params.getInt("pulse");
|
|
else
|
|
return SCRIPT_CONTINUE;
|
|
|
|
if (dot.applyDotDamage(self, dot_id))
|
|
{
|
|
// If we're DoT'd by a player keep us in combat while the DoT pulses.
|
|
obj_id attacker = params.getObjId("attacker");
|
|
if(isPlayer(attacker) && exists(attacker) )
|
|
{
|
|
addHate(self, attacker, 0.0f);
|
|
addHate(attacker, self, 0.0f);
|
|
}
|
|
messageTo(self, "OnDotPulse", params, pulse, false);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler OnBuffDotPulse()
|
|
{
|
|
if (params == null)
|
|
return SCRIPT_CONTINUE;
|
|
|
|
|
|
if(!trial.verifySession(self, params, params.getString("buffName")))
|
|
return SCRIPT_CONTINUE;
|
|
|
|
|
|
obj_id caster = params.getObjId("caster");
|
|
string buffName = params.getString("buffName");
|
|
int strength = params.getInt("strength");
|
|
string type = params.getString("type");
|
|
|
|
if(!buff.hasBuff(self, buffName))
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
long stackCount = buff.getBuffStackCount(self, buffName);
|
|
|
|
strength *= stackCount;
|
|
|
|
if (dot.applyBuffDotDamage(self, caster, buffName, strength, type))
|
|
{
|
|
// If we're DoT'd by a player keep us in combat while the DoT pulses.
|
|
obj_id attacker = params.getObjId("attacker");
|
|
if(isPlayer(attacker) && exists(attacker) )
|
|
{
|
|
addHate(self, attacker, 0.0f);
|
|
addHate(attacker, self, 0.0f);
|
|
}
|
|
messageTo(self, "OnBuffDotPulse", params, buff.BUFF_DOT_TICK, false);
|
|
}
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler bleedingStopped()
|
|
{
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
messageHandler OnDotGraceEnd()
|
|
{
|
|
if (utils.hasScriptVar(self, dot.SCRIPT_VAR_DOT_GRACE))
|
|
utils.removeScriptVar(self, dot.SCRIPT_VAR_DOT_GRACE);
|
|
|
|
return SCRIPT_CONTINUE;
|
|
}
|
|
|
|
/***** COMMANDHANDLERS *************************************************/
|
|
|
|
|
|
/***** FUNCTIONS *******************************************************/
|