85 lines
2.0 KiB
Plaintext
85 lines
2.0 KiB
Plaintext
#include "x2_inc_switches"
|
|
#include "adv_include"
|
|
|
|
// This fires when a player uses an herb. It will recover HP or remove poison depending on its type.
|
|
// All herbs should have a tag named the same as this script.
|
|
// First Aid Sprays also fall under this script.
|
|
|
|
void main()
|
|
{
|
|
if (GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE) return;
|
|
|
|
object oPC = GetItemActivator();
|
|
object oTarget = GetItemActivatedTarget();
|
|
object oItem = GetItemActivated();
|
|
string sResref = GetResRef(oItem);
|
|
float fRecovery;
|
|
int bRemovePoison = FALSE;
|
|
int iSkill = ADV_GetUpgradeLevel(oPC, ADV_ID_FIRST_AID);
|
|
|
|
// Green Herb
|
|
if(sResref == "green_herb")
|
|
{
|
|
fRecovery = 0.25;
|
|
}
|
|
// Blue Herb
|
|
else if(sResref == "blue_herb")
|
|
{
|
|
bRemovePoison = TRUE;
|
|
}
|
|
// Green + Red
|
|
else if(sResref == "gr_herb")
|
|
{
|
|
fRecovery = 0.80;
|
|
}
|
|
// Green + Green
|
|
else if(sResref == "gg_herb")
|
|
{
|
|
fRecovery = 0.55;
|
|
}
|
|
// Green + Green + Green
|
|
else if(sResref == "ggg_herb")
|
|
{
|
|
fRecovery = 0.75;
|
|
}
|
|
// Green + Red + Blue
|
|
else if(sResref == "grb_herb")
|
|
{
|
|
fRecovery = 0.80;
|
|
bRemovePoison = TRUE;
|
|
}
|
|
// Green + Blue
|
|
else if(sResref == "gb_herb")
|
|
{
|
|
fRecovery = 0.25;
|
|
bRemovePoison = TRUE;
|
|
}
|
|
|
|
// First Aid Spray
|
|
else if(sResref == "first_aid_spray")
|
|
{
|
|
fRecovery = 100.0;
|
|
}
|
|
|
|
// Herb removes poison - remove it!
|
|
if(bRemovePoison)
|
|
{
|
|
}
|
|
|
|
// Herb restores HP - heal PC!
|
|
if(fRecovery > 0.0)
|
|
{
|
|
// First Aid skill grants +1% to recovery per level
|
|
if(iSkill > 0 && fRecovery < 100.0)
|
|
{
|
|
fRecovery = fRecovery + (fRecovery * 0.01);
|
|
}
|
|
|
|
int iRecovery = FloatToInt(GetMaxHitPoints(oTarget) * fRecovery);
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectHeal(iRecovery), oTarget);
|
|
}
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_REMOVE_CONDITION), oTarget);
|
|
|
|
DestroyObject(oItem);
|
|
}
|