////////////////////////////////////////////////////////////////////////////////
// GS2Emu Beta 4 GS1 NPC-Server                                               //
////////////////////////////////////////////////////////////////////////////////

Oh neat.

//////////////////////////////////////////////////////////////////////
// Super simple idiot-proof setup instructions for existing servers //
//////////////////////////////////////////////////////////////////////

Add the following flags to your serveroptions.txt:
	serverside = true
	generation = classic

Your server will now be running the npc-server and in classic (2.x/3.x) mode.

///////////////////////////////////
// Generations                   //
///////////////////////////////////

Generations is a new concept for the gserver.  Since there have been some big changes over the years,
we have decided to restrict some things under a "generation" option.  This option can alter how data is stored,
how packets are sent to clients, what features are available, and so on.

There are currently four identified generations:
	original - 1.x
	classic  - 2.x/3.x
	newmain  - 4.x to 5.007
	modern   - 5.1+

The GS1 npc-server has only been tested with the "classic" generation.  It is possible that it will work with "newmain"
and "modern", but there are no guarantees at this point.  Buyer beware.

///////////////////////////////////
// Additional options            //
///////////////////////////////////

By default, the npc-server will not send signs and links to the player.  To change that, adjust the following options:
	clientsidesigns = true
	clientsidelinks = true

There is an optimization where script events will only be run on NPCs that test for the event flag.  To turn that off, enable:
	runallscriptevents = true

///////////////////////////////////
// allowedversions.txt           //
///////////////////////////////////

In order to support "generations", allowedversions.txt was altered to accept a new format.

If the file starts with "[generation-range]", then each generation has a list of accept client ranges.
Each generation contains a comma-separated list of allowed versions.  Putting a colon (:) between two versions creates a range.
See the examples already in the file.

///////////////////////////////////
// Considerations                //
///////////////////////////////////

Please review the lists below of available events, flags, functions, commands, and message codes.
Of particular note is that 'sleep' IS NOT SUPPORTED.  Script suspend/resume will require a custom syntax tree
walker to be developed and that time is better spent implementing things and fixing bugs.  Just use 'timeout'.

--------------------------------------------------------------------------------

///////////////////////////////////
// Implemented events            //
///////////////////////////////////

created
initialized
playerlogin
playerenters
playerleaves
playertouchsme
playertouchesme
playertouchsother
playertouchesother
playerlaysitem
playerchats
playerdies
compusdied
warped
washit	(hitobjects)
npcwarped
timeout
triggeraction events

//-------------------------------//
// Not implemented events        //
//-------------------------------//

playerlogout
playerendreading
playerhurt
weaponfired
firedonhorse
exploded
washit	(anything not hitobjects)
wasshot
waspelt
wasthrown
serverlistconnect

///////////////////////////////////
// Implemented flags             //
///////////////////////////////////

canspin
weaponsenabled
playerpaused
playerismale
playerisfemale
playeronhorse
playerattached
isleader
visible
issparringzone
nopkzone
isonmap
compsdead
isweapon

//-------------------------------//
// Not implemented flags         //
//-------------------------------//

carrying
carriesblackstone
carriesbush
carriessign
carriesstone
carriesvase
playerswimming
playertrial
followsplayer
peltwithblackstone
peltwithbush
peltwithnpc
peltwithsign
peltwithstone
peltwithvase
shotbybaddy
shotbyplayer

///////////////////////////////////
// Implemented variables         //
///////////////////////////////////

timevar
timevar2
allplayerscount
allplayers[]
weaponscount
playerscount
players[]
npcscount
board[]
paramscount
levelorigx
levelorigy

npcs[]
    .id
    .x
    .y
    .z
    .width
    .height
    .rupees
    .gralats
    .bombs
    .darts
    .hearts
    .glovepower
    .swordpower
    .shieldpower
    .ap
    .hurtdx
    .hurtdy
    .save[]
    .sprite
    .dir
    .timeout
npcs[] shorthand: e.g., hearts

players[]
    .id
    .x
    .y
    .z
    .rupees
    .gralats
    .bombs
    .darts
    .glovepower
    .swordpower
    .shieldpower
    .mp
    .ap
    .fullhearts
    .hearts
    .headset
    .sprite
    .dir
    .attachid
    .attachtype
players[] shorthand: e.g., playerhearts

//-------------------------------//
// Not implemented variables     //
//-------------------------------//

compuscount
compus[]
bombscount
bombs[]
arrowscount
arrows[]
itemscount
items[]
exploscount
explos[]
horsescount
horses[]
signscount
signs[]
tiles[x,y]
gravity
actionplayer
playerhurtpower
players[]
    .saysnumber
    .lastdead
    .logintime

///////////////////////////////////
// Implemented commands          //
///////////////////////////////////

