I need help trying to get certain creatures immune to certain item materials.
making creatures immune to item materials
Débuté par
apookgnik123
, déc. 24 2010 04:38
#1
Posté 24 décembre 2010 - 04:38
#2
Posté 25 décembre 2010 - 05:44
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.
* 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
Posté 29 décembre 2010 - 02:04
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
Posté 30 décembre 2010 - 11:35
/*
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 .





Retour en haut






