mirror of
https://bitbucket.org/seefoe/dsrc.git
synced 2026-07-31 01:15:55 -04:00
220 lines
5.8 KiB
Plaintext
220 lines
5.8 KiB
Plaintext
/**
|
|
* Title: innate.scriptlib
|
|
* Description: function library for species innate abilities/commands
|
|
*/
|
|
|
|
/***** INCLUDES ********************************************************/
|
|
|
|
include library.prose;
|
|
include library.buff;
|
|
|
|
/***** CONSTANTS *******************************************************/
|
|
|
|
const int ONE_HOUR = 3600;
|
|
const int TWO_HOURS = ONE_HOUR * 2;
|
|
|
|
//DURATION DEFINES
|
|
const float DURATION_REGEN = 300f;
|
|
const float DURATION_ROAR = 300f;
|
|
const float DURATION_VIT = 300f;
|
|
|
|
//VALUE DEFINES
|
|
const int VALUE_VIT_BUFF = 50;
|
|
const int VALUE_EQUALIZE_AMOUNT = 250;
|
|
|
|
//RAMPUP DEFINES
|
|
const float RAMP_REGEN = 30f;
|
|
const float RAMP_VIT = 0f;
|
|
|
|
//OBJVAR DEFINES
|
|
const string VAR_INNATE_BASE = "innate";
|
|
|
|
const string VAR_REGENERATION = VAR_INNATE_BASE + ".regeneration";
|
|
const string VAR_ROAR = VAR_INNATE_BASE + ".roar";
|
|
const string VAR_VITALIZE = VAR_INNATE_BASE + ".vitalize";
|
|
const string VAR_EQUILIBRIUM = VAR_INNATE_BASE + ".equilibrium";
|
|
|
|
//STRING IDS
|
|
const string STF = "innate";
|
|
|
|
const string_id SID_REGEN = new string_id(STF, "regen");
|
|
const string_id SID_ROAR = new string_id(STF, "roar");
|
|
const string_id SID_VIT = new string_id(STF, "vit");
|
|
const string_id SID_EQUIL = new string_id(STF, "equil");
|
|
|
|
/*
|
|
const string REGEN = getString(SID_REGEN);
|
|
const string ROAR = getString(SID_ROAR);
|
|
const string VIT = getString(SID_VIT);
|
|
const string EQUIL = getString(SID_EQUIL);
|
|
*/
|
|
|
|
const string REGEN = "regeneration";
|
|
const string ROAR = "roar";
|
|
const string VIT = "vitalize";
|
|
const string EQUIL = "equilibrium";
|
|
|
|
const string_id PROSE_INNATE_WAIT = new string_id(STF, "innate_wait");
|
|
|
|
const string_id PROSE_INNATE_NA = new string_id(STF, "innate_na");
|
|
|
|
//const string_id SID_REGEN_WAIT = new string_id(STF, "regen_wait");
|
|
const string_id SID_REGEN_ACTIVE = new string_id(STF, "regen_active");
|
|
|
|
//const string_id SID_ROAR_WAIT = new string_id(STF, "roar_wait");
|
|
const string_id SID_ROAR_ACTIVE = new string_id(STF, "roar_active");
|
|
|
|
//const string_id SID_VIT_WAIT = new string_id(STF, "vit_wait");
|
|
const string_id SID_VIT_ACTIVE = new string_id(STF, "vit_active");
|
|
|
|
//const string_id SID_EQUIL_WAIT = new string_id(STF, "equil_wait");
|
|
const string_id SID_EQUIL_ACTIVE = new string_id(STF, "equil_active");
|
|
|
|
//COMMAND DEFINES
|
|
const string[] INNATE_CMD = {
|
|
EQUIL,
|
|
REGEN,
|
|
ROAR,
|
|
VIT}; //list in alpha order!!
|
|
|
|
//ANTI-MOD RETURN CODES
|
|
const int AMR_ERROR = -1;
|
|
const int AMR_CONTINUE = 0; //apply normally
|
|
const int AMR_OVERRIDE = 1; //do not apply
|
|
const int AMR_AMPLIFY = 2; //OUCH!
|
|
|
|
/***** FUNCTIONS *******************************************************/
|
|
/***********************************************************************
|
|
* @brief activates innate regeneration ability
|
|
*
|
|
* @return boolean; false on unable to add
|
|
***********************************************************************/
|
|
string parseInnateCommand(string txt)
|
|
{
|
|
if ( (txt == null) || (txt.equals("")) )
|
|
return null;
|
|
|
|
for ( int i = 0; i < INNATE_CMD.length; i++ )
|
|
{
|
|
if ( INNATE_CMD[i].startsWith(txt) )
|
|
return INNATE_CMD[i];
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* @brief activates innate regeneration ability
|
|
*
|
|
* @return boolean; false on unable to add
|
|
***********************************************************************/
|
|
boolean regeneration()
|
|
{
|
|
obj_id self = getSelf();
|
|
|
|
if(buff.hasBuff(self, "innate_regeneration"))
|
|
return false;
|
|
|
|
if(buff.applyBuff(self, "innate_regeneration"))
|
|
{
|
|
sendCombatSpamMessage(self, SID_REGEN_ACTIVE, COMBAT_RESULT_GENERIC);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* @brief activates innate vitalize ability
|
|
*
|
|
* @return boolean; false on unable to add
|
|
***********************************************************************/
|
|
boolean vitalize()
|
|
{
|
|
obj_id self = getSelf();
|
|
|
|
if(buff.hasBuff(self, "innate_vitalize"))
|
|
return false;
|
|
|
|
if(buff.applyBuff(self, "innate_vitalize"))
|
|
{
|
|
sendCombatSpamMessage(self, SID_VIT_ACTIVE, COMBAT_RESULT_GENERIC);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/***********************************************************************
|
|
* @brief activates innate equilibrium ability
|
|
*
|
|
* @return boolean; false on unable to add
|
|
***********************************************************************/
|
|
boolean equilibrium()
|
|
{
|
|
obj_id self = getSelf();
|
|
|
|
equalizeEffect(self);
|
|
|
|
sendCombatSpamMessage(self, SID_EQUIL_ACTIVE, COMBAT_RESULT_GENERIC);
|
|
return true;
|
|
}
|
|
|
|
void equalizeEffect(obj_id player)
|
|
{
|
|
if(!isIdValid(player))
|
|
return;
|
|
|
|
if(getAttrib(player, HEALTH) <= VALUE_EQUALIZE_AMOUNT)
|
|
return;
|
|
|
|
addAttribModifier(player, HEALTH, (-1 * VALUE_EQUALIZE_AMOUNT), 0, 0, MOD_POOL);
|
|
addAttribModifier(player, ACTION, VALUE_EQUALIZE_AMOUNT, 0, 0, MOD_POOL);
|
|
}
|
|
|
|
/***********************************************************************
|
|
* @brief does whacktacular logic for anti-mods
|
|
*
|
|
* @return int; -1 on error
|
|
***********************************************************************/
|
|
int doAntiModCheck(obj_id target, string skill_mod)
|
|
{
|
|
if ( !isIdValid(target) || (skill_mod == null) || (skill_mod.equals("")) )
|
|
{
|
|
return AMR_ERROR;
|
|
}
|
|
|
|
int val = getSkillStatMod(target, skill_mod);
|
|
if ( val < 0 )
|
|
{
|
|
//return AMR_AMPLIFY;
|
|
return AMR_CONTINUE;
|
|
}
|
|
else if ( val == 0 )
|
|
{
|
|
return AMR_CONTINUE;
|
|
}
|
|
|
|
int roll = rand(1,100);
|
|
if ( val > 0 && val <= 100 )
|
|
{
|
|
if ( roll < val && roll <= 95 )
|
|
{
|
|
return AMR_OVERRIDE;
|
|
}
|
|
|
|
return AMR_CONTINUE;
|
|
}
|
|
else if ( val > 100 )
|
|
{
|
|
if ( roll < (95 + ((val-100)/10)) )
|
|
{
|
|
return AMR_OVERRIDE;
|
|
}
|
|
|
|
return AMR_CONTINUE;
|
|
}
|
|
|
|
return AMR_ERROR;
|
|
}
|