Wargus / stratagus

The Stratagus strategy game engine
GNU General Public License v2.0
631 stars 120 forks source link

make sure we play the same game #193

Closed mimooh closed 8 years ago

mimooh commented 8 years ago

I recently submitted the patch which enlarges the demolish made by suicide-bombers via a parameter in lua. Then I was curious how the multiplayer game goes between two clients which differ in their lua setups. As expected there are no checks against such incompatibilities - the game started and didn't complain that suicide-bombers destroyed more forest in one game and less in the other, which of course would break the game sooner or later.

I don't know how likely it is, that the clients will indeed play with different lua setups, but perhaps a quick checksum on multiplayer game startup would make sense, eg. cat find . | grep lua | md5sum

Another idea would be a more precise game versioning, say v.2.4-{git-revision}. I could create such a patch for linux.

I played wargus multiplayer quite a bit lately. I can now say, that the desync problem is pretty much gone, so thanks for fixing that! Desync is not entirely gone, since it happend once or twice, which I don't consider a problem anymore.

Erenussocrates commented 8 years ago

hey, could you be able to make the AI detonate the suicide bombers when they are near enemy units? Because the AI just makes them basic attack when AI attacks with those units.

mimooh commented 8 years ago

hey, could you be able to make the AI detonate the suicide bombers when they are near enemy units? Because the AI just makes them basic attack when AI attacks with those units. You mean autocast spell of detonation if enemies are nearby? I don't think I could do that, unless it is in Lua.

Karol Kreński

You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/Wargus/stratagus/issues/193#issuecomment-246178422

mimooh commented 8 years ago

Ah, you probably mean: prefer attacking via spell over attacking via hitting? No, I don't think I could code that.

Karol Kreński

hey, could you be able to make the AI detonate the suicide bombers when they are near enemy units? Because the AI just makes them basic attack when AI attacks with those units. You mean autocast spell of detonation if enemies are nearby? I don't think I could do that, unless it is in Lua.

Karol Kreński

You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/Wargus/stratagus/issues/193#issuecomment-246178422

DinkyDyeAussie commented 8 years ago

Usually unit responses can be and are coded in lua instead of the engine. That's the whole reason we have this scripting system in stratagus to begin with. Just have a look at the lua files and see if you can.

Erenussocrates commented 8 years ago

Okay, which .lua file should I look at to figure out where to edit to make AI detonate suicide bombers near enemy units? Sorry for the question, I'm new in this.

mimooh commented 8 years ago

I haven't managed to find how lua encodes this. My intuition is that death and decoy spell is a good hint for how it is made. The death and decoy a) is a spell just as the detonation and b) AI prefers to use death and decoy over just simple attacking, so it is what you are trying to achieve.

I tried to modify "autocast" and "ai-cast" in wargus/scripts/spells.lua

DefineSpell("spell-suicide-bomber", (...) "autocast", {"range", 6, "priority", {"Priority", true}, "condition", {"opponent", "only"}, "position-autocast", SpellDeathCoil}, "ai-cast", {"range", 6, "priority", {"Priority", true}, "condition", {"opponent", "only"}, "position-autocast", SpellDeathCoil}

Seems like there is no documentation for what these parameters are, so I just guessed and tested, but to no success.

SpellDeathCoil seems to calculate the x,y coordinates for where to cast the spell.

Karol Kreński

Okay, which .lua file should I look at to make AI detonate suicide bombers near enemy units? Sorry for the question, I'm new in this.

You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/Wargus/stratagus/issues/193#issuecomment-246207759

Erenussocrates commented 8 years ago

Hello, I've checked the spells.lua, and I don't think "autocast" or "ai-cast" lines has to do anything with AI's behaviours in using them. Because even the spell exorcism has the default " "autocast", {"range", 10, "condition", {"opponent", "only"}}, "ai-cast", {"range", 10, "condition", {"opponent", "only"}} "

lines, and I don't think this changes anything in how the AI behaves in casting them. Maybe it's in another lua file, maybe it is possible to make the AI detonate it's suicide bombers when facing enemy, but have to edit a different lua file?

mimooh commented 8 years ago

It makes sense what you say. I can advise searching for the mechanism based on how death and decay operates since it's certainly used by the AI the way you want it.

Karol Kreński

Hello, I've checked the spells.lua, and I don't think "autocast" or "ai-cast" lines has to do anything with AI's behaviours in using them. Because even the spell exorcism has the default " "autocast", {"range", 10, "condition", {"opponent", "only"}}, "ai-cast", {"range", 10, "condition", {"opponent", "only"}} "

lines, and I don't think this changes anything in how the AI behaves in casting them. Maybe it's in another lua file, maybe it is possible to make the AI detonate it's suicide bombers when facing enemy, but have to edit a different lua file?

You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/Wargus/stratagus/issues/193#issuecomment-246211362

DinkyDyeAussie commented 8 years ago

Those parameters for death and decay look good and if you can find the ones or create parameters for the demolishion squad then you're all set!

Kintobor commented 8 years ago

Cybermind knows all about the auto casting. I believe he was the one that made the mage able to use blizzard.

Erenussocrates commented 8 years ago

Who is cybermind? Is he still around? Can we somehow get him to look at this topic?

Erenussocrates commented 8 years ago

btw, mimooh, which lua did you use to make the detonations larger?

mimooh commented 8 years ago

btw, mimooh, which lua did you use to make the detonations larger? https://github.com/Wargus/wargus/pull/194/commits/22978fc175f779a2e24b9f4ce11932cb601b8969

Karol Kreński

You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/Wargus/stratagus/issues/193#issuecomment-246341589

Erenussocrates commented 8 years ago

btw, does that condition make the sappers destroy buildings now?

mimooh commented 8 years ago

btw, does that condition make the sappers destroy buildings now? It does.

Karol Kreński

You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/Wargus/stratagus/issues/193#issuecomment-246358214

mimooh commented 8 years ago

Just found there are docs for spells and AI and everything! :) stratagus/doc/scripts/magic.html