addstring
addweapon
attachplayertoobj
blockagain
callnpc
canbecarried
canbepulled
canbepushed
cannotbecarried
cannotbepulled
cannotbepushed
cannotwarp
canwarp
canwarp2
deletestring
destroy
detachplayer
disableweapons
dontblock
drawoverplayer
drawovertrees
drawunderplayer
enableweapons
freezeplayer2
hide
hitobjects
hitplayer
hurt
insertstring
join
message
move
noplayeronwall
putcomp
putnewcomp
putnpc
putnpc2
removecompus
removestring
removeweapon
replacestring
say
say2
sendpm
sendrpgmessage
sendtonc
sendtorc
serverwarp
set
setani
setarray
setbeltcolor
setbody
setcharani
setchargender
setcharprop
setcoatcolor
setgender
setgif
sethead
setimg
setimgpart
setlevel
setlevel2
setplayerdir
setplayerprop
setshape
setshield
setshoecolor
setshootparams
setskincolor
setsleevecolor
setstring
setsword
shoot (sending projectiles to the client)
show
showcharacter
takeplayerhorse
tokenize
tokenize2
unfreezeplayer
unset

//-------------------------------//
// Not implemented commands      //
//-------------------------------//

addguildmember
carryobject
copyflags
copylevel
copystrings
deletelevel
explodebomb
hitcompu
hitnpc
lay
lay2
putbomb
putexplosion
putexplosion2
puthorse
removearrow
removebomb
removeexplo
removeguild
removeguildmember
removehorse
removeitem
saveinfo
savelog
savelog2
setmap
setminimap
setpm
setz
shoot (serverside processing of projectiles)
shootarrow
shootball
shootfireball
shootfireblast
shootnuke
showani
showani2
showimg
showimg2
showstats
sleep
spyfire
take
take2
takehorse
takeplayercarry
throwcarry
timershow
updateboard
updateboard2
updateterrain

///////////////////////////////////
// Implemented functions         //
///////////////////////////////////

abs(value)
arctan(value)
cos(value)
int(value)
log(value)
max(value1, value2)
min(value1, value2)
random(min, max)
sin(value)
strtofloat(string)
ascii(string)
startswith(prefix, string)
strcontains(string, substring)
strequals(string1, string2)
strlen(string)
aindexof(value, array)
arraylen(array)
indexof(substring, string)
lindexof(string, list)
sarraylen(list)
findnearestplayer(x, y)
getareanpcs(x, y, width, height)
getdir(dx, dy)
getnearestplayer(x, y)
getnearestplayers(x, y, flag)
getnpc(name)
getplayer(account)
hasweapon(name)
onmapx(level)
onmapy(level)
onwall(x, y)
onwall2(x, y, width, height)
onwater(x, y)
testnpc(x, y)
testplayer(x, y)
testsign(x, y)
vecx(dir)
vecy(dir)

//-------------------------------//
// Not implemented functions     //
//-------------------------------//

_(string)
N_(string)
base64decode(string)
base64encode(string)
findnearestplayers(x, y)
getangle(dx, dy)
getz(x, y)
imgheight(image)
imgwidth(image)
keycode(key)
keydown(key)
keydown2(keycode, ignorecase)
playersays(???)
playersays2(???)
screenx(x, y)
screeny(x, y)
testbomb(x, y)
testcompu(x, y)
testexplo(x, y)
testhorse(x, y)
testitem(x, y)
textheight(zoom, font, style)
textwidth(zoom, font, style, text)
tiletype(x, y)
worldx(x, y)
worldy(x, y)

///////////////////////////////////
// Implemented message codes     //
///////////////////////////////////

#1 | #1(index)  [Read / Write]
#2 | #2(index)  [Read / Write]
#3 | #3(index)  [Read / Write]
#5 | #5(index)  [Read / Write]
#6 | #6(index)  [Read]
#7 | #7(index)  [Read / Write]
#8 | #8(index)  [Read / Write]
#a | #a(index)  [Read]
#c | #c(index)  [Read / Write]
#g | #g(index)  [Read]
#m | #m(index)  [Read / Write]
#n | #n(index)  [Read / Write]
#N | #N(index)  [Read]
#W | #W(index)  [Read]
#w | #w(index)  [Read]
#p(index)       [Read / Write]
#t(index)       [Read / Write]
#F              [Read]
#f              [Read]
#L              [Read]
#C0 - #C4  | #C0(index) - #C4(index)   [Read / Write]
#P1 - #P30 | #P1(index) - #P30(index)  [Read / Write]
#b
#e(start_index, length, string)
#I(string_list, index)
#R(string_list)
#s(identifier)
#T(string)
#v(identifier)

//-------------------------------//
// Not implemented message codes //
//-------------------------------//

#Q(guild_name, account_name)  [Read]
#G | #G(index)                [Read]
#D | #D(filename)
#i(image) | #i(image, x, y, width, height)
#K(key_index)
#k(key_index)
