Trouble setting a specific objective in MP scenario

Discussion of all aspects of multiplayer development: unit balancing, map development, server development, and so forth.

Moderator: Forum Moderators

Post Reply
Munkaccino
Posts: 4
Joined: July 6th, 2023, 4:04 am

Trouble setting a specific objective in MP scenario

Post by Munkaccino »

A couple of friends and I have been trying to code this scenario for over a week now, and for the most part we managed to make it work, except for the main objective.

Image

In this scenario, the player in the center (the Pit Lord) is pitched against 8 other players cornering him, but these 8 players aren't allied with each other, since their objective is to be the first to slay the Pit Lord, meaning they can make temporary alliances or stab each other's backs while they plot against the Pit Lord.

The Pit Lord's objective is to either kill, or have the other 8 players kill themselves, with or without the help of the allied AI (side 1), and be the last man standing, in this assymetrical scenario he has access to more villages, a stable passive income, and the ability to sacrifice units to open the gates of the Pit and release AI controled foes that will lash on towards the enemy players. We thought this was the hardest part to implement, but this feature is currently working as perfectly as intended.

The real issue we are having is that we managed to make a victory condition when the Pit Lord dies, but, that means everyone wins when he dies, including the Pit Lord himself. The way it was supposed to work is that when the Pit Lord dies, the side that killed him gets the victory, while the Pit Lord and all the other 7 sides get a defeat, but there seems to be no way to implement this.

We can't find any campaign where this happens, basically all campaign operate in a 1v1 or a last-man-standing logic, and the wiki is very vague with how the tags are implemented. We have basically tried everything at this point, and can't make any progress anymore.

The code we are currently trying to run is:

Code: Select all

[event]
    name=die
    [filter]
       id=PL
#this is the id for the Pit Lord       
 	[message]
		message=_"Side who killed pitlord is $second_unit.side"
		speaker=PL
	[/message]
	
	[endlevel]
		summary=yes
		[result]
			result=victory
			side=4
		[/result]
		[result]
			result=defeat
			side=3
		[/result]
	[/endlevel]
[/event]
As I said, none of this matters, when the Pit Lord dies, everybody wins, we tried triggering messages so see if anything would change, but to no avail, so any help would be greatly appreciated, thanks in advance.
(edit: also, we were using side 3 and 4 to test the winning conditions. Side 1 is the AI, side 2 the Pit Lord, side 3 to 10 are the other players...)
Last edited by Munkaccino on November 26th, 2023, 6:45 am, edited 1 time in total.
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Trouble setting a specific objective in MP scenario

Post by gfgtdf »

Hmm it's hard to tell what goes wrong here, in particular since I still don't know for sure how exactly it's tested.

So I'll give just some hints for now:
1) using [endlevel] with [result] is I think the right thing to do, but I'd additionally put `result=defeat` directly into the [endlevel] to be sure (the value from [endlevel] is still uses as a default. For sides that have no [result] specified). So

Code: Select all

	[endlevel]
		summary=yes
		#all other sides lose
		result=defeat
		[result]
		# except for side 4, it wins.
			result=victory
			side=4
		[/result]
	[/endlevel]
2) if you know Lua you can look up the details of the [endlevel] implementation in https://github.com/wesnoth/wesnoth/blob ... dlevel.lua

3) i don't think this is tested/used regularly so I cannot guarantee for sure there is no bug in the code, but I'd still call that unlikely.

4) it you are testing where one client controls multiple human sides (of which some won and some lose) , be aware that if in doubt wesnoth shows the result for the side that won.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Munkaccino
Posts: 4
Joined: July 6th, 2023, 4:04 am

Re: Trouble setting a specific objective in MP scenario

Post by Munkaccino »

gfgtdf wrote: November 25th, 2023, 11:05 pm Hmm it's hard to tell what goes wrong here, in particular since I still don't know for sure how exactly it's tested.
Oh right, well, a friend of mine and I were testing as:
• Me (Pit Lord)
• AI (player 2)
• Him (player 3)

So, I (the Pit Lord) would start the game and send my leader so the AI kills me, and when my leader died, both him and I got a victory message, and it's safe to assume the AI did too, which is half good and half bad. It's good that killing the Pit Lord triggers the victory result, but since it was the AI that killed me, my friend should have gotten a defeat screen. This kept happening the entire afternoon with us testing all possible variables within our reach.
gfgtdf wrote: November 25th, 2023, 11:05 pm 4) it you are testing where one client controls multiple human sides (of which some won and some lose) , be aware that if in doubt wesnoth shows the result for the side that won.
Yeah, I was testing it like that for a while, until my friend suggested we tested it together, so that way we could get the result in different screens, and that's how we realised there was something wrong with the coding... :doh:
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Trouble setting a specific objective in MP scenario

Post by gfgtdf »

Have you tried with the code I posted earlier? (I'm on my phone, so I cannot test it mysel :( )

Also, just to be sure: you are on wesnoth 1.16 right?
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Munkaccino
Posts: 4
Joined: July 6th, 2023, 4:04 am

Re: Trouble setting a specific objective in MP scenario

Post by Munkaccino »

gfgtdf wrote: November 26th, 2023, 3:39 am Have you tried with the code I posted earlier? (I'm on my phone, so I cannot test it mysel :( )

Also, just to be sure: you are on wesnoth 1.16 right?
Sorry, yeah, I will try it first thing in the morning, and I'll be sure to get back at you, thanks a lot for the help so far :D
(also, yes, it's 1.16, I believe that's the steam version)
Munkaccino
Posts: 4
Joined: July 6th, 2023, 4:04 am

Re: Trouble setting a specific objective in MP scenario

Post by Munkaccino »

gfgtdf wrote: November 26th, 2023, 3:39 am Have you tried with the code I posted earlier? (I'm on my phone, so I cannot test it mysel :( )

Also, just to be sure: you are on wesnoth 1.16 right?
It's incredible, it finally worked! Thanks a ton for your help, we applied the code as follows:

Code: Select all

[event]
    name=die
    [filter]
       id=PL
    [/filter]
	[endlevel]
		summary=yes
		result=defeat
		[result]
			result=victory
			side=$second_unit.side
		[/result]
	[/endlevel]
Now the Pit Lord is defeated when he dies, and also all the other sides that aren't the side that killed him are defeated as well!

Thank you so much once again, you trully came in like that Mercy meme offering a helping hand in a time of dire darkness, time to delve into the Pit now....
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Trouble setting a specific objective in MP scenario

Post by gfgtdf »

Your welcome :)

And note to self: we should consider redesigning this api a bit, having an attribute and a subtag with the same name could be problematic in some cases. Maybe renaming [result] to [side_result] or similar.
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
Post Reply