Shared upgrades coop mode

Level 3
Joined
Sep 20, 2024
Messages
15
Hello,
Is there a way to make it so researches (upgrades in armory, lumber mill etc.) are shared with all players but without any bugs? The 8 player coop campaigns have scripts for this but they are bugged causing the researches to sometimes not be researched for all players (for insance if player leaves or upgrades to keep etc. while the upgrade is still researching).

I made a simple trigger shown below. I need help, if anyone knows how to: "if a research is currently being researched other players should not be able to start researching same upgrade" (currently in my map all can start researching same upgrade and the players who didn't start researching first lose their gold and lumber spent when first player finishes the upgrade):
  • Shared Upgrades
    • Events
      • Unit - A unit Finishes research
    • Conditions
      • ((Owner of (Researching unit)) is in Players.) Equal to True
    • Actions
      • Player Group - Pick every player in Players and do (Actions)
        • Loop - Actions
          • Player - Set the current research level of (Researched tech-type) to (Current research level of (Researched tech-type) for (Owner of (Triggering unit))) for (Picked player)
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
There's three Research Events: Begins, Finishes, Cancels

So just break down the logic with these Events in mind.

You don't want players to be able to Research the same tech, at the same time:
Begins -> Disable research for all players (excluding self).

If a player cancels a research you'll want to undo the effects from your Begins trigger:
Cancels -> Enable research for all players.

If a player finishes a research you'll want to share this tech with everyone:
Finishes -> Level up tech for all players.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Fwiw this does mean you could hold a research hostage by intentionally starting it, letting it nearly finish, cancelling it, and starting it again ad infinitum.

I also believe (though could be wrong about this) that such events only apply to the currently researching item in the queue (not the rest of the queue) which means multiple players can queue it simultaneously as long as none of them actually start it because it was first in their queue.
 
Level 3
Joined
Sep 20, 2024
Messages
15
I believe the bug has to do with queue as you say or when you cancel a research, when you queue many upgrades on the 8 player coop campaigns, then not all players get the upgrades when they finish (for instance when you leave game etc.). @Naelavok said he would fix this but I guess busy with other things? ☺️

In my map I only have the "Finishes trigger" shown in my first post, while the 8 player coop campaign has "Finishes trigger" and "Begins trigger". The 2 player campaign by the spoon fixed all bugs with shared research using variables, but that is too advanced for me and I have more than 2 players in my coop maps.

I thought about it regarding trolls starting and cancelling. The best would be if I kept my trigger and simply return the gold and lumber to other players who were starting to research when the research is complete.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I believe the bug has to do with queue as you say or when you cancel a research, when you queue many upgrades on the 8 player coop campaigns, then not all players get the upgrades when they finish (for instance when you leave game etc.). @Naelavok said he would fix this but I guess busy with other things? ☺️

In my map I only have the "Finishes trigger" shown in my first post, while the 8 player coop campaign has "Finishes trigger" and "Begins trigger". The 2 player campaign by the spoon fixed all bugs with shared research using variables, but that is too advanced for me and I have more than 2 players in my coop maps.

I thought about it regarding trolls starting and cancelling. The best would be if I kept my trigger and simply return the gold and lumber to other players who were starting to research when the research is complete.
I'm pretty sure my three triggers handle it all. I can't see why they wouldn't work.

The exact moment you begin a research, nobody can click that button until it finishes.
The exact moment you cancel a research, everyone can click that button again.
The exact moment you finish a research, everyone instantly researches it, making it permanently unclickable. If it has multiple levels you can enable it again.

Regarding what Pyro said, holding a research hostage is one of the million ways a player can grief, which is not worth worrying about. If a player wants to ruin the game they will, one way or another. Multiple same-type techs starting at once doesn't make sense to me, unless there's a frame perfect situation. But in that case I assume the game will handle that because one of the techs has to begin before the others, and I imagine the others will then fail and cancel themselves. Worst case scenario you'll have to account for that with some kind of "1 frame later" cancelling system. This will be an extremely rare bug if it even exists.

If you need some kind of "leaver protection", which I don't fully understand, there's an Event for when a Player leaves. Using that you can create a new trigger which adjusts the Researches as you see fit. That doesn't sound necessary, though.
 
Last edited:
Level 10
Joined
Jul 15, 2010
Messages
29
I believe the bug has to do with queue as you say or when you cancel a research, when you queue many upgrades on the 8 player coop campaigns, then not all players get the upgrades when they finish (for instance when you leave game etc.). @Naelavok said he would fix this but I guess busy with other things? ☺️

In my map I only have the "Finishes trigger" shown in my first post, while the 8 player coop campaign has "Finishes trigger" and "Begins trigger". The 2 player campaign by the spoon fixed all bugs with shared research using variables, but that is too advanced for me and I have more than 2 players in my coop maps.

I thought about it regarding trolls starting and cancelling. The best would be if I kept my trigger and simply return the gold and lumber to other players who were starting to research when the research is complete.
Very late to respond, but here's the fix I found. I just haven't updated the actual maps because you're correct, I have been extremely busy. But before everything went crazy, I pretty much finished my template for a complete rework of the co-op logic for TFT. I attached my testbed for the rework if you want to examine it in detail.

I have all structures controlled by a dummy player. In my case, Player 24 controlled by the computer, but with no AI. I made a dummy hero unit for each individual research, which players can buy from the P24's structures. When they do, the dummy hero gets removed, P24 begins researching from that structure, and P24 stops selling that dummy hero at all its structures. When a research finishes, it starts selling the dummy hero that's next in the chain. If the structure is destroyed, it starts selling the original one again. So if it finished Iron Forged Swords, it starts selling the one associated with Steel Forged Swords.

This also prevents any issues from people leaving, since the computer P24 will be the one actually doing the research. The downside to this approach is that you can't queue things up at one building.
 

Attachments

  • 8p_nightelfx03.w3x
    625.7 KB · Views: 0
  • 8p_nightelfx02.w3x
    553.8 KB · Views: 0
Last edited:
Top