You can just make the potion a unique item and have the PC cast the spell when they drink the potion. For instance and essence of cure from my campaign:
//essence of cure ffbj
#include "x2_inc_switches"
void main()
{
int nEvent =GetUserDefinedItemEventNumber();
if (!nEvent == X2_ITEM_EVENT_ACTIVATE)
return;
object oPC = GetItemActivator();
object oItem = GetItemActivated();
object oCaster = oPC;
int iHeal = GetSkillRank(SKILL_HEAL, oCaster, TRUE);
AssignCommand(oCaster, ActionCastSpellAtObject(SPELL_CURE_MODERATE_WOUNDS, oPC, 10 +iHeal, TRUE, TRUE));
DelayCommand (1.0, AssignCommand(oCaster, ActionCastSpellAtObject(SPELL_REGENERATE, oPC, 10 +iHeal, TRUE, TRUE)));
DelayCommand (2.0, AssignCommand(oCaster, ActionCastSpellAtObject(SPELL_REMOVE_DISEASE, oPC, 10 +iHeal, TRUE, TRUE)));
}
Modifié par ffbj, 21 mai 2011 - 07:06 .