[Tutorial to writeGlobalField function]How to add new field and edit existing one

Joined
Jan 28, 2009
Messages
1,320
Reaction score
616
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.

Vormav - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums


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\"

Vormav - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums


- 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
Vormav - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums


- 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:

Vormav - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums


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/writefield-function-adding-editing-pt-725350/#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 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/writefield-function-adding-editing-pt-725350/#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):

Vormav - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums



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]
Vormav - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums



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:


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):



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); [COLOR="Red"]<--- load "ship"[/COLOR]
     teleport(village_2, 3978, -17471, 120, 64, 32, 100, 1); [COLOR="Red"]<--- teleport type near ship[/COLOR]
   teleportTo(village_2, new_field, 4260, -17559, 194); [COLOR="Red"]<--- location on ship[/COLOR]
        sound(village_2, 3848, 128, -17485, 100, sndT_ship_swaing_l); [COLOR="Red"]<--- sound of ship swing, added to Ricarten (village-2) to hear ship swing from outside new_field map.[/COLOR]

and new_field:
Code:
//----- (new field) ------------------------------------------------------------
        field(new_field, "new_field\\new_field.ASE", "new_field");
    animation(new_field, "new_field\\lamp.ASE", 0);[COLOR="Red"] <--- animation of lamp you see in video, its on same .max file, you export it as animation, .ASE (Transform Animation Keys)[/COLOR]
     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); [COLOR="Red"]<--- this in "tent" on ship, it will take us outside of ship[/COLOR]
   teleportTo(new_field, village_2, 3973, -18279, 122); [COLOR="Red"]<--- location outside map[/COLOR]
        sound(new_field, 4265, 300, -17199, 1000, sndT_ship_swaing_l); [COLOR="Red"]<--- 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)[/COLOR]      
                
            
  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.php?attachmentid=85463&stc=1&d=1297795713
http://forum.ragezone.com/attachment.php?attachmentid=85464&stc=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/writefield-function-adding-editing-pt-725350/#post6151545 for source code updates.

.
 

Attachments

  • ASE_export_options - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums
    ASE_export_options.webp
    16.5 KB · Views: 1,605
  • NewFieldCoordinates - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums
    NewFieldCoordinates.webp
    119.3 KB · Views: 1,004
  • new_field - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums
    new_field.webp
    119.4 KB · Views: 1,584
  • checker.bmp
    checker.bmp
    192.1 KB · Views: 1,517
  • 3DS_new_field_01 - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums
    3DS_new_field_01.webp
    76.2 KB · Views: 1,595
Last edited:
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:
 

Attachments

Last edited:
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:
 
Damn 0o Vormav this is some sick ****,

Im gonna try your guide somewhere this week,


Thanks for the share, and liked for the tut (damn)
 
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.
 
@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.
 
"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.

So long as you avoid extensions like "WinForms" the same remains true of the C# open standard Microsoft submitted and had accepted by the industry standards authorities. Unlike their XML document formats (to rival the "Open Document Format" submitted by IBM, Lotus and Sun et el?) for Office Productivity documents. Even Microsoft Office does not comply to the "Standard" which they finally got through as a recognised industry standard.

So if you follow the "standard" documentation on how to read those files, you get nothing from MS Office files but garbage... but if you follow the earlier "Open Document" standard documentation, you can read ODT, ODS, ODP data from any application, including MS Office. :$:

I conclude... they try. Bless them. Microsoft is not *evil*, merely human.
 
Last edited:
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
 
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:
 
When I try to compile the codes (f9) I get an error. This one: 19 C:\Program Files (x86)\PPT-Server\writeField\writeField.cpp expected constructor, destructor, or type conversion before '(' token
Pown - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums Pown2 - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums Pown3 - [Tutorial to writeGlobalField function]How to add new field and edit existing one - RaGEZONE Forums

Mabye I should also note that when I teleport to a field more than Ice mine, I just teleport to grey space. *I guess this is because I didn't add the OLD_files yet cause i don't know how exactly) also, I used the normal writefield function, not the global one. I will also try what will happen if i use the global one. I think it doesnt make much difference.
 
Last edited:
this one got old_versions I believe, it goes up to field 62 ;). Can't get the old_files to work though. They work perfectly on client, but my server crashes :(. I don't need to do anything to the gameserver/field folder?
 
Last edited:
I'm sorry to ask this many questions, but I just can't seem to make it work.
When i open writeserverfield, which one do i need to compile writeServerField.cpp or .h? .cpp gives an error:
C:\Program Files (x86)\PPT-Server\writeField\writeServerField\/..\writeField.cpp:1012: error: invalid conversion from `BYTE*' to `char*'

C:\Program Files (x86)\PPT-Server\writeField\writeServerField\/..\writeField.cpp:1012: error: initializing argument 1 of `int environment(char*, int, int, int, int, int, int, int, int)'

Uitvoering voltooid (translation: Run finished)

Or is this correct and do i just need to ignore the errors?
 
Back