Author Topic: Custom healing kit script help  (Read 729 times)

Legacy_SuperFly_2000

  • Hero Member
  • *****
  • Posts: 1292
  • Karma: +0/-0
Custom healing kit script help
« on: November 06, 2010, 02:05:06 pm »


               Let's face it. The healing kits are too good. At least on a low to medium magic server.

I could crank up the price a bit for them...but still don't like how they can easily be used in combat without getting any attacks of opportunity and they also heal too much HP.

I guess they easiest way would be to make sure to remove the healing kits from all the shops and so on and make custom ones with a script on.

I would like them to not be able to use in combat, only for stabilizing bleeding (downed/unconsious) party members. Outside of combat they should work pretty much like normal healing kits, just heal less.

Could probably have healing kits +1 and maybe +2 as well...

Any easy way of scripting this?
               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Custom healing kit script help
« Reply #1 on: November 06, 2010, 02:18:11 pm »


               There is a search feature on the Vault....

Just typed in Healing kits and these popped up.






Custom Healing Kit

Kilana

07-18-2006 / 11-22-2006
Requires: TAG Based Scripting Enabled. This special "Healer's Kit" script is meant to be an alter...

Leo's Healing Kits

Leomist

09-18-2007 / 09-19-2007
The Healing kit System was created by myself Leomist. Unlike the original Healing kit this one is...

While Leo is a nice guy I would look at Kilana's stuff as she is underrated but I would bet her material is what your looking for.
               
               

               
            

Legacy_SuperFly_2000

  • Hero Member
  • *****
  • Posts: 1292
  • Karma: +0/-0
Custom healing kit script help
« Reply #2 on: November 06, 2010, 03:25:52 pm »


               I checked all thoose already (probably should have written that I had checked them)...they don't do what I want....
               
               

               


                     Modifié par SuperFly_2000, 06 novembre 2010 - 03:26 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Custom healing kit script help
« Reply #3 on: November 06, 2010, 05:13:49 pm »


               You could try something like this on a custom tag based healing kit. Just whipped it up and haven't tested:

#include "x2_inc_switches"
void main()
{
    int nEvent =GetUserDefinedItemEventNumber();
    if (nEvent != X2_ITEM_EVENT_ACTIVATE) return;

    object oPC = GetItemActivator();
    object oTarget = GetItemActivatedTarget();
    int iHP = GetCurrentHitPoints(oTarget);
    //Create your formula for how many hitpoints to heal here. Examples:
    //int iHealPoints = 10;
    //int iHealPoints = 1 * GetHitDice(oPC);
    int iHealPoints = GetSkillRank(SKILL_HEAL, oPC);

    if (iHP <= -10)
    {
        SendMessageToPC(oPC, "This target can not be healed or stabalized.");
        return;
    }
    if (iHP < 1 && iHP > -10)
    {
        int iNew = (iHP - iHP) + 1;
        effect eHeal = EffectHeal(iNew);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
    }
    if (!GetIsInCombat(oPC))
    {
        effect eHeal = EffectHeal(iHealPoints);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
    }
    else
    {
        SendMessageToPC(oPC, "You can not use this item at this time.");
    }
}

It's a start at least. I'd comment it for you but I'm going to be late for work. ':lol:'

Good luck.
               
               

               
            

Legacy_SuperFly_2000

  • Hero Member
  • *****
  • Posts: 1292
  • Karma: +0/-0
Custom healing kit script help
« Reply #4 on: November 06, 2010, 11:05:01 pm »


               Ahh...ok thanks so far.

I would like some explanation of what this does or some commenting if possible.

(I am not exactly sure how the default healing kits work exactly either...I only feel it might be a tad too much....probably around half of the healing is enough from them or at least 1/3 less or something.)

Take your time...I'm in no rush...



I still haven't decided if to use custom content or not for the module or to even start working for another PW. Heh...oh well....guess I have a long way to go. I actually always wanted to make my own PW but time is always short...
               
               

               


                     Modifié par SuperFly_2000, 06 novembre 2010 - 11:33 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Custom healing kit script help
« Reply #5 on: November 07, 2010, 12:24:52 am »


               The original Heal Kits heal a skill roll + Heal Kit bouns + Heal Skill rank.

d20 + Heal Rank+ KitBouns.

In combat the d20 is rolled for a random effect.
Out of combat the d20 is normally given as a 'take 20' to heal full amount the heal kit can heal.

GoG's script.
If the pc has less then 10 Hp sends a message "This target can not be healed or stabalized." then exists the script.

If the PC has between 0 and -9 hp it will heal him for the amount set above in the script.

It then checks to see it the PC is in combat.
If the PC is in combat it sends a message "You can not use this item at this time."
if he is not in combat it heals him for the amount set above.

