Several Questions Pertaining to Development

Content and general development discussion, including maps, quests, and server code from the development team.
lost_soul
Peon
Peon
Posts: 30
Joined: 03 Dec 2007, 23:10

Several Questions Pertaining to Development

Post by lost_soul » 14 Mar 2008, 21:30

I have several general questions I thought I'd throw out there.

First I'd like to say that I have been following this project for over a year or so, and I have always thought that it has great potential, and it seems as though the new server has been the main issue that has held back a bloom of development in content. In browsing, and building the new client/server, it seems as though things have come along quite nicely, and appear to be 85% + done, and I am looking forward to the time when it is implemented.

My Questions:
1.)(Pardon me if this is redundant)
Why was Lua chosen as the scripting language as opposed to say, Python? Is it because Lua has such a small footprint and is embeddable?
I would like to assist in some of the Lua scripting, however I am not familiar with it, however, I am in the process of learning it.

2.) Would it be possible to animate the NPC's, such that they move within certain boundaries in a section of a map? Or do you believe that this would be an unnecessary hassle, without much contribution to game-play enhancement?
I am aware that the NPC's have different graphics, and they don't contain the different perspectives that character graphics do, while the move. Which brings up another point, would it be possible to use the same graphics for the NPC's, so that all the character models are uniform? As of now, the NPC's look radically different than the players.
From what I have seen in the code, it appears that the NPC's are called from a look-up table and placed at whatever grid coordinates you supply. You could work with this method, in order to animate the NPC's, however the tables would be extremely large, 8 times larger or so, (taking into account there are ~8 different graphics for moving about, and that each one was called for whichever direction the NPC was moving in, this would be a work around and not ideal. Or could the same function's be called for drawing the characters, and be applied to the NPC's?


Just a few things I have had mulling around in my head, just wanted to get some feedback and see what anyone has to say in regards

Cheers,
Lost
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Re: Several Questions Pertaining to Development

Post by Crush » 14 Mar 2008, 23:04

lost_soul wrote: Why was Lua chosen as the scripting language as opposed to say, Python? Is it because Lua has such a small footprint and is embeddable?
That and the fact that LUA is extremely performant in comparison to other scripting languages. That's why LUA is a very widely used scripting language in professional game development.
2.) Would it be possible to animate the NPC's, such that they move within certain boundaries in a section of a map? Or do you believe that this would be an unnecessary hassle, without much contribution to game-play enhancement?
[...]
Or could the same function's be called for drawing the characters, and be applied to the NPC's?
NPCs are already using the same animation system player characters and monsters are using. The animation file used by the NPCs just only defines one frame.

Writing a server-sided AI for NPCs wouldn't be very hard either.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
lost_soul
Peon
Peon
Posts: 30
Joined: 03 Dec 2007, 23:10

Re: Several Questions Pertaining to Development

Post by lost_soul » 14 Mar 2008, 23:25

Oh, well thanks for the reply and the info! I will have to look back over, and see what ideas I can put together.

Do you think it would be a good idea to use a uniform character template? Or do you believe that the current NPC graphics are sufficient?
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Re: Several Questions Pertaining to Development

Post by Crush » 15 Mar 2008, 01:12

No, I don't consider the current NPC graphics sufficient. They look completely different stylistical and thus look like they were ripped from a dozend of different games. But this is more an aesthetical than a technical problem.

Limiting NPC graphics to the graphics used by player characters would limit the flexibility of the NPC system a lot. How do you want to display the treasure chest or the note "NPCs" when having to use the player spriteset for it?
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
lost_soul
Peon
Peon
Posts: 30
Joined: 03 Dec 2007, 23:10

Re: Several Questions Pertaining to Development

Post by lost_soul » 15 Mar 2008, 03:34

Well, the treasure chest and note NPC graphic sets wouldn't be touched, only the ones used for the NPC's based upon living beings. I am not sure how they are currently setup, but I wouldn't think that would be a problem would it?
edit:: I see what you are referring too now, after looking at the npcs.png, I noticed they are all put together...for an animated NPC you would have to have a graphics/sprites/npc1.png, npc2.png, npc3.png...etc, with their .xml mates....the set would have to be setup similar to that of player_male_base.png or player_female_base.png so that it would annimate properly. :: edit

