Scripting an NPC Fish not to go on land.
#1
Posté 14 décembre 2010 - 06:54
void main()
{
object oObject = GetEnteringObject();
int iFish = GetLocalInt(oObject, "fish");
object oWay = GetNearestObjectByTag("FISHRETURN", OBJECT_SELF, 1);
location lWay = GetLocation(oWay);
if(!GetIsPC(oObject))
{
if (iFish == 1)
{
AssignCommand(oObject, ActionJumpToLocation(lWay));
}
}
}
There is a waypoint out in the water far away called "FISHRETURN". All fish/sharks or otherwise water only creatures have the "fish" LocalInt set to "1". However, when I try this in game, the NPC ignores the trigger entirely. I cannot figure out why that is.
Thanks in advance for help.
#2
Posté 14 décembre 2010 - 08:32
#3
Posté 14 décembre 2010 - 09:46
Create a trigger. This trigger fills the entire section where you want the fish to remain inside.
I placed the following script on the OnExit of the trigger.
void main()
{
object oExiting = GetExitingObject();
if( !GetIsObjectValid( oExiting) || (GetTag( oExiting) != "TAG_OF_FISH_HERE")) return;
{
AssignCommand(oExiting, ClearAllActions());
DelayCommand (0.5, AssignCommand(oExiting, ActionForceMoveToLocation(GetLocation(GetNearestObjectByTag("FISHRETURN")))));
}
}
FP!
Modifié par Fester Pot, 14 décembre 2010 - 09:46 .
#4
Posté 15 décembre 2010 - 01:16
_Knightmare_ wrote...
How do you have the triger drawn down? Is it along the water edge where thefish might swim into it, or is it drawn around the whole water section where the fish is swimming around inside the trigger?
The trigger is around the island i do not want the fish to "walk" upon. Yet the fish comes into the trigger with no issues and attacks.
The fish does not spawn inside the trigger.
Modifié par Ivanovich, 15 décembre 2010 - 01:19 .
#5
Posté 15 décembre 2010 - 01:18
Fester Pot wrote...
This is how I do it.
Create a trigger. This trigger fills the entire section where you want the fish to remain inside.
I placed the following script on the OnExit of the trigger.void main()
{
object oExiting = GetExitingObject();
if( !GetIsObjectValid( oExiting) || (GetTag( oExiting) != "TAG_OF_FISH_HERE")) return;
{
AssignCommand(oExiting, ClearAllActions());
DelayCommand (0.5, AssignCommand(oExiting, ActionForceMoveToLocation(GetLocation(GetNearestObjectByTag("FISHRETURN")))));
}
}
FP!
I appreciate the suggestion, but exit triggers would be far more difficult given the terrain I'm managing. There must be a reason why the script I posted above does not work right.
#6
Posté 15 décembre 2010 - 04:50
void main()
{
object oEntering = GetEnteringObject();
if( !GetIsObjectValid( oEntering) || (GetTag( oEntering) != "TAG_OF_FISH_HERE")) return;
{
AssignCommand(oEntering, ClearAllActions());
DelayCommand (0.5, AssignCommand(oEntering, ActionForceMoveToLocation(GetLocation(GetNearestObjectByTag("FISHRETURN")))));
}
}
FP!
Modifié par Fester Pot, 15 décembre 2010 - 04:51 .
#7
Posté 16 décembre 2010 - 01:56
Ivanovich wrote...
I appreciate the suggestion, but exit triggers would be far more difficult given the terrain I'm managing. There must be a reason why the script I posted above does not work right.
I'm having to do something similar to manage the mixed flying and walking areas in Sanctum 3. Depending on how important it is for the creature's behavior to look natural and the shape of the area, you may want to put several of the waypoints in various parts of the water area. If the area is at all concave and you use ActionForceMoveToLocation instead of jumping, it'll also help avoid the possibility of a fish trying to walk over land to get to the "FISHRETURN" point. If you do that then you'll want to use the entering object rather than the trigger in GetNearestObjectByTag.
The only other thing I can see with the script you posted that might cause it not to work is the lack of a ClearAllActions call before assigning the jump or move action. What FP wrote looks like a simplified version of my scripts, and they work fine.
You may also want to use a delay to get the creature to return to its normal behavior after the move. One thing I found for example is that the ClearAllActions will reset a creature's combat state, which is important for me to restore after preventing a land-based creature from entering a flyng area. You're trying to keep a water-based creature from entering a land area, so what you're doing is largely the same thing with different names.
Modifié par AndarianTD, 16 décembre 2010 - 01:57 .
#8
Posté 17 décembre 2010 - 06:56
#9
Posté 06 avril 2011 - 10:43
#10
Posté 10 avril 2011 - 04:32
/*
MADE BY:Ivanovich
DATE:12.01.2010 4 months ago by forums
current date 04.09.2011
*/
void main()
{
object oObject = GetEnteringObject();
// replace name of local variable on creature here
int iFish = GetLocalInt(oObject, "fish");
// replace name of return waypoint hhere
object oWay = GetNearestObjectByTag("FISHRETURN", OBJECT_SELF, 1);
location lWay = GetLocation(oWay);
if(!GetIsPC(oObject))
{
if (iFish == 1)
{
AssignCommand(oObject,ClearAllActions(TRUE));
AssignCommand(oObject, ActionJumpToLocation(lWay));
}
}
}
This is pasted fix of Ivanovich above script pretty easy to do. The issue was ClearAllActions(TRUE) needed to be in there to clear the creatures combat state. Both Ivanovich, and fester Pot are correct in there scripting methods. The terrian makes a difficult sometimes you just adjust. Im sure Ivanovich wont mind you using the script thats why we post here to help each other out
#11
Posté 18 avril 2011 - 05:26





Retour en haut






