2025/12/16 Update
Updated PEPS Hooked up new GUI module event. Updated classes.2da Updated baseitems.2da Updated nim tools. Full compile.
This commit is contained in:
@@ -11,8 +11,6 @@
|
||||
void ai_SetupPlayerTarget();
|
||||
// Selects a target for oAssocite to follow.
|
||||
void ai_AllSelectTarget(object oPC, object oAssociate, object oTarget);
|
||||
// Removes the Cutscene ghosts and variables from all associates. For original AI scripts.
|
||||
void ai_OriginalRemoveAllActionMode(object oPC);
|
||||
// Removes the Cutscene ghosts and Command mode from all associates.
|
||||
void ai_RemoveAllActionMode(object oPC);
|
||||
// Once a trap has been selected from the associates inventory move to placing the trap.
|
||||
@@ -30,6 +28,13 @@ void ai_UpdateAssociateWidget(object oPC, object oAssociate);
|
||||
// Sets oAssociates action mode for nFeat from the quick widget menu
|
||||
int ai_SetActionMode(object oAssociate, int nFeat);
|
||||
|
||||
void ai_EnterAssociateTargetMode(object oPC, object oAssociate)
|
||||
{
|
||||
SetLocalObject(oPC, AI_TARGET_ASSOCIATE, oAssociate);
|
||||
SetLocalString(oPC, AI_TARGET_MODE, "ASSOCIATE_ACTION");
|
||||
SetLocalInt(oPC, AI_TARGET_MODE_ON, TRUE);
|
||||
EnterTargetingMode(oPC, OBJECT_TYPE_ALL, MOUSECURSOR_ACTION, MOUSECURSOR_NOWALK);
|
||||
}
|
||||
void ai_SetupPlayerTarget()
|
||||
{
|
||||
object oModule = GetModule();
|
||||
@@ -40,129 +45,7 @@ void ai_SetupPlayerTarget()
|
||||
}
|
||||
SetEventScript(oModule, EVENT_SCRIPT_MODULE_ON_PLAYER_TARGET, "0e_player_target");
|
||||
}
|
||||
void ai_OriginalActionAssociate(object oPC, object oTarget, location lLocation)
|
||||
{
|
||||
object oAssociate = OBJECT_SELF;
|
||||
if(!GetLocalInt(oAssociate, sGhostModeVarname) && GetLocalInt(oPC, sGhostModeVarname))
|
||||
{
|
||||
effect eGhost = EffectCutsceneGhost();
|
||||
ApplyEffectToObject(DURATION_TYPE_PERMANENT, eGhost, oAssociate);
|
||||
SetLocalInt(oAssociate, sGhostModeVarname, TRUE);
|
||||
}
|
||||
int nObjectType = GetObjectType(oTarget);
|
||||
ai_ClearCreatureActions(TRUE);
|
||||
if(oTarget == GetArea(oPC))
|
||||
{
|
||||
ActionMoveToLocation(lLocation, TRUE);
|
||||
if(GetLocalObject(oPC, AI_FOLLOW_TARGET) == oAssociate)
|
||||
{
|
||||
float fFollowDistance = 3.0;
|
||||
AssignCommand(oPC, ai_ClearCreatureActions());
|
||||
AssignCommand(oPC, ActionForceFollowObject(oAssociate, fFollowDistance));
|
||||
}
|
||||
}
|
||||
else if(nObjectType == OBJECT_TYPE_CREATURE)
|
||||
{
|
||||
if(oTarget != GetLocalObject(oPC, AI_TARGET_ASSOCIATE))
|
||||
{
|
||||
if(GetMaster(oTarget) == oPC)
|
||||
{
|
||||
SetLocalString(oPC, AI_TARGET_MODE, "ASSOCIATE_ACTION");
|
||||
SetLocalObject(oPC, AI_TARGET_ASSOCIATE, oTarget);
|
||||
ai_SendMessages(GetName(oTarget) + " is now in Action Mode.", AI_COLOR_YELLOW, oPC);
|
||||
}
|
||||
else ActionMoveToObject(oTarget, TRUE);
|
||||
}
|
||||
}
|
||||
else if(nObjectType == OBJECT_TYPE_DOOR)
|
||||
{
|
||||
if(GetIsTrapped(oTarget) && GetAssociateState(NW_ASC_DISARM_TRAPS, oAssociate))
|
||||
{
|
||||
if(GetTrapDetectedBy(oTarget, oPC)) SetTrapDetectedBy(oTarget, oAssociate);
|
||||
if(GetTrapDetectedBy(oTarget, oAssociate))
|
||||
{
|
||||
bkAttemptToDisarmTrap(oTarget);
|
||||
EnterTargetingMode(oPC, OBJECT_TYPE_ALL, MOUSECURSOR_ACTION, MOUSECURSOR_NOWALK);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(GetLocked(oTarget)) bkAttemptToOpenLock(oTarget);
|
||||
if(GetIsOpen(oTarget))
|
||||
{
|
||||
ActionCloseDoor(oTarget, TRUE);
|
||||
}
|
||||
else ActionOpenDoor(oTarget, TRUE);
|
||||
}
|
||||
else if(nObjectType == OBJECT_TYPE_ITEM)
|
||||
{
|
||||
ActionPickUpItem(oTarget);
|
||||
}
|
||||
else if(nObjectType == OBJECT_TYPE_PLACEABLE)
|
||||
{
|
||||
ActionMoveToObject(oTarget, TRUE);
|
||||
if(GetHasInventory(oTarget))
|
||||
{
|
||||
if(GetIsTrapped(oTarget) && GetAssociateState(NW_ASC_RETRY_OPEN_LOCKS, oAssociate))
|
||||
{
|
||||
if(GetTrapDetectedBy(oTarget, oPC)) SetTrapDetectedBy(oTarget, oAssociate);
|
||||
if(GetTrapDetectedBy(oTarget, oAssociate))
|
||||
{
|
||||
bkAttemptToDisarmTrap(oTarget);
|
||||
EnterTargetingMode(oPC, OBJECT_TYPE_ALL, MOUSECURSOR_ACTION, MOUSECURSOR_NOWALK);
|
||||
return;
|
||||
}
|
||||
if(GetLocked(oTarget))
|
||||
{
|
||||
if(GetAssociateState(NW_ASC_RETRY_OPEN_LOCKS, oAssociate))
|
||||
{
|
||||
bkAttemptToOpenLock(oTarget);
|
||||
}
|
||||
else AssignCommand(oAssociate, ai_HaveCreatureSpeak(oAssociate, 0, "This " + GetName(oTarget) + " is locked!"));
|
||||
EnterTargetingMode(oPC, OBJECT_TYPE_ALL, MOUSECURSOR_ACTION, MOUSECURSOR_NOWALK);
|
||||
return;
|
||||
}
|
||||
DoPlaceableObjectAction(oTarget, PLACEABLE_ACTION_USE);
|
||||
}
|
||||
else if(GetLocked(oTarget))
|
||||
{
|
||||
if(GetAssociateState(NW_ASC_RETRY_OPEN_LOCKS, oAssociate))
|
||||
{
|
||||
bkAttemptToOpenLock(oTarget);
|
||||
}
|
||||
else AssignCommand(oAssociate, ai_HaveCreatureSpeak(oAssociate, 0, "This " + GetName(oTarget) + " is locked!"));
|
||||
EnterTargetingMode(oPC, OBJECT_TYPE_ALL, MOUSECURSOR_ACTION, MOUSECURSOR_NOWALK);
|
||||
return;
|
||||
}
|
||||
DoPlaceableObjectAction(oTarget, PLACEABLE_ACTION_USE);
|
||||
}
|
||||
DoPlaceableObjectAction(oTarget, PLACEABLE_ACTION_USE);
|
||||
}
|
||||
else if(nObjectType == OBJECT_TYPE_TRIGGER)
|
||||
{
|
||||
if(GetIsTrapped(oTarget) && GetAssociateState(NW_ASC_RETRY_OPEN_LOCKS, oAssociate))
|
||||
{
|
||||
if(GetTrapDetectedBy(oTarget, oPC)) SetTrapDetectedBy(oTarget, oAssociate);
|
||||
if(GetTrapDetectedBy(oTarget, oAssociate)) bkAttemptToDisarmTrap(oTarget);
|
||||
}
|
||||
}
|
||||
EnterTargetingMode(oPC, OBJECT_TYPE_ALL, MOUSECURSOR_ACTION, MOUSECURSOR_NOWALK);
|
||||
}
|
||||
void ai_OriginalActionAllAssociates(object oPC, object oTarget, location lLocation)
|
||||
{
|
||||
object oAssociate;
|
||||
int nIndex;
|
||||
for(nIndex = 1; nIndex <= AI_MAX_HENCHMAN; nIndex++)
|
||||
{
|
||||
oAssociate = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC, nIndex);
|
||||
if(oAssociate != OBJECT_INVALID) AssignCommand(oAssociate, ai_OriginalActionAssociate(oPC, oTarget, lLocation));
|
||||
}
|
||||
for(nIndex = 2; nIndex < 6; nIndex++)
|
||||
{
|
||||
oAssociate = GetAssociate(nIndex, oPC);
|
||||
if(oAssociate != OBJECT_INVALID) AssignCommand(oAssociate, ai_OriginalActionAssociate(oPC, oTarget, lLocation));
|
||||
}
|
||||
}
|
||||
void ai_ActionAssociate(object oPC, object oTarget, location lLocation)
|
||||
void ai_ActionAssociate(object oPC, object oTarget, location lLocation, int bActionAll = FALSE)
|
||||
{
|
||||
object oAssociate = OBJECT_SELF;
|
||||
if(ai_GetAIMode(oPC, AI_MODE_ACTION_GHOST) &&
|
||||
@@ -233,7 +116,7 @@ void ai_ActionAssociate(object oPC, object oTarget, location lLocation)
|
||||
if(ai_ReactToTrap(oAssociate, oTarget, TRUE)) bStopAction = TRUE;
|
||||
if(bStopAction)
|
||||
{
|
||||
EnterTargetingMode(oPC, OBJECT_TYPE_ALL, MOUSECURSOR_ACTION, MOUSECURSOR_NOWALK);
|
||||
ai_EnterAssociateTargetMode(oPC, oAssociate);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -258,7 +141,7 @@ void ai_ActionAssociate(object oPC, object oTarget, location lLocation)
|
||||
{
|
||||
if(ai_ReactToTrap(oAssociate, oTarget, TRUE))
|
||||
{
|
||||
EnterTargetingMode(oPC, OBJECT_TYPE_ALL, MOUSECURSOR_ACTION, MOUSECURSOR_NOWALK);
|
||||
ai_EnterAssociateTargetMode(oPC, oAssociate);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -291,7 +174,7 @@ void ai_ActionAssociate(object oPC, object oTarget, location lLocation)
|
||||
if(GetTrapDetectedBy(oTarget, oAssociate)) ai_ReactToTrap(oAssociate, oTarget, TRUE);
|
||||
}
|
||||
}
|
||||
EnterTargetingMode(oPC, OBJECT_TYPE_ALL, MOUSECURSOR_ACTION, MOUSECURSOR_NOWALK);
|
||||
if(!bActionAll) ai_EnterAssociateTargetMode(oPC, oAssociate);
|
||||
}
|
||||
void ai_ActionAllAssociates(object oPC, object oTarget, location lLocation)
|
||||
{
|
||||
@@ -300,12 +183,12 @@ void ai_ActionAllAssociates(object oPC, object oTarget, location lLocation)
|
||||
for(nIndex = 1; nIndex <= AI_MAX_HENCHMAN; nIndex++)
|
||||
{
|
||||
oAssociate = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC, nIndex);
|
||||
if(oAssociate != OBJECT_INVALID) AssignCommand(oAssociate, ai_ActionAssociate(oPC, oTarget, lLocation));
|
||||
if(oAssociate != OBJECT_INVALID) AssignCommand(oAssociate, ai_ActionAssociate(oPC, oTarget, lLocation, TRUE));
|
||||
}
|
||||
for(nIndex = 2; nIndex < 6; nIndex++)
|
||||
{
|
||||
oAssociate = GetAssociate(nIndex, oPC);
|
||||
if(oAssociate != OBJECT_INVALID) AssignCommand(oAssociate, ai_ActionAssociate(oPC, oTarget, lLocation));
|
||||
if(oAssociate != OBJECT_INVALID) AssignCommand(oAssociate, ai_ActionAssociate(oPC, oTarget, lLocation, TRUE));
|
||||
}
|
||||
}
|
||||
void ai_SelectFollowTarget(object oPC, object oAssociate, object oTarget)
|
||||
@@ -343,34 +226,6 @@ void ai_SelectFollowTarget(object oPC, object oAssociate, object oTarget)
|
||||
}
|
||||
aiSaveAssociateModesToDb(oPC, oAssociate);
|
||||
}
|
||||
void ai_OriginalRemoveAllActionMode(object oPC)
|
||||
{
|
||||
if(!ai_GetAIMode(oPC, AI_MODE_ACTION_GHOST)) return;
|
||||
object oAssociate;
|
||||
int nIndex;
|
||||
for(nIndex = 1; nIndex <= AI_MAX_HENCHMAN; nIndex++)
|
||||
{
|
||||
oAssociate = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC, nIndex);
|
||||
if(oAssociate != OBJECT_INVALID &&
|
||||
!ai_GetAIMode(oAssociate, AI_MODE_GHOST) &&
|
||||
GetLocalInt(oAssociate, sGhostModeVarname))
|
||||
{
|
||||
ai_RemoveASpecificEffect(oAssociate, EFFECT_TYPE_CUTSCENEGHOST);
|
||||
DeleteLocalInt(oAssociate, sGhostModeVarname);
|
||||
}
|
||||
}
|
||||
for(nIndex = 2; nIndex < 6; nIndex++)
|
||||
{
|
||||
oAssociate = GetAssociate(nIndex, oPC);
|
||||
if(oAssociate != OBJECT_INVALID &&
|
||||
!ai_GetAIMode(oAssociate, AI_MODE_GHOST) &&
|
||||
GetLocalInt(oAssociate, sGhostModeVarname))
|
||||
{
|
||||
ai_RemoveASpecificEffect(oAssociate, EFFECT_TYPE_CUTSCENEGHOST);
|
||||
DeleteLocalInt(oAssociate, sGhostModeVarname);
|
||||
}
|
||||
}
|
||||
}
|
||||
void ai_RemoveAllActionMode(object oPC)
|
||||
{
|
||||
object oAssociate;
|
||||
@@ -642,17 +497,18 @@ void ai_SelectWidgetSpellTarget(object oPC, object oAssociate, string sElem)
|
||||
{
|
||||
object oItem = GetObjectByUUID(JsonGetString(JsonArrayGet(jSpell, 5)));
|
||||
int nBaseItemType = GetBaseItemType(oItem);
|
||||
int nIprpSubType = JsonGetInt(JsonArrayGet(jSpell, 4));
|
||||
itemproperty ipProperty = GetFirstItemProperty(oItem);
|
||||
while(GetIsItemPropertyValid(ipProperty))
|
||||
{
|
||||
if(nIprpSubType == GetItemPropertySubType(ipProperty)) break;
|
||||
ipProperty = GetNextItemProperty(oItem);
|
||||
}
|
||||
if(Get2DAString("spells", "Range", nSpell) == "P" || // Self
|
||||
nBaseItemType == BASE_ITEM_ENCHANTED_POTION ||
|
||||
nBaseItemType == BASE_ITEM_POTIONS)
|
||||
nBaseItemType == BASE_ITEM_POTIONS ||
|
||||
nIprpSubType == IP_CONST_CASTSPELL_UNIQUE_POWER_SELF_ONLY)
|
||||
{
|
||||
int nIprpSubType = JsonGetInt(JsonArrayGet(jSpell, 4));
|
||||
itemproperty ipProperty = GetFirstItemProperty(oItem);
|
||||
while(GetIsItemPropertyValid(ipProperty))
|
||||
{
|
||||
if(nIprpSubType == GetItemPropertySubType(ipProperty)) break;
|
||||
ipProperty = GetNextItemProperty(oItem);
|
||||
}
|
||||
if(ai_GetIsInCombat(oAssociate)) AssignCommand(oAssociate, ai_ClearCreatureActions(TRUE));
|
||||
AssignCommand(oAssociate, ActionUseItemOnObject(oItem, ipProperty, oAssociate));
|
||||
DelayCommand(6.0, ai_UpdateAssociateWidget(oPC, oAssociate));
|
||||
|
||||
Reference in New Issue
Block a user