The only problem I forsee, is that it seems the NPC's are only activated when the map refreshes?? I'm not clear on how that works....I assume that if no one is on that map, the NPC wouldn't be activated.

I figured the NPC could roam about, with a loop function, and would be interrupted when either: A.) the character moves within a certain distance (the NPC would stop moving, wait for the player to begin interaction, if it doesn't occur within a set period it resumes it's random walk. or B.) the player right clicks on the NPC to begin interaction, at which point the NPC stops movement.

The NPC's wouldn't have labels, which makes it great! (except the static ones) It would force inter-player interaction, since NPC's would move about and would look similar to normal characters.

I couldn't locate the function that is called when a player right clicks on an NPC, or where the server listens for it, do you know what file it is in?

cheers,
lost
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Re: Several Questions Pertaining to Development

Post by Crush » 15 Mar 2008, 09:32

lost_soul wrote:I figured the NPC could roam about, with a loop function, and would be interrupted when either: A.) the character moves within a certain distance (the NPC would stop moving, wait for the player to begin interaction, if it doesn't occur within a set period it resumes it's random walk. or B.) the player right clicks on the NPC to begin interaction, at which point the NPC stops movement.
My idea would be to leave as much NPC behavior as possible to the scripting engine for maximum flexibility.
The NPC's wouldn't have labels, which makes it great! (except the static ones) It would force inter-player interaction, since NPC's would move about and would look similar to normal characters.
This sounds like you want to make NPCs as similar as possible to player characters so that players mistake them for other player characters. I think this is not a good idea. No matter how similar you make them visually the way players interact with them is still fundamentally different.

And thus players should be able to distinguish players and non-players easily.
I couldn't locate the function that is called when a player right clicks on an NPC, or where the server listens for it, do you know what file it is in?
*taking a deep breath*

Client:
src/gui/popupmenu.cpp line 90 defines a link whichs action is catched in
src/gui/popupmenu.cpp line 124 which calls the member function NPC::talk() which is defined in
src/npc.cpp line 60 which invokes the sending of a network message type "PGMSG_NPC_TALK" in
src/net/gameserver/player.cpp line 112 which is sent to the server by
src/net/connection.cpp line 90

This message now travels through a series of tubes formally known as "The Internet" to the gameserver which catches the packet and stores it in an event queue which is processed in

src/net/connectionhandler.cpp line 76 which hands the message to
src/gameserver/gamehandler.cpp line 147 which then realizes that it is NPC related and calls NPC::prompt() which is defined in
src/npc.cpp line 40 where control is handed to the scripting engine.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
lost_soul
Peon
Peon
Posts: 30
Joined: 03 Dec 2007, 23:10

Re: Several Questions Pertaining to Development

Post by lost_soul » 18 Mar 2008, 01:17

I appreciate the in-depth response of where the code was in the source
Crush wrote: This sounds like you want to make NPCs as similar as possible to player characters so that players mistake them for other player characters. I think this is not a good idea. No matter how similar you make them visually the way players interact with them is still fundamentally different.

And thus players should be able to distinguish players and non-players easily.
Well, it's not something that I would necissarily want to do, but, if the NPC's did use the player sprite graphics, so their bodies had the same dimensions then it would be hard to distinquish between them. I thought about the NPC, moving around, and stopping and prompting the player when they get close, but I think that would be annoying and would buggy, especially if you aren't trying to talk to the NPC! The NPC could have a tag below it's name to identify it, but if the NPC was moving around, I dont know if it would move with it??? If so, than that wouldn't be a problem.
Crush wrote:This message now travels through a series of tubes formally known as "The Internet"...
haha, yes, "I have used the google" to learn about how "the internets" work....it is exactly like a series of tubes :lol:

