[Tutorial] DIY Buff Bot

Guides for osRose and osiRose (compilation / setup)...

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

[Tutorial] DIY Buff Bot

Postby PurpleYouko on Mon Mar 16, 2009 9:43 pm

Introduction to AIP
Buff Bot (custom NPC)

Tools you will need.
AIP editor
IFO editor
STB/STL editor
LTB editor (if you want your NPC to speak)

Down to basics.
First of all what is AIP?
AIP is a system of coded instructions that rose uses to tell all teh monsters and NPCs in the game what they should do.
It is parsed by both the server and the client (although each of them uses different parts of the code) every few seconds. In the case of NPCs it is much longer though, typically a minute or so.

For making a Buff Bot NPC we are only going to use a few of the conditions and actions that are available to us so the AIP won't be all that complicated.

Our Buff Bot NPC is going to stand around looking pretty then every few minutes ( I am setting this to a minimum of 20 cycles but you can modify this if you like) she will be giving away free buffs to everyone in range.

Before we can get to the AIP though, we have to do all this other crap so please bear with me a bit longer. :lol:

first steps
First thing we are going to have to do is to make oursleves a custom NPC. I am going to put this one in Zant and make her stand a little way up from Judy at the north end of the main plaza. he will be pretty much facing Spero. Should be a nice easy place to access to get buffs.
I am not focusing on how to add a custom NPC. This tutorial will skip over all but the essentials of that so if you want a little more detail on that you should go read this tutorial on the subject.

Files you need to edit to add the NPC
3ddata\STB\LIST_NPC.STB
3ddata\STB\LIST_NPC_S.STL
3ddata\NPC\LIST_NPC.CHR

Ok so what NPC should we copy to make our Buff Bot. You can use any one you like. I'm going to use the Lena and call her "[Kuro-Tejina Staff] Buffy" but you can call use whatever you like. Buffy will be joining the ranks of Kuro-Tejina staff who work on my KTRose pre-evo server :D

