Hello guys,
I really need help on this bug. Im using the BrainAI 5.0 made by Austin Heilman and modified by Edwards.
The problem I'm having is that no npc is moving or wandering. Only red or provocated npcs move toward the player to attack.
When a player gets in the range of view of npcs, they should start moving more energetic, e.g. 1 step every 2 secs. Then when a player leaves the range of view, the npc should enter "sleep" mode where they just walk around very slowly, like 1 step every 50 secs.
At the moment nothing of this is working. They stay there like stones.
It seems to me that something is not letting them enter the "wake up" and "sleep" mode.
Does someone already fixed this issue or know how to fix it?
Thank you.
BrainAI not working
Moderators: POL Developer, Distro Developer
Re: BrainAI not working
I've this issue as well I bet, I haven't had a player level character logged in as I've been working on stuff other than the npc stuff, I figured however this was like this so npcs aren't moving about when only staff are around as a sort of small QoL feature for testing purposes.
I've no idea where or how to fix this but am also curious where this might be fixed.
I've no idea where or how to fix this but am also curious where this might be fixed.
Re: BrainAI not working
I am not familiar with the BrainAI system at all. The AI scripts that I am familiar with have a function, "wander", that is called periodically for both human and non-human NPCs and merchants turn toward a player when he "speaks". If I get a chance I will look into the AI system on Edwards' "distro" but I can't make any promises whether I'll be able to solve the problem. You can check out the AI scrips in the Distro-Alt and look at the "wander" function. The key will be where, in the BrainAI, to put such a function. You don't want it called too often. Maybe it should be called a little more often when players are in range of an NPC.
Re: BrainAI not working
I found something interesting.
While trying to understand why this pkg is not working I compared Mytharria version with Edwards/official distro.
What I found out is that someone changed all Wait_For_Event(xx) to Wait_For_Event(1).
Can anyone explain me why? I mean its a big diference between 1 and 100000
I Know that both versions of this BrainAI are very different but stuff like "Wait_For_Event" should still be same because they are meant to do the same thing.
While trying to understand why this pkg is not working I compared Mytharria version with Edwards/official distro.
What I found out is that someone changed all Wait_For_Event(xx) to Wait_For_Event(1).
Can anyone explain me why? I mean its a big diference between 1 and 100000
I Know that both versions of this BrainAI are very different but stuff like "Wait_For_Event" should still be same because they are meant to do the same thing.
Re: BrainAI not working
Another interesting thing is that both version we tested, Mytharria and Edwards version seems to be broken.
Making me belive that this BranAI never worked right at all. I didnt found a working version. I still need to try the 097 and the Neverlands Reborn version.
What me and guialtran found is that the BrainAI/scripts/enterArea/generic.src never stops looping and most important it never wake up the npcs once it starts.
We put 7 prints to see if this script is doing everything right.
On both versions we got only 4 prints looping and spaming the console forever even when we leave the npc area. Attacking the npc doesnt change anything.. npcs will attack you back but will keep looping.
It shows that this script keeps running the "while ( npc )" part and is not wakening any npc at all.
print("AI_WakeUp 1"); and print("AI_WakeUp 2"); never happened.
will loop forever.
Its not normal to loop like this forever. If a player runs into 100 npcs they will all start a never ending loop.
What should make this loop stop? the Brain.src script or leftarea script? should the loop stop when the npc wakes up?
We are having trouble fixing it because we dont understand what should happen at all and DOCs are not helping.
This emote has never been so accurate.
Making me belive that this BranAI never worked right at all. I didnt found a working version. I still need to try the 097 and the Neverlands Reborn version.
What me and guialtran found is that the BrainAI/scripts/enterArea/generic.src never stops looping and most important it never wake up the npcs once it starts.
We put 7 prints to see if this script is doing everything right.
Code: Select all
// $Id: generic.src 1250 2011-11-02 02:22:41Z AustinHeilman $
//
//
use uo;
use os;
include ":brainAI:npcNerves";
include ":brainAI:npcCommands";
include ":brainAI:npcWatchList";
program BrainNerve(params)
Set_Critical(1);
Set_Event_Queue_Size(200);
var npc := params[1];
//var nerve_name := params[2];
var event := params[3];
var settings := params[4];
var scripts := params[5];
params := 0; // Not needed anymore.
print("loop "+getpid());
Set_Critical(0);
while ( npc )
print("while "+getpid());
if ( event )
case ( event.type )
SYSEVENT_ENTEREDAREA:
print("core "+getpid());
EnteredArea(npc, event, settings, scripts);
break;
default:
break;
endcase
event := 0;
endif
event := Wait_For_Event(3600); //on Edwards version wait_for_event is 1 - event := Wait_For_Event(1);
endwhile
print("endwhile "+getpid()); //only happens when the npc dies.
return 1;
endprogram
function EnteredArea(npc, byref event, byref settings, byref scripts)
var source := event.source;
print("AI_WakeUp 0");
if ( NPC_ShouldWatch(npc, source, settings, scripts) )
print("AI_WakeUp 1");
if ( NPC_AddToWatchList(npc, source) )
AI_WakeUp(npc);
print("AI_WakeUp 2");
return 1;
endif
endif
return 0;
endfunction
It shows that this script keeps running the "while ( npc )" part and is not wakening any npc at all.
print("AI_WakeUp 1"); and print("AI_WakeUp 2"); never happened.
Code: Select all
if ( NPC_ShouldWatch(npc, source, settings, scripts) )
print("AI_WakeUp 1");
if ( NPC_AddToWatchList(npc, source) )
AI_WakeUp(npc);
print("AI_WakeUp 2");
return 1;
endif
endif
Code: Select all
print("loop "+getpid());
print("while "+getpid());
print("core "+getpid());
print("AI_WakeUp 0");
Its not normal to loop like this forever. If a player runs into 100 npcs they will all start a never ending loop.
What should make this loop stop? the Brain.src script or leftarea script? should the loop stop when the npc wakes up?
We are having trouble fixing it because we dont understand what should happen at all and DOCs are not helping.
This emote has never been so accurate.
Re: BrainAI not working
While looking into the wander issue, one of the things I noticed is while yes, a mobile won't wander when initially created, when engaged in combat once combat for the mobile is over it'll wander for about a minute and then go back to sleep.
I'm assuming this is there to prevent constant npc movements across the server, which makes sense.
I tested this by standing at Brit bank, creating dragon2 and engaging in combat and then before killing it teleporting to the roof so it could not get me. It then stopped engaging and wandered about 10 steps and went back to sleep.
Not sure if this helps narrow anything down but mobiles should begging wandering when a player is within two screens of it to give the illusion of mobiles being more animated than they are.
I'm assuming this is there to prevent constant npc movements across the server, which makes sense.
I tested this by standing at Brit bank, creating dragon2 and engaging in combat and then before killing it teleporting to the roof so it could not get me. It then stopped engaging and wandered about 10 steps and went back to sleep.
Not sure if this helps narrow anything down but mobiles should begging wandering when a player is within two screens of it to give the illusion of mobiles being more animated than they are.
Re: BrainAI not working
the problem seems to be the watchlist process.
from npcWatchlist.inc
If I follow this and look at the "generic npc" it is using the watchfeared script.
by default this only adds the event source to the watchlist if it is an npc defined in the feared.cfg file.
I changed the final return value to "return 1" (also removed the return 0 for cmd level) and the npc seems to respond now when my char is in range.
Watchfeared.src
not looked at the combat scripts yet.
from npcWatchlist.inc
Code: Select all
function NPC_ShouldWatch( npc, mobile, byref settings, byref scripts )
if( !scripts["ShouldWatch"] )
// Assume it wants to watch everything if it has no script.
return 1;
endif
var result := Run_Script_To_Completion( scripts["ShouldWatch"].script, {npc, mobile, settings} );
if( result.errortext )
NPC_ErrorSysLog( npc, "Error::NPC_ShouldWatch() - "+result.errortext );
endif
return result;
endfunction
by default this only adds the event source to the watchlist if it is an npc defined in the feared.cfg file.
I changed the final return value to "return 1" (also removed the return 0 for cmd level) and the npc seems to respond now when my char is in range.
Watchfeared.src
Code: Select all
include ":brainAI:npcNerves";
include ":brainAI:npcCommands";
include ":brainAI:npcWatchList";
include ":brainAI:npcUtil";
program BrainNerve( params )
var npc := params[1];
var mobile := params[2];
//var settings := params[3];
params := 0; // Not needed anymore
if( GetObjProperty( npc, "#Peacemaking" ) >= ReadGameClock() )
return 0;
elseif( GetObjProperty( mobile, "#JustRess" ) >= ReadGameClock() )
return 0;
elseif( mobile.npctemplate )
var hate_config := ReadConfigFile( ":brainAI:hatelist" );
var config_list := FindConfigElem( hate_config, NPC_ParseTemplateName( npc.npctemplate ).template );
if( config_list == error )
return 0;
endif
var my_fear_list := GetConfigStringArray( config_list, "Fears" );
if( !( NPC_ParseTemplateName( mobile.npctemplate ).template in my_fear_list ))
return 0;
endif
return 1;
endif
return 1;
endprogram
not looked at the combat scripts yet.
Re: BrainAI not working
the genericcombat.src script:
The Edwards edited version moves the "AI_SetOpponent" line up outside the main while loop.
When first called the script sets the opponent, but does not retain it as in the original Mytharria script.
try change the script setup back as Austin had it (below).
hope it works
The Edwards edited version moves the "AI_SetOpponent" line up outside the main while loop.
When first called the script sets the opponent, but does not retain it as in the original Mytharria script.
try change the script setup back as Austin had it (below).
Code: Select all
while( npc )
if ( !npc.opponent )
AI_SetOpponent(npc, opponent);
endif