------------one more quick question----------
--Where will the functional LUA scripts reside??
--Will they remain in tmwserv/trunk/data/ like where the current, test.lua script is, and remain server side??
--while trying to find the answer on my own, I noticed, that in the /tmw/trunk/data/maps/new_1-1.tmx....which is client side, i noticed that in that --file there were embedded NPC's as well as a pointer to the
--test.lua script
new_1_1.tmx wrote: ...
<object name="Other npcs" type="SCRIPT" x="0" y="0" width="0" height="0">
<properties>
<property name="FILENAME">
test.lua
...
So I guess I just need clarification, as to where to put the LUA scripts, and how to get them functional in order to test them.

Your assistance is much appreciated,
cheers,
Lost
User avatar
Jaxad0127
TMW Adviser
TMW Adviser
Posts: 4209
Joined: 01 Nov 2007, 18:35
Location: Internet

Re: Several Questions Pertaining to Development

Post by Jaxad0127 » 18 Mar 2008, 02:48

To tell the difference between NPCs and players, we could give the NPCs a different name color. And they could pop up a 'chat balloon' (just an ellipsis) when you get close to them.
Image
User avatar
ElvenProgrammer
TMW Adviser
TMW Adviser
Posts: 2526
Joined: 13 Apr 2004, 20:11
Location: Italy
Contact:

Re: Several Questions Pertaining to Development

Post by ElvenProgrammer » 18 Mar 2008, 11:50

lost_soul wrote:So I guess I just need clarification, as to where to put the LUA scripts, and how to get them functional in order to test them.
You can do both. Map specific NPCs should be embedded in the map file, while generic scripts (i.e banker script) could be stored in a data/scripts/banker.lua file and included in all the maps that need it.

The fact that the client map files contains the script is just the result of the fact that the client svn is the only repository of map files, in the fiture we will probably differentiate client and server maps.
lost_soul
Peon
Peon
Posts: 30
Joined: 03 Dec 2007, 23:10

Re: Several Questions Pertaining to Development

Post by lost_soul » 18 Mar 2008, 15:25

Yeah, I was a bit confused on the client side and server side data being inter-mixed with each other. I was ultimately able to figure out where to put the script's and map files on my machine to test the scripts on a local server.....although I am still not sure what side was handling it...the server or client side?? heh....all i really wanted to do was to test out some scripts, and I was able to do so....so I am happy about that.

I noticed some changes in the test.lua, that crush had made, and made a few changes here and there to try out animating the NPC's. I have absolutely no clue how the identifier number's for the NPC's are only valid for values in 100. I understand that the monsters and items have id's defined in monsters.xml and items.xml, which point to their .xml files defining their attributes.
The NPC's seem to only have valid id's within 100, which only point to npcs.png, and npc.xml. Since i don't know how to create unique #'s, or create an .xml file for each npc, I made a new npcs.png, and npc.xml in order to see the animated NPC.
Basically I just took male_base_character.png and slapped some jeans and a shirt on him, and made him the NPC.....but all the NPC's are him...but it illustrated the movement well enough. I noticed that you do plan on incorporating NPC's as items, they have a place-holder id of -100.

I'll attatch what I did, in case you want to see it yourselves, the replacement .png and .xml, and test script.

my appologies in advance, i couldnt attach the files below .lua .xml, i suppose in the future i could .tar.gz them
----------------------the file test.lua -----------------------------
--------------
-- Map code --
--------------


