Problem with onheartbeat script and waypoints
#1
Posté 04 septembre 2010 - 07:22
Has anyone encountered this problem?Thanks in advance!
#2
Posté 04 septembre 2010 - 07:47
Modifié par GhostOfGod, 04 septembre 2010 - 07:49 .
#3
Posté 04 septembre 2010 - 08:00
Edit: still don't work for guard with waypoints...
Modifié par Krevett, 04 septembre 2010 - 08:12 .
#4
Posté 04 septembre 2010 - 08:04
ExecuteScript("nw_c2_default1", OBJECT_SELF);
Just put that at the bottom of your script just before/above the last closing curly bracket "}".
Modifié par GhostOfGod, 04 septembre 2010 - 08:06 .
#5
Posté 04 septembre 2010 - 11:24
#6
Posté 04 septembre 2010 - 12:57
FP!
#7
Posté 04 septembre 2010 - 01:48
void main()
{
int post;
if (GetIsDay()&GetLocalInt(OBJECT_SELF, "post")==2)
{
ActionEquipItem(GetItemPossessedBy(OBJECT_SELF, GetTag(GetLocalObject(OBJECT_SELF, "oldobject"))), INVENTORY_SLOT_LEFTHAND);
SetLocalInt(OBJECT_SELF, "post", 1);
}
if (GetIsNight()&GetLocalInt(OBJECT_SELF, "post")==1)
{
SetLocalObject(OBJECT_SELF, "oldobject", GetItemInSlot(INVENTORY_SLOT_LEFTHAND));
ActionEquipItem(GetItemPossessedBy(OBJECT_SELF, "NW_IT_TORCH001"), INVENTORY_SLOT_LEFTHAND);
SetLocalInt(OBJECT_SELF, "post", 2);
}
ExecuteScript("nw_c2_default1", OBJECT_SELF);
}
I set a local variable "post" to 1 on the guards i want to switch their shield for a torch at night, and of course these guards have a torch in their inventory!
#8
Posté 04 septembre 2010 - 04:23
#9
Posté 04 septembre 2010 - 04:38
Even with this correction guards with waypoints still won't switch their shields for torches at night as if while walking they ignore the heartbeat script!!
#10
Posté 04 septembre 2010 - 05:14
Try this and see what happens:
void main()
{
if (GetIsDay()&& GetLocalInt(OBJECT_SELF, "post")==2)
{
ClearAllActions();
ActionEquipItem(GetItemPossessedBy(OBJECT_SELF, GetTag(GetLocalObject(OBJECT_SELF, "oldobject"))), INVENTORY_SLOT_LEFTHAND);
SetLocalInt(OBJECT_SELF, "post", 1);
}
if (GetIsNight()&& GetLocalInt(OBJECT_SELF, "post")==1)
{
ClearAllActions();
SetLocalObject(OBJECT_SELF, "oldobject", GetItemInSlot(INVENTORY_SLOT_LEFTHAND));
ActionEquipItem(GetItemPossessedBy(OBJECT_SELF, "NW_IT_TORCH001"), INVENTORY_SLOT_LEFTHAND);
SetLocalInt(OBJECT_SELF, "post", 2);
}
ExecuteScript("nw_c2_default1", OBJECT_SELF);
}
I slapped in a couple "ClearAllActions" to interupt his current action. Not tested but hope that is the problem. Good luck.
Modifié par GhostOfGod, 04 septembre 2010 - 05:14 .
#11
Posté 04 septembre 2010 - 06:05
#12
Posté 04 septembre 2010 - 06:53
Modifié par ShaDoOoW, 04 septembre 2010 - 06:53 .
#13
Posté 04 septembre 2010 - 07:02
#14
Posté 04 septembre 2010 - 07:32
#include "NW_I0_GENERIC"
void main()
{
WalkWayPoints();
}
You could alter that to something like:
#include "NW_I0_GENERIC"
void main()
{
if (GetLocalInt (OBJECT_SELF, "Guard") == 1)
ExecuteScript("GuardTorch", OBJECT_SELF);
WalkWayPoints();
}
And then set a local int (variable) on your guards with torches to Guard 1.
Then you execute the torch script as above, and follow that up with the normal
walkwaypoints call. You might want to put a delaycommand in befor walkwaypoints,
but the other script should execute first.
#15
Posté 04 septembre 2010 - 07:41
Try this, I think the problem is that "waypoint walking" cancels the equipping, this should workaround this + has number of new features - see comments.void main()
{
object oGuard = OBJECT_SELF;
if(GetIsInCombat(oGuard))//if fighting do not mess with equiping AI
{
ExecuteScript("nw_c2_default1",oGuard);
return;
}
ClearAllActions();
object oLeftHand = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oGuard);
if(GetIsDay() || GetIsDawn())
{
object old = GetLocalObject(oGuard,"oldobject");
if(GetTag(oLeftHand) == "NW_IT_TORCH001")//if got torch in the left hand
{
if(old != OBJECT_INVALID)//guard have shield, or light weapon equipping it, unequip torch
{
ActionEquipItem(old, INVENTORY_SLOT_LEFTHAND);
}
else//guard do not have any shield, or light weapon, must unequip torch manually
{
ActionUnequipItem(oLeftHand);
}
}
}
else//night or dusk
{
if(GetTag(oLeftHand) != "NW_IT_TORCH001")//if not torch in the left hand
{
SetLocalObject(oGuard, "oldobject", oLeftHand);
ActionEquipItem(GetItemPossessedBy(oGuard, "NW_IT_TORCH001"), INVENTORY_SLOT_LEFTHAND);
}
}
ActionDoCommand(ExecuteScript("nw_c2_default1",oGuard));
}
Also, I would add the check if the guard can even equip the torch, but suppose you giving this only to guards with one-handed weapon it is not needed.
#16
Posté 05 septembre 2010 - 04:10
void main()
{
if ((GetIsDawn() || GetIsDay()) && GetLocalInt(OBJECT_SELF, "post")==2)
{
ClearAllActions();
ActionEquipItem(GetLocalObject(OBJECT_SELF, "oldobject"), INVENTORY_SLOT_LEFTHAND);
SetLocalInt(OBJECT_SELF, "post", 1);
return;
}
if ((GetIsNight() || GetIsDusk()) && GetLocalInt(OBJECT_SELF, "post")==1)
{
ClearAllActions();
SetLocalObject(OBJECT_SELF, "oldobject", GetItemInSlot(INVENTORY_SLOT_LEFTHAND));
ActionEquipItem(GetItemPossessedBy(OBJECT_SELF, "NW_IT_TORCH001"), INVENTORY_SLOT_LEFTHAND);
SetLocalInt(OBJECT_SELF, "post", 2);
return;
}
ExecuteScript("nw_c2_default1", OBJECT_SELF);
}
You may have already got it working with one of the other methods posted. But just in case this is another. Hope it helps and good luck.
Modifié par GhostOfGod, 05 septembre 2010 - 04:14 .
#17
Posté 05 septembre 2010 - 07:26





Retour en haut






