PDA

View Full Version : Trying to learn AI.obj and in need of help


Metalmurphy
15.09.2005, 14:19
Im trying to do a simple NPC that when a player clicks on a <a action="bypass -h talk_select">Link</a> it checks the level of the player and if level >= 30 show one html, if not show another. After searching a while i think this is the right code for it:


L####1
push_event // talker
push_const 32
add
fetch_i // level
push_const 888
add
fetch_i
push_const 30
greater_equal
branch_false L####2
L####2
shift_sp 1
push_event // talker
push_const 32
add
fetch_i
S###1. "IS_LVL_30.htm"
push_string S###1
func_call 43 // func[ShowPage]
shift_sp -2
shift_sp -1
jump L#####
L###4
shift_sp 1
push_event // talker
push_const 32
add
fetch_i
S###2. "IS_NOT_LVL_30.htm"
push_string S###2
func_call 43 // func[ShowPage]
shift_sp -2
shift_sp -1


I think its correct but if somone finds errors in it please tell me. Anyway what i want to know is, since this is a complete new NPC (it has no AI.obj) what do i have to put in the rest of the AI so that when a player clicks on that "Link" it shows either 1 html or the other.

Alien003
15.09.2005, 16:51
I have a similar question about the AI.obj

when we do


push_event // talker
push_const 32
add


what happens exactly? what value stays in stack?

Livid
15.09.2005, 16:58
Pointer to talker structure afaik.

HF
15.09.2005, 18:06
Im trying to do a simple NPC that when a player clicks on a <a action="bypass -h talk_select">Link</a> it checks the level of the player and if level >= 30 show one html, if not show another. After searching a while i think this is the right code for it:
...
I think its correct but if somone finds errors in it please tell me. Anyway what i want to know is, since this is a complete new NPC (it has no AI.obj) what do i have to put in the rest of the AI so that when a player clicks on that "Link" it shows either 1 html or the other.why are you need Html to finish? You found good code for some old npc, who use check to level. Example, Learn Masters and... new C3 "Newbie Guide", who cast newbie buffs ;) So, use cast skills to players (in defined levels range) to finished talking.

Metalmurphy
15.09.2005, 18:12
Well thats exactly what im trying to do. The C3 newbie buffer, but the others npcs with quests have alot of other code (to check if its a one time quest and stuff) that confuses me alot. Im new to this AI.obj stuff and still dont get most of it.

Metalmurphy
15.09.2005, 21:54
Well no one knows how to do this? Ive seen ppl do much harder stuff common im pretty sure this is an easy thing. Give this man some help :p

flakka
16.09.2005, 00:01
I agree. If we can get the breakdown of AI.obj and how it works (with a sticky as well when we get it), it would help immensely. :wink:

rodier
16.09.2005, 04:24
hmm do u know how to check item attribute via ai.obj? I have some code for mymyu that can change hatch to strider.. but it totally lag server when u run that (player click on that html menu)

Metalmurphy
16.09.2005, 11:00
You must have done it wrong then (maybe u inserted the code in the wrong place). I have the same code but it doesnt lag at all.

(still awating for somenoe to awnser my question)

Aikeleer
16.09.2005, 14:24
Hmm, let me try to make a 'newbie guide' for ai. :P In the AI all the 'pieces' are linked. I.e, you make a new merchant, that you call Gon.

It'll be like
class gon : merchant
class_end

What happens here is, you define a new class called 'gon' and you load all the 'merchant'-class ai aswell. If you look in the ai.obj and you look for 'merchant :', you'll see what all the merchant AI is. Overall, for a thing like a level-check, 'citizen' will be appropiate. :)

Let's keep the idea of Gon, but make it a citizen that checks your level:

class gon : citizen

Every part has handlers. All the handlers are written down somewhere, you can find it with the search. There are handlers for being attacked, being talked to, or being asked. In this case we work with talk select. This is handler 4.

Let's start:

handler 4 // TALK_SELECTED
variable_begin
"fhtml0"
"i0"
"quest_id"
"talker"
"myself"
"_choiceN"
"_code"
"_from_choice"
variable_end

If you search through the ai.obj, you'll see that talk_select things always start with a check if it's from choice. So:

push_event // _from_choice
push_const 332
add
fetch_i
push_const 0
equal
branch_false L1

Ok, the first part is ready. If it's not from choise there shouldn't be done anything. L1 will be at the bottom, so nothing gets loaded anymore. Let's continue with your part
L2
push_event // talker
push_const 32
add
fetch_i // level
push_const 888
add
fetch_i
push_const 30
greater_equal
branch_flase L4