atinit(function()
create_npc(108, 50 * 32 + 16, 19 * 32 + 16, npc1_talk, nil)
create_npc(110, 51 * 32 + 16, 25 * 32 + 16, npc4_talk, nil)
create_npc(100, 40 * 32 + 16, 18 * 32 + 16, npc5_talk, npc_walker)
create_npc(110, 58 * 32 + 16, 15 * 32 + 16, npc6_talk, nil)
create_npc(100, 50 * 32 + 16, 20 * 32 + 16, npc_tweakster_talk, npc_walker)
end)
--This is the NPC #1 function
--
function npc1_talk(npc, ch)
do_message(npc, ch, "Hello! I am testing .")
do_message(npc, ch, "This message is just here for testing connections.")
do_message(npc, ch, "What do you want?")
local v = do_choice(npc, ch, "Guns! Lots of guns!",
"A Christmas party!",
"To buy.",
"To sell.",
"To make a donation.")
if v == 1 then
do_message(npc, ch, "Sorry, this is a heroic-fantasy game, I do not have any guns.")
elseif v == 2 then
local n1, n2 = tmw.chr_inv_count(ch, 524, 511)
if n1 == 0 or n2 ~= 0 then
do_message(npc, ch, "Yeah right...")
else
do_message(npc, ch, "I can't help you with the party. But I see you have a fancy hat. I could change it into Santa's hat. Not much of a party, but it would get you going.")
v = do_choice(npc, ch, "Please do.", "No way! Fancy hats are classier.")
if v == 1 then
tmw.chr_inv_change(ch, 524, -1, 511, 1)
end
end
elseif v == 3 then
tmw.npc_trade(npc, ch, false, { {533, 10, 20}, {535, 10, 30}, {537, 10, 50} })
elseif v == 4 then
tmw.npc_trade(npc, ch, true, { {511, 10, 200}, {524, 10, 300}, {508, 10, 500}, {537, 10, 25} })
elseif v == 5 then
if tmw.chr_money_change(ch, -100) then
do_message(npc, ch, string.format("Thank you for you patronage! You are left with %d gil.", tmw.chr_money(ch)))
local g = tonumber(get_quest_var(npc, ch, "001_donation"))
if not g then g = 0 end
g = g + 100
tmw.chr_set_quest(ch, "001_donation", g)
do_message(npc, ch, string.format("As of today, you have donated %d gil.", g))
else
do_message(npc, ch, "I would feel bad taking money from someone that poor.")
end
end
end
--This is the NPC #4 fucntion
function npc4_talk(npc, ch)
do_message(npc, ch, "Where do you want to go?")
local v = do_choice(npc, ch, "Map 1", "Map 3")
if v >= 1 and v <= 2 then
do_message(npc, ch, "Are you really sure?")
local w = do_choice(npc, ch, "Yes, I am.", "I still have a few things to do around here.")
if w == 1 then
if v == 1 then
tmw.chr_warp(ch, nil, 60 * 32, 50 * 32)
else
tmw.chr_warp(ch, 3, 25 * 32, 25 * 32)
end
end
end
end
--This is the NPC #5 test function
function npc5_talk(npc, ch)
do_message(npc, ch, "I am the Maggot Man! Do you want me to spawn some maggots?")
local answer = do_choice(npc, ch, "Yes", "No");
if answer == 1 then
local x = tmw.posX(npc)
local y = tmw.posY(npc)
tmw.monster_create(1002, x + 32, y + 32)
tmw.monster_create(1002, x - 32, y + 32)
tmw.monster_create(1002, x + 32, y - 32)
tmw.monster_create(1002, x - 32, y - 32)
end
end
--This is Tweakster, the spastic test NPC
function npc_tweakster_talk(npc, ch)
do_message(npc, ch, "EEEEEEEEEKK!!")
local x = tmw.posX(npc)
local y = tmw.posY(npc)
tmw.monster_create(1002, x + 2 , y + 2 )
tmw.monster_create(1002, x + 4 , y + 4 )
tmw.monster_create(1002, x + 8 , y + 8 )
tmw.monster_create(1002, x + 16 , y + 16 )
tmw.monster_create(1002, x + 32 , y + 32 )
tmw.monster_create(1002, x - 2 , y - 2 )
tmw.monster_create(1002, x - 4 , y - 4 )
tmw.monster_create(1002, x - 8 , y - 8 )
tmw.monster_create(1002, x - 16 , y - 16 )
tmw.monster_create(1002, x - 32 , y - 32 )
tmw.monster_create(1002, x + 2 , y - 2 )
tmw.monster_create(1002, x + 4 , y - 4 )
tmw.monster_create(1002, x + 8 , y - 8 )
tmw.monster_create(1002, x + 16 , y - 16 )
tmw.monster_create(1002, x + 32 , y - 32 )
tmw.monster_create(1002, x - 2 , y + 2 )
tmw.monster_create(1002, x - 4 , y + 4 )
tmw.monster_create(1002, x - 8 , y + 8 )
tmw.monster_create(1002, x - 16 , y + 16 )
tmw.monster_create(1002, x - 32 , y + 32 )
end

