Here's what I'm trying to do.
1/ In a custom area (which is an arena), the player can access three "modes":
- Hero: without companions.
- Party: normal 4-member party (or less).
- Extended party: the players controls only the hero, but all pool members are here also as allies.
(ammunitions, poultices, etc., in fact everything except items with
permanent effects like tomes).
#1 is done easily, #2 is a lot trickier, and #1 and #2 together give me the hell of a headache!
For the "extended party" mode, here is a short version of the script (which works):
UT_PartyStore();
object [] aPool = GetPartyPoolList();
int nSizePool = GetArraySize(aPool);
int iPool;
object oCurrent;
for(iPool = 0; iPool < nSizePool; iPool++)
{
oCurrent = aPool[iPool];
if(!IsPartyMember(oCurrent))
{
WR_SetObjectActive(oCurrent, TRUE);
UT_LocalJump(oCurrent, [i]somewhere in the area[/i]);
SetGroupId(oCurrent, GROUP_PC);
SetImmortal(oCurrent, FALSE);
SetFollowPartyLeader(oCurrent, TRUE);
}
}
Under the EVENT_TYPE_ENTER area event, we change the event-handling script for all pool members, in order to manage items properly:
object[] aPool = GetPartyPoolList();
int nSizePool = GetArraySize(aPool);
int iPool;
object oCurrent;
for (iPool = 0; iPool < nSizePool; iPool++)
{
oCurrent = aPool[iPool];
if (!IsSummoned(oCurrent))
{
EnablevEvent(oCurrent, TRUE, EVENT_TYPE_INVENTORY_REMOVED);
SetEventScript(oCurrent, R"custom_party_member.ncs");
}
}
And here is a short version of the script "custom_party_member".
#include [i]blablabla...[/i]
const int COMMAND_TYPE_EXECUTE_EFFECT = 32;
const int ITEM_ABILITY_UNIQUE_POWER_SINGLE_USE = 200202;
const int ITEM_TALENT_POINT = 200258;
const int ITEM_SKILL_POINT = 200259;
const int ITEM_ATTRIBUTE_POINT = 200260;
void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
int bEventHandled = FALSE;
switch (nEventType)
{
case EVENT_TYPE_INVENTORY_REMOVED:
{
// The item being removed
object oItem = GetEventObject(ev, 0);
int nItemType = GetItemType(oItem);
// We will check the current command
// because we want to do nothing
// when the item is manually destroyed
// in the inventory GUI.
command cCommand = GetCurrentCommand(OBJECT_SELF);
int nCommandType = GetCommandType(cCommand);
//***************
// Ammunitions
//***************
// When the character is using ammunition, one
// can notice that oItem is always invalid
// (and not an ammo type item). Thus, we cannot
// get the item via oItem.
if (
(nItemType == ITEM_TYPE_INVALID) &&
(
(nCommandType == COMMAND_TYPE_ATTACK) ||
(nCommandType == COMMAND_TYPE_USE_ABILITY)
)
)
{
object oAmmunition =
GetItemInEquipSlot(INVENTORY_SLOT_RANGEDAMMO,
OBJECT_SELF);
if (IsObjectValid(oAmmunition))
SetItemStackSize(oAmmunition,
GetItemStackSize(oAmmunition) + 1);
}
//***************
// Other (not ammunitions) ==> poultices, poisons, etc.
//***************
// Normally, the current command should
// be COMMAND_TYPE_USE_ABILITY.
// But one can notice that sometimes, it is
// COMMAND_TYPE_EXECUTE_EFFECT.
else if (
(nCommandType == COMMAND_TYPE_USE_ABILITY) ||
(nCommandType == COMMAND_TYPE_EXECUTE_EFFECT)
)
{
object oNewOwner = GetEventCreator(ev);
int nAbility = GetItemAbilityId(oItem);
if
(
(nAbility != ITEM_ABILITY_UNIQUE_POWER_SINGLE_USE)
&& (nAbility != ITEM_TALENT_POINT)
&& (nAbility != ITEM_SKILL_POINT)
&& (nAbility != ITEM_ATTRIBUTE_POINT)
)
{
MoveItem(OBJECT_SELF, OBJECT_SELF, oItem);
}
}
break;
}
}
if (!bEventHandled)
{
HandleEvent(ev, RESOURCE_SCRIPT_PLAYER_CORE);
}
}
And now, the questions!
- For ammunitions, it works except if the character is using special ammo, like ice arrow, and had exactly one left. I understand why, but I can see no better way to do.
- For quick items, it works except if it is the last item in the stack. In my real script, I have a workaround using a M2DA, which allows emulating a StringToResource for a certain list of items. But it will never work for items created by other modders or included in DLCs. Does someone see a better way to do it?
- Last but not least, all this doesn't work at all for companions in "extended party" mode! According to my tests, they use the "custom_party_member" script indeed, but the EVENT_TYPE_INVENTORY_REMOVED is never fired!
Sorry for this long message and very big thanks in advance to anyone who has an clue about it!!!
Modifié par FanfanVilperdue, 27 avril 2010 - 02:11 .





Retour en haut