First thing to do is open LIST_NPC.STB so go ahead and open the file in an STB editor. (I'm using my Excel utility but you can use any)
NPCs start around line 1000 so scroll down to that area and find all the NPCs that are in Zant. They should be the first block of entries.
Find an open line at the end of the block and remember the line number. This is important. It will become your NPC's ID number from now till the end of time in your server.

Now go find the entry for Lena It should be on line 1014
Copy the entire entry into your chosen empty line at the end of the block of Zant NPCs. This is row 1024 in my server but it may be different in yours.
It should look something like this now.
Image
Note that I highlighted the value in the AI column. That is the reference to the AIP file that we are going to use so we are going to have to change it a bit later because it still points to the Angel's AI right now.
I also changed his name in the name column. It won't come through in the game that way though. We need to edit the STL that goes along with it.
First of all (Still in the STB) scroll across to the right until you reach the column with the STL reference values. It currently says LNPC1014 which is wrong.
I just placed Buffy into row 1024 so I'm going to change the value to LNPC1024
If you put it in a different row then use the id from whatever row you put it in.
Don't save the STB yet. We have a way to go yet. ;)
Now go to the STL tab (or use a stand alone STL editor) and open LIST_NPC_S.STL
Add this entry.
Image
I inserted the line into the editor in the middle right after entry LNPC1023 but you can actually put it any place you like.
Caution.... If using my Excel editor make sure you scroll to the bottom of the file and make sure that there is a number next to the last entry in column 2. Inserting in Excel shifts the cells downward by one line and this sometimes leave a row without a reference. My editor might not save the last row if you miss this step.
Also you can ignore the "Dark Fairy" entry. that's just another custom NPC that we are adding at KT Rose ;)

OK you are done with the STL. you can save it and put it back into your client with your VFS editor now.

Now back to the STB.
We still need to figure out what AIP file we are going to link it into. It's still pointing at a blank space which is completely wrong. Lena has no AIP apparently
So how do we figure this out?
Well there is an STB file called FILE_AI.STB that tells us which AIP files to associate with which numbers in LIST_NPC.STB.
If you are using my editor, it isn't possible to open multiple instances so go ahead and save the STB that we are working on but don't put it into your client's VFS yet. We still need to come back to it yet.

now open FILE_AI.STB and scroll down to row 211. it should point to 3DDATA\AI\NPC_1020.aip which is the last NPC before the one we are adding.
On the row immediately after this we can add our new entry 3DDATA\AI\NPC_1024.aip Note: I made the name of the AIP file reference the same as the NPC id number from LIST_NPC.STB. This isn't strictly necessary but it does make it easier to keep track of things.
FILE_AI.STB should now look like this
Image
Go ahead and save the STB then put it into your VFS with your editor. We are DONE with this one.
NOTE: You also need to add this file to your server or your new AIP file won't work

Now back to LIST_NPC.STB. Re-open the file and go to the new entry that we added earlier.
Go to that entry for the AI that i ringed earlier and change it to point to the row in FILE_AI.stb where we just added the new entry. in my example this went into row 212 so i am going to put 212 in that cell instead of the 236 that is currently there.
That's it for LIST_NPC.STB. Save it and add it back into your client and server. It will need to be in both

Finally we need to tell the client which bones images and animations to display for our new NPC so open 3ddata\NPC\LIST_NPC.chr with maxxon and Sethanye's wonderful little CHR editor.
Image
Put 1024 (the id of our new NPC) into the "Entry" window at the top right then click "jump to"
All the stuff down the right will now be empty
In the next box down on the right where it says Entries type in 1014 (the id of Lena who we are copying) then click the Copy button
All the stuff will appear just as shown in the picture
Save the file and put it back into your client. We are DONE with this one.

One last thing we need to do to make our NPC show up and that is to add her into the database.
So open up your database editor (Navicat, phpmyadmin or whatever floats your boat)
Open table list_npc and get ready to make a new entry at the bottom of the list.
In the Name field put your NPC's name. Mine is [Kuro-Tejina Staff] Buffy as I've already told you. You can call yours Barbara Buffer if you like.
In the type field put 1024. this is the NPC ID number. If you put your NPC at a different row in LIST_NPC.STB then use the row number.
In the map field put 1. this points to Zant
In the dir field put 185. this is the direction that your NPC will face. 185 makes her face toward Spero
In the x field put 5226. This is the NPC X coordinate
In the y field put 5218. this is teh NPC Y coordinate
In the Dialog field leave as zero. We don't have any dialog for this NPC right now and if we ever put any in, it will be a different tutorial completely.
Save your table

And of course we need a skill or two for our little Buffy to actually cast.
There are very few ready made that will do what we want so let's go make a new skill.
Open up LIST_SKILL.STB in the STB editor of your choice and scroll down till you find the GM buff skills.
Unfortunately the format of LIST_SKILL.STB is very different in evo servers than it is in pre-evo or irose. I'm going to show you how to do it for Pre-Evo / irose but I think that it should work for evo also. let me know if it doesn't.

Pre-evo / irose
Your GM skills should start at row 3201 so scroll down to there and take a look around. You should find a block of skills labelled LSKILL3201 to LSKILL3221
We need the one that puts up Attack Power and Accuracy.
In pre-evo this is 3202
What I'm going to do is copy the entire row 3202 and paste it at row 3230. that's going to be the new skill that we are going to set up our buff bot to use.
First though we need to make some alterations because the GM skill isn't going to work the way it is set up right now.
here is what I did with mine
Image
Only the places that i marked in red really need to be changed at all.
First level skill ID should be set to the same as your skill id
Target needs to be changed to 7 so that it will point to all characters
Skill type needs to be 10 (AOE BUFF)
Cost type and amount are deleted entirely as there is no point charging an NPC MP to use a skill.

I also reduced the range a bit but that is not absolutely necessary.


Now finally we get to the AIP.
First thing you need to do is download my AIP editor.
This is a slightly newer version with a few more bugs fixed so even if you already grabbed the one i posted in the tools list, this supersedes it.
AIPEdit 1.4.zip
(53.28 KiB) Downloaded 1029 times


I'm including a simple AIP file that I made for this also
NPC_1024.zip
(304 Bytes) Downloaded 959 times

This file will make your buff bot fire off one instance of skill 3230 every 20 minutes or so.

Sorry but getting this working and all written up here has taken longer than i thought it would so I'm going to have to leave it here and come back to the actual AIP editing tomorrow.

One last thing to note (and it's a biggy)
This buff wot WILL NOT WORK on any of the current osrose servers :lol:
None of them currently have code to handle NPCs casting skills.
rev 81 dev rev could be adapted very quickly and easily though. I will pass on my code to Lmame so that he can add it.
OsProse is also pretty close but will require a few modifications to get it working. I have this all working on my own private server after having made the necessary changes today. will get it up onto the SVN...... eventually ;)
Osirose is miles away I think. :(

Should work fine on Arc files as they stand.

Anyway. AIP tutorial and instructions will follow tomorrow if i get time to write it up :D
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: [Tutorial] DIY Buff Bot

Postby PurpleYouko on Tue Mar 17, 2009 9:53 pm

OK *cracks knuckles* let's get down to some AIP :D

First thing you need to do is fire up my AIP editor and load in NPC_1024.AIP (the file that I included in the post above)
once you have it open you should see something like this
Image
There's not a lot going on there really at the moment.

Click on Block 2: Idle: Monster is not in combat in the first list then 2 records appear in the upper right list box. Click Record 1 and a bunch of stuff appears in the Condition and Action areas.
These are the Conditions and Actions that are associated with this specific record.

In AIP, records are parsed sequentially from first to last. .
The conditions are checked first. An action is only performed when ALL the conditions of the record are found to be TRUE. If they are not all TRUE then the code moves on to the next record where its conditions are checked..... And so on till the end of the file...
The code only stops when it either performs an action or reaches the end of the AIP file.

So what are all those empty boxes and stuff?
Those are where all the data will be displayed when we select a condition or action.

Go ahead and select the first condition of the first record.
You should see this.
Image
Now you have a bunch of data bytes and some nice handy labels have appeared to show you what they all mean. if you click the button labeled Test cond then the utility will parse the bytes and display an output in the text bar beneath the data bytes. If you haven't changed any data yet then this will be exactly the same as the condition listed above.
If you want to know a bit more about what the labels mean, hover the mouse over them and popup messages will tell you what they do. Each Operation Code (OpCode) has a unique set of labels that is associated with it.
Right now we have 4 bytes in a set that is labeled RefVarand a single byte labeled btOp
RefVar is a special variable that, once loaded, is held in memory for the duration of the AIP record. That means that once the code in Rose Server (and client) reads in the value in the condition, all subsequent conditions and actions in this record will have access to this value
You will notice that both the second condition Check variable objVar[1024][1] TRUE if value < 20 and the action Set variable ObjVar[1024][1] Add value 1 have the number 1024 embedded in them.
But where does this 1024 come from??? :o
how the heck does 0,4,0,0 make 1024?
The values in each cell are Hexidecimal with the least significant byte at the left and the most significant byte to the right.
The left most cell will directly translate to the same value in either byte (one cell) or DWORD (4 cells) format. If you put any number from 0 to 255 in that cell then that is exactly the number that will get used. Try it. Mess with the numbers a bit and click Test cond after each change
The second cell (where we currently have a 4) is the 256 or FF cell. Whatever we put in here is multiplied by 256 and added to the value in the first cell. do the math. 4 X 256 = 1024
The third cell is the 65536 column and the 4th is the 16777216 column
if you put 255 in every one of them you will get a value of 4,294,967,295 or FFFFFF (4.3 billion) except that is not what will be displayed. VB doesn't allow for unsigned integers so the final bit (8 bits make a byte) is the sign bit which means that your output will be -1 :lol:

Anyway enough of that. On to the next bit of condition 1

btOp is an operator. It can hold a value of 0 to 10.
A value of zero means you get a "=" in your equation but in this particular case btOp isn't used and shouldn't even be there :lol:
The label will be removed from subsequent versions of the editor. Typical that we find a bug in the very first condition.
Either way it doesn't matter. The btOp byte will be ignored by the editor in this case no matter what we do with it. The error is only with the labeling.

Condition 1 cannot return FALSE since all it does is assign a pointer RefVar

So now on to condition 2
Set variable ObjVar[1024][1] Add value 1
Click the condition to load up its labels and data bytes then click Test cond to parse it into the text output box.
You will now see this
Image
Notice that we have a bunch of new labels now.
If you hover over the first one Var, you will see that it tells you that it is an index pointer. It is in fact the 1 in ObjVar[1024][1]
So what about the 1024 in ObjVar[1024][1]???? I don't see that anywhere.
That comes from the Refvar setting in the first condition. Remember I told you that RefVar is a special variable that stays in memory through the entire record?

next we have a few unused bytes. Don't worry about those

Value This is another 4 byte variable and this time we only have a value of 20 in the least significant byte. This will be the number that we compare to the the indexed value of the ObjVar array to depending on the value that we will find in the btOp byte

The ObjVar array is another rather special set of data used by both the client and server.
It consists of a 2 dimensional array Objvar[x][y] and the values placed into any part of it are available to every NPC and Monster in the entire worldserver.
The X coordinate typically corresponds to the NPC number of the NPC for whom we are parsing the AIP script.
The Y coordinate points to one of 20 individual array elements that each NPC can hold.
If you use Y = 0 you can set event ids of the NPCs but more on that another time.
In this case we are checking whether the value currently held in Objvar[1024][1] is Greater than (btOp = 3) Value 20
If Objvar[1024][1] > 20 then the condition returns TRUE and runs the Action
otherwise it returns FALSE and moves on to the next record.

The Action
Set variable ObjVar[1024][1] Add value 1
Click the action, click Test action and you will see this
Image
Again we are using the same RefVar from the first condition but this time we are setting a value in the ObjVar array rather than checking the value already in it.
Once again we have Var = 1 so we are doing something to ObjVar[1024][1]
Value = 1
and finally btOp = 6
As i mentioned before, btOp can hold a value ranging from 0 to 10. 6 happens to mean add so in this case we find that we have to add (btOp) a Value of 1 to ObjVar[1024][1]

So what is going to happen when we run this AIP record?
Simple.
each time it runs it looks at the ObjVar array and checks whether the value in element [1024][1] is less than 20. If it is then it performs the action which adds 1 to the current value.
So after 20 cycles (run at 1 per minute in osprose server code) the value will finally reach 20 at which point it will return FALSE and move on to record 2.
It is a 20 minute delay loop. nothing more and nothing less. :D

What about the 3 bytes at the end that have no labels?
The bytes 103, 99, 1
TBH I have absolutely no idea what they are for at this point. just leave them alone for now till somebody figures out what they do.... if anything. I wouldn't be surprised to find that they are just unnecessary random crap :lol:

And once more i am out of time. I will continue withanalyzing record 2 tomorrow.
g'night people I'm outa here Image
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: [Tutorial] DIY Buff Bot

Postby lmame on Wed Mar 18, 2009 12:02 am

Nice one :D
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [Tutorial] DIY Buff Bot

Postby Mike567 on Wed Apr 15, 2009 3:25 pm

thnx
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: [Tutorial] DIY Buff Bot

Postby PurpleYouko on Wed Apr 15, 2009 4:15 pm

does anybody need me to go through the next record?
or are we Ok with it already?
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: [Tutorial] DIY Buff Bot

Postby Mike567 on Thu Apr 16, 2009 6:16 am

hmmmm

purple youko

this can be in a osrose?
User avatar
Mike567
Antares
Antares
 
Posts: 392
Joined: Wed Mar 19, 2008 4:27 am
Location: Philippines

Re: [Tutorial] DIY Buff Bot

Postby lmame on Thu Apr 16, 2009 10:23 am

Yes.
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [Tutorial] DIY Buff Bot

Postby PurpleYouko on Thu Apr 16, 2009 2:06 pm

Mike567 wrote:hmmmm

purple youko

this can be in a osrose?


Makes no difference. AIP is AIP.
The differences are in the way that the server parses the AIP files.
osrose dev rev and osprose do it pretty much the same
osirose is missing a few functions but does a decent job.
osrose rev 80 doesn't handle AIP at all.
Need to lookup information on NARose items, skills, quests?
Now featuring a newly completed skill tree for all classes
Formatting fixed for different resolutions
Image

"A Gazelle is nothing but a giraffe plotted logarithmicaly"
User avatar
PurpleYouko
Rose Guru
Rose Guru
 
Posts: 4733
Joined: Fri Aug 10, 2007 2:05 pm

Re: [Tutorial] DIY Buff Bot

Postby DeltaBurnt on Sun Jun 28, 2009 8:05 pm

Sorry for the bump but I can't get this to work on an Arc server. I added all the files to the client and the server but there's no NPC table in the database. So how do I tell the server where the NPC goes and to make it show up?
DeltaBurnt
Rackie
Rackie
 
Posts: 206
Joined: Sun Jun 21, 2009 10:35 pm

Re: [Tutorial] DIY Buff Bot

Postby DoubleEagles on Sun Jun 28, 2009 8:14 pm

IFO...
DoubleEagles
Rackie
Rackie
 
Posts: 225
Joined: Sat Dec 13, 2008 9:00 am

Next

Return to osRose / osiRose Guides

Who is online

Users browsing this forum: No registered users and 8 guests

cron