News:

SMF - Just Installed!

Main Menu

A little question about wands

Started by ImpassIve, February 23, 2012, 10:12:26 AM

Previous topic - Next topic

ImpassIve

I want to ask you about possibility of placing multiple types of wands in a single match.
"Somebody got Wand of Destruction and nobody can take him down? Don't worry, you can still found Wand of Securing and secure all his spawn points!"

But... The type of wand is stored only in a "MenuSelections" object, but not in a individual "Item" object, aren't it?
If so, theoretically, it would be hard to implement feature like this  :(

Anyway, what's about adding different sprites for different wand types? Yes, it doesn't changes gameplay anyhow (because only one type of wand can be ingame), but as I think, it would looks a bit better (correct me if I'm wrong)

It's not necessary to draw individual sprite for every wand, but what's about adding (for example) a head (crystal?) on a wand,  and later add 4 colors for it?
Here is just an example (unpack it into knights_data folder, don't forget to backup replaceable files):
http://dl.dropbox.com/u/18251705/wands.zip
(yes, I know, this sprites are ugly, but it is just an example).

So, what do you, guys, think of it?




Stephen

This is not difficult. In fact it can be done just by editing text files, with no code changes needed.

Try this: Go into the "knights_data" folder and open "menus.txt". Look for the following lines

            ["Wand of Destruction"  DungeonItem(GetMenu("num_wands"), i_wand_of_destruction) ]
            ["Wand of Open Ways"    DungeonItem(GetMenu("num_wands"), i_wand_of_open_ways)   ]
            ["Wand of Securing"     DungeonItem(GetMenu("num_wands"), i_wand_of_securing)    ]
            ["Wand of Undeath"      DungeonItem(GetMenu("num_wands"), i_wand_of_undeath)     ]


and immediately after these, add:

            ["Multiple Wands"  DungeonItem(GetMenu("num_wands"), i_wand_of_destruction)
                               DungeonItem(GetMenu("num_wands"), i_wand_of_securing) ]


This will give you an extra "Multiple Wands" menu setting (under "Type of Wand").

Of course, this method doesn't allow users to choose which two wand types they want. For that you would have to be a bit more clever, but it can still be done only by editing menus.txt. Also, the two wands will have the same graphic so you won't be able to tell them apart in-game (except by trying them out!).

Changing the graphics is a bit more complicated, you have to

(1) place your new BMP files into knights_data

(2) edit lua_test.lua to load the new graphics into the game, by adding things like

g_wand_red = Graphic("wand_red.bmp",0,0,0,-3,-6)
g_wand_yellow = Graphic("wand_yellow.bmp",0,0,0,-3,-6)


etc.

(3) edit items.txt to make the wand use the correct graphics, for example by adding

    graphic = g_wand_red
    overlay = [g_wand_red_north, g_wand_red_east, g_wand_red_south, g_wand_red_west]


to the i_wand_of_destruction section. (The "graphic" part is for when the wand is on the ground, the "overlay" is for when the wand is held by a knight, for each of the four facing directions.)

ImpassIve

Oh, great thanks for a such detailed answer.
I have seen sprite files, but ignored (don't know, why)) "*.txt" ones, which were placed in the same folder

I will try this soon.
Thanks again!




K9

Stephen, to be sure I understand how this works, what happens when someone does this setting on their local machine, will it affect gameplay on network?  I haven't made my way through all internal coding, so maybe this is dumb question.

Is this setting something that might be done on the server which would then show up immediately for all online players (as you said without any programming changes)?

PS I know this note is probably out of place, but while I'm here quickly wanted to say I probably won't be able to make it on tomorrow's games.. family birthday activities to attend, looking forward to the following weekend in March.. see you later.

Thank you.

ImpassIve

to K9:

I tried this. Changing "menus.txt" file on the local machine doesn't allow you to use multiple wands in a network game, because at least this file (or all files from knights_data folder?) is stored on server.

But just modifying files on the server is also insufficient, because if you added new sprites for different wands, so user connects to the server, doesn't have them. So, you had to send this modified files to the players, before they will be able to join the game...

That's how I understand it. I may be wrong.




ImpassIve

#5
P.S.
Here is working variant of implementing multiple wands. It was made by using Stephen's advice.

It puts "Multiple wands" and "All wands" items to menu.
Multiple wands = Destruction + Securing

It doesn't change sprites of single-type wands (if you will select "Type of wands" as, for example, "Wand of securing" - game will use usual sprite), but if you select Multiple wands - they will have different sprites.

The wand of destruction is red.

The wand of securing is lightblue.

The wand of open ways is white.

The wand of undeath is dark-brown.



Note: if you select, for example, 4 wands ingame - there will be 4 wands of each type. So, with "multiple wands" there will be 4 destruction + 4 securing.

Upd: the link for those who are not logged in (same as an attachment)
http://dl.dropbox.com/u/18251705/m_wands.zip




Stephen

Thanks ImpassIve, that looks great, I will try it out later.

To answer the question about files: yes, basically ImpassIve is right. For local games (e.g. single player mode) your own .txt files are used, but for online games (where you connect to the Knights server), the server's files are used and your local .txt files are ignored.

The graphics files (.bmp) are different; they are read from the local machine (so each player has to have their own copy of the BMP files). Therefore, ImpassIve's mod would require a new release of Knights if we wanted to push it out to all players.

An alternative design would be to have the server download the BMP files to the client when the client first connects. This would mean we could apply mods like this without clients needing to make any changes. In fact this would be quite easy to do... I might look into it for a future release.

Stephen

Quote from: ImpassIve_rus on February 26, 2012, 05:00:52 PM
Upd: the link for those who are not logged in (same as an attachment)
http://dl.dropbox.com/u/18251705/m_wands.zip

Oops, I did not realize guests could not view attachments. I've changed the permissions, hopefully this should be possible now.

ImpassIve

#8
Heh, there are still several bugs in my "mod".
1) It looks like something is a bit wrong with offset of wands sprites... That's strange, because I didn't change size of sprites (they are still 3x11 px)...
2) The wand of undeath... It still works, when you hit somebody with it, but zombies aren't afraid of player who holds it. Looks like I should rewrite original "i_wand_of_undeath" object (in this mod, I tried to create new object - "i_wand_of_undeath_c", etc. - that was made to save original sprites in usual game-types and to store most of modified data in a special folder - it makes easier deleting of mod), because A.I. of zombies doesn't know about "i_wand_of_undeath_c".

And I have several technical questions to Stephen, about possibility of "modding" in this game.
1) Is where any existing way to add your own .lua files in addition to standart ones? (I dislike modifying original files - because several mods would be incompatible in such way). (something like "include" operator from config files, but in lua?)
2) That's about adding possibility of "rewriting" objects from config files?
so, an "i_wand_of_undeath" is declared in "knight_data/items.txt" and we have to modify this file to change sprites instead of writing something like "replace:i_wand_of_undeath" (or something like this?) in my own file - and this new definition should rewrite old one, without real changing of original file.