Karol Kreński

You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/Wargus/stratagus/issues/193#issuecomment-246358214

DinkyDyeAussie commented 8 years ago

That's cool :+1:

Erenussocrates commented 8 years ago

@mimooh

Hey, after you mentioned about those docs, I took a look at them and I had an idea of trying to create my own "Capture/Charm" spell that makes the target unit your own unit when you cast it.

http://pastebin.com/hSK3KZtw

this is an excerpt from magic.html that you've talked about. Using that capture tag, I'm trying to create my own capture spell in wargus, but it seems to be not working. Here's what I wrote for creating the spell: http://pastebin.com/z8x9VbTN

I don't know why it doesn't work, but the game does not even open. If you have any idea about how this spell should work, could you tell me how to fix it?

mimooh commented 8 years ago

I don't know if you can find a spell expert here. We need to call out for Mistranger. Is watching this discussions? I don't know how to contact him.

Karol Kreński

@mimooh

Hey, after you mentioned about those docs, I took a look at them and I had an idea of trying to create my own "Capture/Charm" spell that makes the target unit your own unit when you cast it.

http://pastebin.com/hSK3KZtw

this is an excerpt from magic.html that you've talked about. Using that capture tag, I'm trying to create my own capture spell in wargus, but it seems to be not working. Here's what I wrote for creating the spell: http://pastebin.com/z8x9VbTN

I don't know why it doesn't work, but the game does not even open. If you have any idea about how this spell should work, could you tell me how to fix it?

You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/Wargus/stratagus/issues/193#issuecomment-246926476

Mistranger commented 8 years ago

Wow, it's still alive. Amazing. I have retired from Stratagus, Wargus and Doom Wars development 1.5 years ago, and haven't touched it since (except for a couple of bugs), so I don't remember everything in detail.

So, what's the problem? Of course the game will desync because the only kind of sync between players is player commands. If you're curious, open any log file in /logs and look at the commands. This mean that everything that is bound to this commands should be the same for all players (lua files, executables). What isn't bound to commands, could differ from player to player (nicknames, sound settings etc)

And yes, if you want to develop for Stratagus (and related games), you should study by yourself (that's how I learned out everything). The documentation is really outdated (last serious update in 2006 I think). I didn't like to write documentations, if no one will read them, heh.

So, if the target of spell is "position", you could use "position-autocast" property for "autocast" and "ai-cast" fields. "position-autocast" excepts 1 parameter - Lua function name that will do calculations. The Lua function gets 1 parameter - units table, which are selected in autocast range meeting the "condition"'s. You can mess with table in function (look at SpellBlizzard) and you should return 2 values - position for autocasting, or (-1, -1), if no suitable target position found.

So, just keep trying and you should get everything working properly. Welcome to Stratagus development, heh.

Erenussocrates commented 8 years ago

@Mistranger I would have read your documentations. Glad to see your help back here. Btw, about what you said about the spell. Was it addressed at my question? If it was addressed at my question, I didn't get what I must do here to fix it, sorry. Could you elaborate on that by telling/showing what I should change to make the charm spell work, for example?

Mistranger commented 8 years ago

@Erenussocrates oh my, you've messed everything in your script. I've answered in the issue you've created - look at my Doom Wars game, I've made a lot of heavy Lua scripting here, mostly based on new Stratagus features, that are not documented. Okay, here is the spell I've mentioned: http://pastebin.com/HHKG1Pvp Still, it would be good if you will look at the game itself to see how it works in action.

timfel commented 8 years ago

@mimooh I've pushed very simple checksumming for the loaded lua files and updated the error message in wargus, stargus, and war1gus. When you try to connect to a server that has modified the lua files you should get rejected now.