Ok, what we have above is fairly simple. The player is push_const 32. With the fetch_i push_const 888 command you get his level. This should be greater, or equal, to the value '30'. If it's not, then you should go to L4, otherwise continue.
L3
shift_sp 1
push_event // talker
push_const 32
add
fetch_i
S1. "IS_LVL_30.htm"
push_string S1
func_call 43 // func[ShowPage]
shift_sp -2
shift_sp -1
jump L1

Ok, obvious. It should show the page and after this it shouldn't parse any more code. The L1 is the empty label at the end. Ok, if we're >= 30, you get a page and the rest isn't parsed. So, if you're < 30, the ai should have a code to show you a page. So:
L4
shift_sp 1
push_event // talker
push_const 32
add
fetch_i
S2. "IS_NOT_LVL_30.htm"
push_string S2
func_call 43 // func[ShowPage]
shift_sp -2
shift_sp -1
L1
handler_end
class_end

Metalmurphy
16.09.2005, 15:43
Finaly my pleas where heard. xD your help is very very much apreciated, and im sure alot more ppl other then me will apreciate this :)

My code was pretty correct afterall, i just switched the htmls pages (and now that i look at it i dunno why i made that mistake couse i did understood the branch_false , probably wasnt paying attention. But your guide allowed me to understand the rest i was missing.

Again many thanks :)

toolpunk
16.09.2005, 16:55
woot!
thats nice. really helpful. mods plz sticky this sumwhere!
thx a lot aikeleer. u r the man ;)

and now a lil quest for u my young apprentices XD lol im talkin trash...
find the mistake.
branch_flase L4
correct it if u like or leave it as it is :p

flakka
16.09.2005, 18:23
Awesome! :D

I'll make a note of this topic so I can put it in a sticky forum.

Now all I have to do is sift through all of the [Tutorial] topics and move them into one place.

Thanks a bunch, Aikeleer! :thumbup:

An@BoL
16.09.2005, 18:35
Unfortunately I've posted my request in wrong topic. Hope to find answer in this one. That's why I'll "copy/paste" my question here. =)
On my way to understanding ai.obj I've found, that somewhere exists a tool "NPC AI Script Compiler". Does any1 know smth about it or maybe where to find it?
This tool helps to translate ai.obj into more understandable thing afaik.

flakka
16.09.2005, 18:38
Yeah, it's called NASC. I'm sure it's here on the forum. Only problem is that it only supports C1 and it's really old and obsolete I believe.

toolpunk
16.09.2005, 18:40
afaik its a compiler.
means u enter source code. more logic than this pseudo assembler crap and compile it 2 get the pseudo asm crap.
kinda easier, better, faster and more efficient.
i think it worx on sina only...
or was it meifu?

An@BoL
16.09.2005, 19:59
That's exactly the thing I need for my Sina C1. The problem is I couldn't find it neither on this forum nor somewhere else. Can somebody post the link?

flakka
16.09.2005, 22:52
Here.

http://zupload.com/download.php?file=getfile&filepath=6800

toolpunk
17.09.2005, 07:53
so does it still work in c3?
i mean basically the structure of ai n scripts r still the same as back in c1.
only heavily modified files r the exes...

[off-topic]
woot! sum1 is usin the hosts i posted. :D :D :D
im kinda happy now rofl^^
[/off-topic]

An@BoL
17.09.2005, 16:41
There I've found "AIEditor.zip". But I've already had that crap. Just wanted to try NASC.

P.S. Thanks any way. ;-)

Anubisan
20.09.2005, 23:03
I have been trying to get NASC to work for some time as well. I am trying to add a very simple kill monsters and collect items quest, but it seems far too difficult to do just in AI.OBJ. The way everything is organized and numbered in there is confusing as hell.

Unfortunately, it seems that the version of NASC that we have is not compatible with the servers that we have. Our NASC version produces an AI.OBJ with the following version information before crashing with a syntax error:

SharedFactoryVersion 294
NPCHVersion 177
NASCVersion 105
NPCEventHVersion 76
Debug 0

Whereas our working AI.OBJ has the following version information:

SharedFactoryVersion 324
NPCHVersion 210
NASCVersion 133
NPCEventHVersion 82
Debug 0

Unless we can find NASC version 133, it appears we won't be able to modify the AI.OBJ any easier than we currently are.... which really sucks, because I doubt I will be able to figure it out enough to add the quests I was hoping to add.

- Anubisan