how i can move npcs but still react to events?
is there some way to handle several scripts to npc or use parallel streams for different actions like moving/fighting
npc ai problem
Moderator: POL Developer
Re: npc ai problem
AI script is event catcher.
You can start as many parallel script as you want, and send those events to AI.
Where is the problem?
You can start as many parallel script as you want, and send those events to AI.
Where is the problem?
Re: npc ai problem
ok, lets imagine
speech event cheks 2 command:
"move forward 100 steps"
"stop moving"
i said first command and AI script start the cycle
for i=0;i<100;i++ moveforward blablabla
while 50-th step is on, i say "stop moving" and expect that moving is stops ( by changing props or something another way to check ). but my script still execute step's cycle and command will be ignored
speech event cheks 2 command:
"move forward 100 steps"
"stop moving"
i said first command and AI script start the cycle
for i=0;i<100;i++ moveforward blablabla
while 50-th step is on, i say "stop moving" and expect that moving is stops ( by changing props or something another way to check ). but my script still execute step's cycle and command will be ignored
Re: npc ai problem
so, catch for events inside of your moving loop
for i=0;i<100;i++
stepforward
checkforevents (wait sleep makeapizza drinkabeer)
endfor
ps. you can also perform moving inside of main loop.
while waitforevent(1)
if (needs_to_be_moved)
stepforward
needs_to_be_moved:=false
endif
chackforevents
endwhile
for i=0;i<100;i++
stepforward
checkforevents (wait sleep makeapizza drinkabeer)
endfor
ps. you can also perform moving inside of main loop.
while waitforevent(1)
if (needs_to_be_moved)
stepforward
needs_to_be_moved:=false
endif
chackforevents
endwhile
Re: npc ai problem
I'll try, but same method provide a big load for sever. if i want to hide delay between steps, i need to repeat main cycle near 10 times at second. and this is ony one npc. i not sure that it a good decision
Re: npc ai problem
testing shows that near 150 npcs with 2 two enabled events and similar functionality and delat beetwen cycle as 50ms increasing sysload from 3-5 to 25-35.
Re: npc ai problem
when entering e.g. a Fight Mode you can start parallel running scripts with start_script
Re: npc ai problem
Found an error.
This is a new feature.
Translated by google translator.
This is a new feature.
Code: Select all
function AiStop(byref npc,byref prop,byref index,byref poltime)
var commands := prop.instruction[index].commands;
var flag := Cint(prop.instruction[index].flag);
var id := 0;
prop.instruction.erase(index);
foreach command in commands
id := AiGetIndexByCommand(prop,command);
if(id)
Print("Stop command: " + command + " out_event: " + prop.instruction[id].out_event + " out_quest: " + prop.instruction[id].out_quest + "mobiles: " + prop.mobiles.size() + " flag: " + flag);
Case(command)
"attack": SetWarMode(0);
endcase
if((flag or prop.mobiles.size()) and prop.instruction[id].out_event)
MSendProcEvent(struct{type := SYSEVENT_UPDATE,source := struct{key := "check_event",who := npc,sid := poltime,template := MGetNpcTemplateByPatch(npc.npctemplate),id := MGetNpcId(npc),realm := Lower(MGetNpcrealm(npc)),region := Lower(MGetNpcRegion(npc)),event_name := prop.instruction[id].out_event,quest_name := prop.instruction[id].out_quest}},MGetNpcProcGroup(npc),MGetNpcProcName(npc),Lower(MGetNpcrealm(npc) + ":" + MGetNpcRegion(npc)),SystemFindObjectBySerial(MGetNpcSpawner(npc)));
endif
prop.instruction.erase(id);
endif
endforeach
prop.idletime := prop.maxidletime + 1;
return 0;
endfunction
Re: npc ai problem
In components to a subject. Whether it is possible to add in the future to a kernel a system event which would occur when NPS would meet on the way of other NPS or the player?
Because SYSEVENT_ENTEREDAREA occurs, current when someone enters the NPS area and if NPS itself Meets Someone on the way that doesn't occur and on it it is necessary to scan periodically terrain to find somebody, and it is load of the server.
Message translated by an electronic translator.
Because SYSEVENT_ENTEREDAREA occurs, current when someone enters the NPS area and if NPS itself Meets Someone on the way that doesn't occur and on it it is necessary to scan periodically terrain to find somebody, and it is load of the server.
Message translated by an electronic translator.