Ok just got home. Sorry bout that bug. Good catch Lightfoot.
So here it is again with the needed return statement that Lightfoot caught and some commenting.
I also added another important part that I forgot. Destroying the used heal kit.
I also added a check to make sure that the target is a player.
#include "x2_inc_switches"
void main()
{
//"tag based" check to make sure this is firing due to an activated item int nEvent =GetUserDefinedItemEventNumber();
if (nEvent != X2_ITEM_EVENT_ACTIVATE) return;
//Get the PC that activated the healing kit: object oPC = GetItemActivator();
//Get the target of the healing kit: object oTarget = GetItemActivatedTarget();
//If the target is not a player then send the user a message and return. if (!GetIsPC(oTarget))
{
SendMessageToPC(oPC, "This is not a valid target. Please select a valid player.");
return;
}
//Get the healing kit: object oHealKit = GetItemActivated();
//Get the current hitpoints of your healing kit target: int iHP = GetCurrentHitPoints(oTarget);
//Create your formula for how many hitpoints to heal here. This is how much //you want your healing kit to heal a person based on the formula you create. //Examples: //int iHealPoints = 10;//This just heals 10 points. //int iHealPoints = 1 * GetHitDice(oPC);//this would heal 1 HP per user level int iHealPoints = GetSkillRank(SKILL_HEAL, oPC);//this would heal same as heal skill rank
//If the target has less than or equal to -10 HP then they are dead and the //healing kit won't work. They need to be resurrected or raised. if (iHP <= -10)
{
SendMessageToPC(oPC, "This target can not be healed or stabalized.");
return;
}
//If the target has between 0 and -9 HP they are bleeding and will be healed //to 1 HP(Stabalize). Also destroys the used healing kit. if (iHP < 1 && iHP > -10)
{
int iNew = (iHP - iHP) + 1;
effect eHeal = EffectHeal(iNew);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
DestroyObject(oHealKit);
return;
}
//If the user is not in combat and the target has 1 or more HPs then this //part will be applied and will heal the target based on the formula above. //Also destroys the used healing kit. if (!GetIsInCombat(oPC))
{
effect eHeal = EffectHeal(iHealPoints);
ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
DestroyObject(oHealKit);
}
//If the player is in combat or perhaps for some other reason then just send //this message. else
{
SendMessageToPC(oPC, "You can not use this item at this time.");
}
}
Modifié par GhostOfGod, 07 novembre 2010 - 03:07 .