--Function to make a NPC randomly move
function npc_walker(npc)
--local defines for function
local initial_timer = 0
local initial_timer = initial_timer + 1
local random_timer = math.random(-1, 1)
--when random_timer number reached, NPC moves random distance
--as of now, there is a 50% chance each tick that the NPC will move
if initial_timer == random_timer then
local x = math.random(-16, 16) + tmw.posX(npc)
local y = math.random(-16, 16) + tmw.posY(npc)
tmw.being_walk(npc, x, y, 500)
else initial_timer = 1
npc_walker(npc)
end
end



--TODO below function is not finished???
function npc6_talk(npc, ch)
local guard_position = 1
if guard_position == 1 then
tmw.being_walk(npc, 61 * 32 + 16, 15 * 32 + 16, 400)
guard_position = 2
else
tmw.being_walk(npc, 55 * 32 + 16, 15 * 32 + 16, 400)
guard_position = 1
end
end
--------------------------------------------------THE XML FILE npc.xml ---------------------------------------------
<?xml version="1.0"?>
<sprite name="npc" action="stand">

<imageset name="base" src="graphics/sprites/npcs.png" width="64" height="64"/>

<action name="stand" imageset="base">
<animation direction="down">
<frame index="0"/>
</animation>
<animation direction="left">
<frame index="18"/>
</animation>
<animation direction="up">
<frame index="36"/>
</animation>
<animation direction="right">
<frame index="54"/>
</animation>
</action>

<action name="walk" imageset="base">
<animation direction="down">
<sequence start="1" end="6" delay="75"/>
</animation>
<animation direction="left">
<sequence start="19" end="24" delay="75"/>
</animation>
<animation direction="up">
<sequence start="37" end="42" delay="75"/>
</animation>
<animation direction="right">
<sequence start="55" end="60" delay="75"/>
</animation>
</action>

<action name="sit" imageset="base">
<animation direction="down">
<frame index="7"/>
</animation>
<animation direction="left">
<frame index="25"/>
</animation>
<animation direction="up">
<frame index="43"/>
</animation>
<animation direction="right">
<frame index="61"/>
</animation>
</action>

<action name="dead" imageset="base">
<animation direction="down">
<frame index="8"/>
</animation>
<animation direction="left">
<frame index="26"/>
</animation>
<animation direction="up">
<frame index="44"/>
</animation>
<animation direction="right">
<frame index="62"/>
</animation>
</action>

<action name="attack" imageset="base">
<animation direction="down">
<sequence start="9" end="12" delay="75"/>
<end/>
</animation>
<animation direction="left">
<sequence start="27" end="30" delay="75"/>
<end/>
</animation>
<animation direction="up">
<sequence start="45" end="48" delay="75"/>
<end/>
</animation>
<animation direction="right">
<sequence start="63" end="66" delay="75"/>
<end/>
</animation>
</action>

<action name="attack_bow" imageset="base">
<animation direction="down">
<sequence start="13" end="17" delay="75"/>
<end/>
</animation>
<animation direction="left">
<sequence start="31" end="35" delay="75"/>
<end/>
</animation>
<animation direction="up">
<sequence start="49" end="53" delay="75"/>
<end/>
</animation>
<animation direction="right">
<sequence start="67" end="71" delay="75"/>
<end/>
</animation>
</action>

</sprite>
Attachments
npcs.png
npcs.png (71.67 KiB) Viewed 2073 times
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Re: Several Questions Pertaining to Development

Post by Crush » 18 Mar 2008, 16:10

The npc IDs starting with 100 is, like the monster IDs starting with 1000, a relict from eAthena. I think that I will change it soon.


The different NPC graphics appear because they are called as variants of the same spriteset. Note the following line in npc.xml:

Code: Select all