Minor bug in the script.

If a PC is bleeding (HPs 0 to -9) he will be either healed twice or healed once and given the message "You can not use this item at this time.". The Bleading section of the code really need a return statment in it.
Out side of the minor bug it is a good script and realy only needs a better explaintion of how you want to calculate the number of HP to heal.
               
               

               


                     Modifié par Lightfoot8, 07 novembre 2010 - 12:27 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Custom healing kit script help
« Reply #6 on: November 07, 2010, 02:14:54 am »


               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 .
                     
                  


            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Custom healing kit script help
« Reply #7 on: November 07, 2010, 03:02:05 am »


               This will return true unless the target has exactly 10 hit points:



if (iHP -10)



I would suggest changing it to



else if (iHP <= 0)



Funky
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Custom healing kit script help
« Reply #8 on: November 07, 2010, 03:07:08 am »


               Actually the code got cut off for some reason when posting it. That line is supposed to be:
if (iHP  -10)

Yep. Just edited and look. It did it again above. Is it the "&&" causin a problem maybe? like the "\\" posting double?

if (iHP < 1 && iHP > -10)

Thanks for the catch Funky.
               
               

               


                     Modifié par GhostOfGod, 07 novembre 2010 - 03:09 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Custom healing kit script help
« Reply #9 on: November 07, 2010, 04:43:44 am »


               I think the problem was the '<'  and '>'  If you had no spaces in between them, It would look like a HTML  tag.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Custom healing kit script help
« Reply #10 on: November 07, 2010, 04:50:56 am »


               Ah ha. That makes sense.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Custom healing kit script help
« Reply #11 on: November 07, 2010, 08:49:40 am »


               ....lack of codeboxes....

sigh
               
               

               
            

Legacy_SuperFly_2000

  • Hero Member
  • *****
  • Posts: 1292
  • Karma: +0/-0
Custom healing kit script help
« Reply #12 on: November 07, 2010, 09:58:03 am »


               

Lightfoot8 wrote...

The original Heal Kits heal a skill roll + Heal Kit bouns + Heal Skill rank.

d20 + Heal Rank+ KitBouns.

Are you sure that the KitBonus is added to the healed HP?

I always thought that the KitBonus was something that only helped when you rolled against the DC of removing poison, deciese or similar negative effects.

Speaking of which...that part about "restoring" a PC from negative effects...is not in the script....and it is probably pretty complicated...

Otherwise thanks again GoG! I think about the healing itself the script looked like it could work.


Gaah...if this gets to complicated I'm probably back at just raising the price for the normal kits...


Oh...by the way....no need to destroy the healing kit. I will put 5 charges on it and it will be destroyed automatically after thoose charges are used up. (I can remove that line myself though...yaaay!)

I will probably be using the formula:

d10 + Heal Rank

In that way I get something similar to the default...only less.

(Hopefully I can add that d10 to your script myself also....)
               
               

               


                     Modifié par SuperFly_2000, 07 novembre 2010 - 09:58 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Custom healing kit script help
« Reply #13 on: November 07, 2010, 05:06:28 pm »


               We could add the part to handle disease and poison too. But again it just depends on some kind of formula to handle it. And what effects you want to be able to remove via the healing kit.

Updated script with your desired changes:


#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 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 = d10() + GetSkillRank(SKILL_HEAL, oPC);

    //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).
    if (iHP < 1 && iHP > -10)
    {
        int iNew = (iHP - iHP) + 1;
        effect eHeal = EffectHeal(iNew);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
        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.
    if (!GetIsInCombat(oPC))
    {
        effect eHeal = EffectHeal(iHealPoints);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eHeal, oTarget);
        //
        //Add poison and disease neutralizing here.
        //
    }
    //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.");
    }
}
               
               

               
            

Legacy_SuperFly_2000

  • Hero Member
  • *****
  • Posts: 1292
  • Karma: +0/-0
Custom healing kit script help
« Reply #14 on: November 07, 2010, 08:21:34 pm »


               Wooo...that looks nice! Yeah...I guess the only thing missing then is to have the disease, poison and other various negative effects removal ála the default Healing kits functionality. Hmm..let me search around a bit on the vault...


EDIT:  Actually, when I come to think of it.  How realistic is it that applying bandages to a PC removes the poison and/or deceise? Actually...its not. This is rough for the players...because getting poisoned or deceised will put them in problems now...maybe it is too rough...I don't know...but for now maybe this script will do.

What do you think? I guess the only way to get rid of poison now is to neutralize it...or get the effect...and then rest...(?).

Anyway...thanks a lot for getting me this far. I don't know what I would do without you guys 'Image
               
               

               


                     Modifié par SuperFly_2000, 07 novembre 2010 - 08:38 .