And just one more thought - that's about adding the string "include mods.txt" to main_config.txt. And mods.txt loads main configuration files of each mod. (for example: "include wands/items.txt;include spiders/main.txt; etc...." - that's the only things which are placed to this file).
So, in ideal - if there are exists several unofficial mods - you will be able to install just by:
Step 1) Unpacking their folders (with all their files and sprites) into knights_data.
Step 2) Adding a link to their config files into the mods.txt (it would be pretty easy for user)




K9

#9
Wow, this activity looks very interesting, ImpassIve_rus

Glad to see someone else creativity and ability to do some of the modding that Stephen has been laying ground work.  Of course some things easier than others, but these wands good place to start maybe feasible quick to get online soon.

Thank you for reply above, and Stephen, client/ server file run time update makes sense if not too difficult to keep security and central control to avoid any risks (if any).

Stephen

Quote from: ImpassIve_rus on February 27, 2012, 06:12:07 PM
Heh, there are still several bugs in my "mod".
1) It looks like something is a bit wrong with offset of wands sprites... That's strange, because I didn't change size of sprites (they are still 3x11 px)...

Hmm, not sure, I will have a look at this later...

Quote
2) The wand of undeath... It still works, when you hit somebody with it, but zombies aren't afraid of player who holds it. Looks like I should rewrite original "i_wand_of_undeath" object (in this mod, I tried to create new object - "i_wand_of_undeath_c", etc. - that was made to save original sprites in usual game-types and to store most of modified data in a special folder - it makes easier deleting of mod), because A.I. of zombies doesn't know about "i_wand_of_undeath_c".

This is specified by "ai_fear" in monsters.txt. Unfortunately you can only specify one ai_fear item per monster type. I should change this so that a list of items can be specified, that would solve your problem (you would write ai_fear = [i_wand_of_undeath, i_wand_of_undeath_c] -- unfortunately this is invalid syntax at the moment).

Quote
And I have several technical questions to Stephen, about possibility of "modding" in this game.
1) Is where any existing way to add your own .lua files in addition to standart ones? (I dislike modifying original files - because several mods would be incompatible in such way). (something like "include" operator from config files, but in lua?)

Not at the moment. The Lua support is still at a very early and experimental stage -- eventually it will be improved and expanded somewhat, but for now everything is just thrown into one file called "lua_test.lua".

Quote
2) That's about adding possibility of "rewriting" objects from config files?
so, an "i_wand_of_undeath" is declared in "knight_data/items.txt" and we have to modify this file to change sprites instead of writing something like "replace:i_wand_of_undeath" (or something like this?) in my own file - and this new definition should rewrite old one, without real changing of original file.

That's a good idea. :)

Quote
And just one more thought - that's about adding the string "include mods.txt" to main_config.txt. And mods.txt loads main configuration files of each mod. (for example: "include wands/items.txt;include spiders/main.txt; etc...." - that's the only things which are placed to this file).
So, in ideal - if there are exists several unofficial mods - you will be able to install just by:
Step 1) Unpacking their folders (with all their files and sprites) into knights_data.
Step 2) Adding a link to their config files into the mods.txt (it would be pretty easy for user)

Yes, that is a good idea, and a higher priority now that the config files are becoming more usable for mod making. I will try to get something like this into the next release. (Don't really know when that will be, as I am a bit busy at the moment, but I should get round to it eventually...)

ImpassIve

#11
I updates the files.
Now, new wands fully rewrite old ones (so, old sprites are not used now) - but Wand of Undeath should work with it.
And also, I tried to slightly change the sprite of Wand of Destruction.
__

to K9:
Thanks for your opinion. I was glad to hear it.

to Stephen:
"I am a bit busy at the moment"
Ok. that's not a problem. I don't think what last items were requested by me, are so necessary for community. So, they can wait for a indefinitely long time...
Anyway, you devote a lot of your time for the project, and this deserves respect




Romanio(Rus)

I also want to thank Stephen for his work. Thank you, Stephen ;)