Page 1 of 1
npc ai problem
Posted: Sat Feb 18, 2017 5:23 am
by az_rieil
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
Re: npc ai problem
Posted: Tue Feb 21, 2017 2:49 am
by az_rieil
no ideas? :c
Re: npc ai problem
Posted: Tue Feb 21, 2017 5:12 am
by RusseL
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?
Re: npc ai problem
Posted: Tue Feb 21, 2017 7:23 am
by az_rieil
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
Re: npc ai problem
Posted: Tue Feb 21, 2017 8:07 am
by RusseL
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
Re: npc ai problem
Posted: Tue Feb 21, 2017 11:29 am
by az_rieil
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
Posted: Tue Feb 21, 2017 12:01 pm
by az_rieil
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
Posted: Wed Feb 22, 2017 3:08 am
by RusseL
when entering e.g. a Fight Mode you can start parallel running scripts with
start_script
Re: npc ai problem
Posted: Wed Feb 22, 2017 7:34 pm
by NightOwl
az_rieil wrote: Sat Feb 18, 2017 5:23 am
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
Look at this script.
Message translated with help of Google translator.
Re: npc ai problem
Posted: Fri Feb 24, 2017 7:58 am
by NightOwl
Found an error.
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
Translated by google translator.
Re: npc ai problem
Posted: Sat Feb 25, 2017 4:12 am
by NightOwl
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.