Aller au contenu

Photo

making creatures immune to item materials


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

#1
apookgnik123

apookgnik123
  • Members
  • 6 messages
I need help trying to get certain creatures immune to certain item materials.

#2
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
Here is what you can do. Not the best solution, but I don't have much time for testing other possibilities:



* Create a script for your special creatures.

* In that script, use the EVENT_TYPE_DAMAGED event to restore the damage done to the creature if the item material is X.

* Get the attacking creature (GetEventCreator(ev)).

* Get the item used by the attacking creature (GetItemInEquipSlot()).

* Get the item material type (GetItemMaterialType()).

* Check the value returned against the values stored in materialtypes.xls.

* If the item material is one of which the creature is inmune to, then heal it (HealCreature()). In order to know the amount of hit points to heal, use GetEventFloat(ev, 0).



There are some cases where this script won't work properly. Since the checking is done after the damage is dealt (I am not 100% sure about it =/), your creature can be already dead when the script is running. For example, if a hostile creature is able to kill it with just one hit. Anyway, it might work for you.

#3
apookgnik123

apookgnik123
  • Members
  • 6 messages
Right now, we cant get any changes to the combat to work in game, so if your good at scripting we could probably use your help right now.

#4
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages

 /*    

   Type:   Creature Core Script.   

   Owner:  special_creature.utc    

   Desc:   Manage Special Creature's events.

*/



#include "utility_h"

#include "wrappers_h"

#include "events_h"                    



// Value taken from materialtypes.xls > tab: materialtypes.

const int MAT_TYPE_SILVERITE = 45;



void main()

{    

   event ev            = GetCurrentEvent();    

   int nEventType      = GetEventType(ev);    

   int bEventHandled   = FALSE;

    

   if (nEventType == EVENT_TYPE_DAMAGED)    

   {        

      object oDamager = GetEventCreator(ev);    // creature dealing the damage        

      float fDamage   = GetEventFloat(ev, 0); // Amount of damage dealt                

      object oDamagerMainItem = GetItemInEquipSlot(INVENTORY_SLOT_MAIN, oDamager);                

   

      int nDamagerMainMatType = GetItemMaterialType(oDamagerMainItem);                                           

      // Check against the material type that won't hurt your creature.        



      if (nDamagerMainMatType == MAT_TYPE_SILVERITE)        

      {            

         HealCreature(OBJECT_SELF, FALSE, fDamage);             

      }

      

      bEventHandled = TRUE;    

   }



   if (!bEventHandled)    

   {                                      

      HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE);    

   }

}


Modifié par _L_o_B_o_, 30 décembre 2010 - 11:38 .