5 Attachment(s)
[Tutorial to writeGlobalField function]How to add new field and edit existing one
This tutorial is explaining how to use Write Field function.
We will talk about creating fields, exporting them and connecting them to existing maps in Priston Tale.
Tutorial expects that you have basic knowledge of 3D Studio MAX
and very basic knowledge of C/C++ language.
X Y Z in PT and 3DS MAX
Login to PT with debugger/admin account and press F9.
We will create field that is near Ricarten, capital city of Priston Tale.
As you can see on picture below PT shows location in X Z Y but for 3DS MAX its X Y Z.
http://forum.ragezone.com/attachment...oordinates.png
Formula look like this:
Code:
PT X = 3DS X
PT Z = 3DS Y
PT Y = 3DS Z
So if we have this location on PT screen:
X = 4016, Z = -17481, Y = 120
In 3DS we will create field at:
X = 4016, Y= -17481, Z = 120
I hope that’s clear.
Creating simple field in 3DS
- open your 3DS MAX and create simple "Plane" 100 x 200
- press "Select and Move" and on X Y Z enter our location
Code:
X = 4016, Y = -17481, Z = 120
- we are on place that is near Ricarten sea and we can start building field
- we have our "Plane" on ground with Z = 120 so it’s on same height as Ricarten ground, you can put few objects with different options here and see how Player will interact with them but for now lets keep it simple
- create "new_field" folder in PT "Field\" folder
- I uploaded checker.bmp (256x256) so save it into to "Field\new_field\"
http://forum.ragezone.com/attachment...1&d=1297176495
- select your "Plane" and press "M" to open Material Editor, select first material and near name you will see rectangle with name, be sure that it say "Standard" if not than click rectangle and select "Standard" from list
- on first page of material you will see "Blinn Basic Parameters" and under it "Diffuse:" there is a little box on right, press it and from list double click Bitmap, next window will tell you to select bitmap, do it but be sure that bitmap you selecting is in "Field\new_field\" folder
- I highlighted in red important parts
http://forum.ragezone.com/attachment...1&d=1297177188
- be sure you added bitmap or else PT will crash
- export to .ASE and name it "new_field.ASE", save it in "Field\new_field\"
- use those options to export:
http://forum.ragezone.com/attachment...1&d=1297176495
We have some simple field that we will develop later.
You should have:
checker.bmp and new_field.ASE in \Field\new_field\ folder by now.
Adding new_field to writeField function
Here’s come programmer part but don’t worry its easy as saying Pneumonoultramicroscopicsilicovolcanoconiosispneumonoultramicro 3 times fast ;)
I am joking ofc.
Read this:
http://forum.ragezone.com/f399/write...0/#post6151545
before we proceed.
There are only 10 functions and for first time we will use only few to show how field in PT are working.
- open wirteField.dev with Dev-C++ and first thing you should notice are:
Code:
//----- Fields definitions
- On bottom you will find:
Code:
#define dun_9 dun_6 + 5244
//----- New field name last filed name + offset from last field
//----- #define new_field dun_9 + 5244
- add (or remove “//----- “):
Code:
#define new_field dun_9 + 5244
That’s first thing that need to be done, this will create new space for our field.
Next field will be new_field_two new_field + 5244 and so on...
- lets go even lower, to the last field where you will see:
Code:
//----- (new field) ------------------------------------------------------------
totalFieldsNumber = 44; /* add 1 for new field */
- you can start from changing totalFieldsNumber = 44; to:
totalFieldsNumber = 45;
There is always one more field, I call it dummyField, if dummyField does not exist than PT will crash when you fall from cliff or jump a bit while running (only on last field if dummyField does not exist).
- under
Code:
//----- (new field) ------------------------------------------------------------
Start writing:
Code:
field(new_field, "new_field\\new_field.ASE", "new_field");
// you already should know what this is from reading
// http://forum.ragezone.com/f399/write...0/#post6151545
// new_field is space we defined on top of this file
// "new_field\\new_field.ASE" is location where we exported our new_field.ASE
// "new_field" is short name, don’t bother with it for now, just type same name as new_field.ASE
// But without .ASE
This will tell PT that we have field!
- next function we should add is
Code:
fieldCmd(new_field, 4036, -17481);
// just put some PT, X Z (3DS, X Y) here and you will be teleported to that location
// we will move X a bit to the front (see first picture why) and we should get X = 4036, Y = -17481
// location on water in Ricarten... but because there will be field we will teleport on top of that, Z is calculated automatically
// fieldCmd is respawn function when respawn function don’t exist on your field
// /field 44 command will take you to that field X Z
- next thing that we probably should add is environment ()
- because my field is near Ricarten I will copy environment from village-2 (village-2 = Ricarten Town)
Code:
environment(new_field, fldT_town, 2, 3, 1, bgmT_town_1_tempskron_ricarten, 0, 1, 1);
// remember to change village_2 to your space new_field
Now we can compile it and use /field 44 to get on field but that’s not what we want, source was created to add anything to any field at any time.
- lets go to the bottom of "village-2" (CTRL + F it if you can’t find it)
Add fieldLoad() function there:
Code:
fieldLoad(village_2, new_field, 4016, -17481, 120);
// this function will load "new_field" from village_2 (Ricarten) space
// when you get eye contact with X Z Y (3DS X Y Z, try to remember that.. always!)
// and result is loaded field that you can walk on
- now lets save changes and compile code (CTRL + F9)
- put writeFile.dll into PT main folder, login to PT and go to location we where taking about
- you should see this (you will probably not see "LOADING" picture because its small field and it will just blink):
http://forum.ragezone.com/attachment...1&d=1297178618
GZ! Your first basic field is created, now you can make it bigger, add object and experiment with things you can and can't do.
All you need is imagination... ship that takes you to other field in that place would be a cool idea!
Choosing sky
Sky is giving your field feel and look, its important part of your environment. We can create desert or ice field, heaven or hell.
Sky is composition of sun/moon, space, hills, fog, colors, global lighting and other parts... so you can see how powerful this alone can be.
Right now we define our environment function as:
Code:
/* Environment */
environment(new_field /* Field start (new field every 5244) */ ,
fldT_forest /* Field type (use name or number, fT_forest = 512) */ ,
skyT_forest_day_4 /* Day sky (use name or number, skyT_forest_day_4 = 2) */ ,
skyT_forest_evening_5 /* Evening sky (use name or number, skyT_forest_evening_5 = 3) */ ,
skyT_forest_night_6 /* Night sky (use name or number, skyT_forest_night_6 = 1) */ ,
bgmT_forest_darkwood /* Background music (use name or number from -1 to 12) */ ,
0 /* 0 = monsters spawn all the time,
1 = monsters spawn only at night */ ,
1 /* field lvl */ ,
1 /* Skills block */ );
skyT_ is short for sky type, we have 35 to chose from:
Code:
//----- Sky types
//----- Defined in Effect\\Sky\\test16.txt and Effect\\Sky\\test32.txt
//----- English translation provided by bobsobol
enum skyType
{
skyT_rainy_sky_7 = 0, //Rainy sky
skyT_forest_night_6 = 1, //Forest at night
skyT_forest_day_4 = 2, //Forest daytime
skyT_forest_evening_5 = 3, //Forest in the evening
skyT_desert_day_8 = 4, //Desert daytime
skyT_desert_evening_9 = 5, //Desert in the evening
skyT_desert_night_10 = 6, //Desert at night
skyT_wilderness_day_0 = 7, //Wilderness daytime
skyT_wilderness_day_1 = 8, //Wilderness daytime /* Have same settings as 7 */
skyT_wilderness_night_3 = 9, //Wilderness at night
skyT_unused_sky_1 = 10, //Unused in kPT version 1.98.9
skyT_wilderness_evening_2 = 11, //Wilderness in the evening
skyT_unused_sky_2 = 12, //Unused in kPT version 1.98.9
skyT_unused_sky_3 = 13, //Unused in kPT version 1.98.9
skyT_unused_sky_4 = 14, //Unused in kPT version 1.98.9
skyT_unused_sky_5 = 15, //Unused in kPT version 1.98.9
skyT_unused_sky_6 = 16, //Unused in kPT version 1.98.9
skyT_in_forest_night_13 = 17, //In the forest at night
skyT_in_forest_day_11 = 18, //In the forest
skyT_in_forest_evening_12 = 19, //In the forest in the evening
skyT_iron_night_16 = 20, //Iron at night
skyT_iron_night_17 = 21, //Iron at night /* Broken in kPT version 1.98.9, taking settings from 20 */
skyT_iron_day_14 = 22, //Iron daytime
skyT_iron_evening_15 = 23, //Iron in the evening
skyT_sod_sky_day_18 = 24, //Sword sky daytime /* SoD 2 round 7-8 sky */
skyT_sod_moonlight_night_19 = 25, //Sword moonlight night /* SoD 2 round 4-6 Lunar stage sky */
skyT_unused_sky_7 = 26, //Unused in kPT version 1.98.9
skyT_unused_sky_8 = 27, //Unused in kPT version 1.98.9
skyT_unused_sky_9 = 28, //Unused in kPT version 1.98.9
skyT_unused_sky_10 = 29, //Unused in kPT version 1.98.9
skyT_unused_sky_11 = 30, //Unused in kPT version 1.98.9
skyT_unused_sky_12 = 31, //Unused in kPT version 1.98.9
skyT_desert_evening_9 = 32, //Desert in the evening /* SoD 2 round 4-6 Solar stage sky */
skyT_sod_black_20 = 33, //Sword black /* SoD 2 round 1-3 sky */
skyT_iron_boss_sky_21 = 34, //Iron Boss sky
skyT_ice_day_23 = 35, //Ice Daytime
skyT_ice_evening_24 = 36, //Ice in the evening
skyT_ice_night_25 = 37, //Ice at night
skyT_south_island_day_26 = 38, //South Island daytime
skyT_south_island_evening_27 = 39, //South Island in the evening
skyT_south_island_night_28 = 40, //South Island at night
skyT_lost_day_29 = 41, //Lost daytime
skyT_lost_evening_30 = 42, //Lost in the evening
skyT_lost_night_31 = 43, //Lost in the evening
skyT_lost_temple_day_32 = 44, //Lost temple
skyT_lost_temple_evening_33 = 45, //Lost temple
skyT_lost_temple_night_34 = 46 //Lost temple
};
Don't bother with unused sky, chose from picture below:
[CLICK PICTURE TO ENLARGE IT]
http://forum.ragezone.com/attachment...1&d=1297370614
SKY NO.21 is broken in PT, it take parameters from SKY NO.20... so use 21.
SKY 25 and 40 look exactly the same but sky = 40 have more lighting casted on field.
SKY 5 and 32 are exactly the same.
Files from this tutorial can be downloaded here:
Multiupload.com - upload your files to multiple file hosting sites!
Inside you will find:
- writeField.dev project with added new_field
- 3DS MAX file, checker.bmp, new_field.ASE, new_field.smd
LL Ship
Watch video first (new field from LL converted to PT and added with writeField function):
http://www.youtube.com/watch?v=Adsis4uW1rM
Here is what I add to writeGlobalField.c to get this effect:
Under village-2 functions:
Code:
fieldLoad(village_2, new_field, 4016, -17481, 120); <--- load "ship"
teleport(village_2, 3978, -17471, 120, 64, 32, 100, 1); <--- teleport type near ship
teleportTo(village_2, new_field, 4260, -17559, 194); <--- location on ship
sound(village_2, 3848, 128, -17485, 100, sndT_ship_swaing_l); <--- sound of ship swing, added to Ricarten (village-2) to hear ship swing from outside new_field map.
and new_field:
Code:
//----- (new field) ------------------------------------------------------------
field(new_field, "new_field\\new_field.ASE", "new_field");
animation(new_field, "new_field\\lamp.ASE", 0); <--- animation of lamp you see in video, its on same .max file, you export it as animation, .ASE (Transform Animation Keys)
fieldCmd(new_field, 4237, -17758);
environment(new_field, fldT_ruins, skyT_lost_day_29, skyT_lost_evening_30, skyT_lost_night_31, bgmT_dungeon_gloomy_heart, 0, 1, 1);
teleport(new_field, 4282, -16438, 294, 64, 32, 100, 1); <--- this in "tent" on ship, it will take us outside of ship
teleportTo(new_field, village_2, 3973, -18279, 122); <--- location outside map
sound(new_field, 4265, 300, -17199, 1000, sndT_ship_swaing_l); <--- see video, its on center of ship (sound is bit different it take 3DS coordinates in order X Z(height) Y), range is 1000 (whole ship)
totalFieldsNumber = 45; /* add 1 for new field */
ship_nest_part.tga have alpha channel so you see nest barrier with hole inside ;)
Files from tutorial update are available here:
http://forum.ragezone.com/attachment...1&d=1297795713
http://forum.ragezone.com/attachment...1&d=1297795713
Recommended: 3DS 2009 to open file (nif importer plugin is for version 2009 too) but any other version should work too.
I think thats all for basic functions explanation... next we will talk about lights, material types and fields types.
Visit http://forum.ragezone.com/f399/write...0/#post6151545 for source code updates.
.
3 Attachment(s)
Re: [Tutorial to writeField function]How to add new field (adding and editing PT fiel
Added sky types and I need post to upload picture ;)
I know I promised that I will make this tutorial bigger but because I was working on code I had no time.
When everything will be stable I will finish this guide, for now enjoy your SKY PALETTE.
:thumbup:
Re: [Tutorial to writeField function]How to add new field (adding and editing PT fiel
That is really freaky to look at. XD
Thanks matey. :wink:
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
UPDATE
http://forum.ragezone.com/attachment...hippo_bump.jpg
YT video added, more information about using functions, some extra informations, files from tutorial added.
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
Damn 0o Vormav this is some sick shit,
Im gonna try your guide somewhere this week,
Thanks for the share, and liked for the tut (damn)
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
This is very nice adds, although you may need have same modifications for clients and distribute them. :)
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
Geez, my dream is to know C++ enough to convert my emu to c++. Its not just about C++ better or not, I mean, saying you coded it in c++ will give more credits, you know what I mean? C++ is a "difficult" language :P
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
C++ is so many times easier than C# or Java. (IMHO)
It's actually, probably, the easiest programming language to learn. Simply because it is so well documented, for free, all across the net.
There are examples of just about anything you could possibly imagine wanting to do. XD
Anyway. This is (I believe) still pure C. Using no ++ extensions to the ISO96/98 language.
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
@telatoro
All modifications that you are making to client and server is calling function from dll =P
@SheenBR
I don't think C# is that much easier, beside that making an emulator is not an easy task but making it C++ would give you more references from the internet.
This is pure C... adding something that is in C++ will not give me anything back but because C/C++ have some nice ISO standards I can move C to C++ anytime.
@bobsobol
Yup C is probably best start because it have ISO... as long ppl adapt it.
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
"adapt" I take it is a typo (Easy one to make) from "adopt".
If people "adapt" it, then it becomes no standard at all.
If people "adopt" it, (choose to use it in preference to manufacturer specific extensions) then the standard remains stable, and will continue to be "portable" from one compiler and platform to another.
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
I managed to add the boat, teleports to level restriction and everything else using OllyDbg.
Today I will make a guide for those who do not want to use C + +.
Sorry for my english, I'm using google translator, I'm from Uruguay ...
Bye
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
It's actually C, but it will compile with C++ because C++ is backwards compatible with C.
You can also set your location in your RZ profile. Saves some explaining. :thumbup:
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
Its always nice to see alternative hex/asm version. If you have any problems than I might be able to help you, I think I still remember what was doing what ;)
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
Using asm, i only can see the new field after enter and back to ric.
The new field not be load in a first time
Re: [Tutorial to writeGlobalField function]How to add new field and edit existing one
Than something might be wrong with your asm interpretation of
fieldLoad(village_2, new_field, 4016, -17481, 120);
this need to be done in Ricarten (village-2) asm space.