Aller au contenu

Photo

Heal character by picking up object


  • Veuillez vous connecter pour répondre
2 réponses à ce sujet

#1
Sonmeister

Sonmeister
  • Members
  • 167 messages
I want to have my character get healed by picking up an object. Will this script
below work.



void main()
{
  string sTag = GetLocalString(GetModule(),"RUNSCRIPT_VAR");
object oCreature = GetObjectByTag(sTag);
effect eHeal = EffectHeal(25.0f)

}

#2
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
 Hi Sonmeister, 

I don't understand what you mean exactly with "picking up an object". Could you give me an example?

Anyway, if what you have in mind is something like a healing fountain, a placeable that after being clicked heals the controlled character, you can attach the following script to your placeable.

#include "placeable_h" 

const float POINTS_TO_HEAL = 25.0f;
const int VFX_HEAL_ID = 1021;

void main(){
    event ev     = GetCurrentEvent();    
    int   nEvent = GetEventType(ev);
    // If TRUE, we won't redirect to rules core    
    int bEventHandled = FALSE;

    switch (nEvent)    
    {
        //---------------------------------------------------------------------        
        //  Sent by engine when creature clicks on the placeable.        
        //---------------------------------------------------------------------        
        case EVENT_TYPE_USE:            
            bEventHandled = TRUE;                                                                
            effect eHeal = EffectHeal(POINTS_TO_HEAL);                  
            object oPlayer = GetMainControlled();         
   
            ApplyEffectOnObject(EFFECT_DURATION_TYPE_INSTANT, eHeal, oPlayer);   
            ApplyEffectVisualEffect(OBJECT_SELF, oPlayer, VFX_HEAL_ID, EFFECT_DURATION_TYPE_INSTANT, 0.0f);            
            break;
    }
    // -------------------------------------------------------------------------    
    // Any event not handled falls through to rules_core:    
    // -------------------------------------------------------------------------    
    if (!bEventHandled)    
    {        
        HandleEvent(ev, RESOURCE_SCRIPT_PLACEABLE_CORE);    
    }
}

Modifié par _L_o_B_o_, 06 mai 2010 - 02:28 .


#3
Sonmeister

Sonmeister
  • Members
  • 167 messages
That should work!