<sprite variants="56" variant_offset="1">
This means that the spriteset the file refers to got 56 different variants of the sprite which are one frame apart and that the animation can be applied to all of them. When the engine needs NPC number 142, for example, it subtracts 100 to get 42 and then requests variant 42 from npc.xml. So it adds 42 * 1 (1= variant_offset) to all frame numbers in the xml declaration and creates an animation out of it.


You misunderstood the meaning of the -100 sprite in items.xml. This is not for NPCs but for player characters. The base sprite of the player character got an item ID so that the server can set the player base sprite with the same mechanism which is used to set the other subsprites like hair or equipment. This will become useful when we introduce different player character sprites.

Code: Select all

function npc_walker(npc)
  --local defines for function
  local initial_timer = 0
  local initial_timer = initial_timer + 1
  local random_timer = math.random(-1, 1)
  --when random_timer number reached, NPC moves random distance
  --as of now, there is a 50% chance each tick that the NPC will move 
  if initial_timer == random_timer then
    local x = math.random(-16, 16) + tmw.posX(npc)
    local y = math.random(-16, 16) + tmw.posY(npc)
    tmw.being_walk(npc, x, y, 500)
  else initial_timer = 1
    npc_walker(npc)
   end
end
Declaring the timer as a local variable inside the function won't work. It will be reinitialized whenever the function is called. When you want to save the state of a variable during function calls you have to declare the variable outside of the function.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
lost_soul
Peon
Peon
Posts: 30
Joined: 03 Dec 2007, 23:10

Re: Several Questions Pertaining to Development

Post by lost_soul » 18 Mar 2008, 21:59

Thanks once again for the reply and clarifications Crush,

I got the impression that the id #'s were reminants of the eathena server.

I'm still trying to understand how the .xml files work exactly. I believe the game engine is setup such that you can define attributes in .xml files which point to other .xml files.....
Crush wrote: This means that the spriteset the file refers to got 56 different variants of the sprite which are one frame apart and that the animation can be applied to all of them. When the engine needs NPC number 142, for example, it subtracts 100 to get 42 and then requests variant 42 from npc.xml. So it adds 42 * 1 (1= variant_offset) to all frame numbers in the xml declaration and creates an animation out of it.
the .xml refered to: wrote: <sprite variants="56" variant_offset="1">
<imageset name="base" src="graphics/sprites/npcs.png" width="50" height="80" />

<action name="stand" imageset="base">
<animation direction="default">
<frame index="0" />
</animation>
</action>
</sprite>
soo...the variant number refers to the number of variations in the .png file? and the offset determines the number of images to skip to get to the next variation? Or do the variation and offset apply to the .xml file??---so that you can define different variations?

I imagine my question isn't quite clear,(I am confusing myself asking it) SO let me just say what I am trying to do, and I believe it is possible, and perhaps, a concrete example will help me better comprehend.
I want to add animations to the NPC's, and you have it working and programmed, I just dont know how to link the graphics up properly. I don't believe all the NPC sprite graphics have to be in a single .png file, and can be called in the npc.xml file to point to other .xml, and other .png files correct?

While writing this I was trying to figure this out, looking at the wiki, and the .xml files...but I can't figure it out 100%, and I don't think the wiki is up to date.
Do you think you could provide some more pointers in how to achieve this goal?

Thanks,
Lost
User avatar
Jaxad0127
TMW Adviser
TMW Adviser
Posts: 4209
Joined: 01 Nov 2007, 18:35
Location: Internet

Re: Several Questions Pertaining to Development

Post by Jaxad0127 » 18 Mar 2008, 22:11

This is the article you need. And it is up to date.
Image
lost_soul
Peon
Peon
Posts: 30
Joined: 03 Dec 2007, 23:10

Re: Several Questions Pertaining to Development

Post by lost_soul » 24 Mar 2008, 06:42

jaxad
I appreciate your reply to my question, and that link that you posted was the link that I was looking at previously. However, that article, and your answer don't help resolve the issue that I was having.

I let this thread sit for a while in hopes someone else may answer it more thoroughly, but perhaps I wasn't as clear as I should have been, in fact I probably made no sense, so I will try to rephrase.

What I want to do is animate the NPC sprites. Unfortunately, not all NPC's are character based, nor are they all the same size. For instance, the treasure chest is treated as an NPC,santa, the wise men, spock...etc...you get the point, any dialog that you can initiate with any object in the game is treated as an NPC through the scripts. For instance I created some additional pixel art for the treasure chest, showing it open(the perspective is slightly off to have it open the way I wanted it to, but that is besides the point). I understand the standards which are outlined in the leading example from http://wiki.themanaworld.org/index.php/Animations
Unfortunately, that doesn't help me resolve the problem. The aforementioned article does touch base on similiar issues I have brought up, however they are only "proposals", hence, why i said I wasn't sure if the article was up-todate. I don't know if the proposals are implemented, more specifically.
"Defining an empty imageset (without src attribute) will make the engine require this imageset to be passed as a parameter whenever the spriteset is referenced."
or
"Since we're currently not naming sprites and defining each in its own file, the following variations on this approach could be implemented:

Since inheritance

Ability to extend one spriteset from another, while overriding imagesets and possibly also adding new ones and redefining specific animations:

<sprite extends="other-sprite-file.xml">
<imageset name="base" ... />
</sprite>

Including other spritesets

Mentioned by Matt, we could have a generic import/include element. This would even allow you to combine several spritesets together. Below the assumption is that you can only define an imageset once while animations can be redefined (actually the same as with the inheritance approach above). This prevents us from loading imagesets unnecessarily and allows us to verify the validity of animation definitions as we encounter them.

<sprite>
<imageset name="base" .../>
<include file="other-sprite-file.xml"/>
</sprite>


The currenct state of the npc.xml file is:
<sprite variants="56" variant_offset="1">
<imageset name="base" src="graphics/sprites/npcs.png" width="50" height="80" />

<action name="stand" imageset="base">
<animation direction="default">
<frame index="0" />
</animation>
</action>
</sprite>,

so, from my understanding, when an NPC is called from a lua script, they have a base number of 100, then you add whatever number the NPC graphic for the sprite you want is, the .npc.xml file defines 56 variants. so it would be a number between 100 and 156. Each NPC is 1 frame apart, starting at index 0,0.

Now, from what is propososed in the article is that you can call other .xml files which define specific character traits and animations, and call specific .png graphics for each character etc etc etc....this would be great!! but I dont know if it is implemented in the engine.

what I could do, and did do....to get around this conundrum....which IS NOT AN IDEAL SOLUTION, only a workaround with the knowledge I have........I resized all the NPC's to 64x64 (so that I could use the player_base sprite graphics without modification) unfortunatley not all graphics fit in the 64x64 dimension, nor would I want them to be subject to constrains...since any interactive object is an NPC( what if you wanted a 64x120 tree that dropped leaves??...that wouldnt work out....)
so i made a 1280x1280 npcs.png mastersheet for all the npcs which could accomodate all the current npcs, and any animations they would need, plus room for growth. However this is a rediculous size and it really seems quite silly to me, but I really felt like getting my stuff working, so needless to say I spent the time doing it. So I could then just modify the current npc.xml, redefining the variant_offset and adding in the generic palyer_base.xml animation paramters, etc....

So, I guess I would like to know....if the game engine in a current state, such that I can define specific npc behaviours in their own .xml and use their own .png files instead of just using one .xml and one .png for all the npcs??

sorry for the length,
lost
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: 25 Aug 2005, 17:08
Location: Germany

Re: Several Questions Pertaining to Development

Post by Crush » 24 Mar 2008, 18:15

lost_soul wrote:So, I guess I would like to know....if the game engine in a current state, such that I can define specific npc behaviours in their own .xml and use their own .png files instead of just using one .xml and one .png for all the npcs??
This is not yet possible but it would be very easy to make it possible. I would like to do this soon, but I need some content for testing. When you want to create an animated NPC you should give it its own animation file and png file. Then I finally got something I can use for testing.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
Post Reply