[Open Assets] Classic-style Coop (classiccoop.lua)

This content may be freely modified and/or maintained by anyone.
Status
Not open for further replies.

FuriousFox

AKA FuriousFox
This Lua script makes it so all players except for the "main player" act like Player 2 from the old Sonic games. This means:

You cannot lose rings
You cannot lose lives
You cannot pop monitors
You cannot activate starposts
You cannot finish levels
Any rings you pick up go to the main player
Any score you gain will go to the main player
If you die or go too far away from the main player, you will teleport back to them

The main player still plays like a normal player, with lives and rings and everything. Basically, the main player is the "Player 1" of the group. Everyone's HUD will display the rings and lives for the main player.

This script includes 3 console commands to assist you with using it.

MAINPLAYER <name> - Sets the main player for the game. This is the player that will still act like normal. By default, this will be the host. If the main player leaves, the host will become the new main player.
LEASH <number> - Sets how far players can move away from the main player, in fracunits. Set to 0 to turn off the leash. Default is 8192.
SUICIDE - Kill yourself. Useful if you get stuck somewhere, like in a zoom tube. You will respawn at the main player.

Version 1.0
Initial Release

Version 1.1
MAINPLAYER command should now accept player numbers in addition to names.
Added CC_CHANGEONDEATH console variable. If set to true, the Main Player will change when the current Main Player dies.
Added CC_CHANGEONNEWMAP console variable. If set to true, the Main Player will change when a new map is loaded.
Added CC_SHOWMAINPLAYERNAME console variable. If set to true, the lives icon will show the Main Player's name instead of their skin's name.

Version 1.2
Fixed a problem where only the server could turn the leash off.
Fixed a problem where only the server could turn main player names on.
Fixed coins not giving the main player rings when picked up by other players.
Fixed the new main player respawning when the previous main player died.
Fixed respawning players not having the same scale as the main player.
Main player names are now on by default.
Made it so only main players can pick up special stage tokens, Chaos Emeralds, and Fire Flowers.
The lives icon should now display the main player's character's Super icon while they are in Super form.

Version 1.3
Fixed a warning that was popping up in 2.1.15
Fixed extra lives counter not being transferred when manually switching mainplayers
Improved the HUD for splitscreen
 

Attachments

  • ClassicCoop-v1.3.lua
    16.6 KB · Views: 1,318
Last edited:
Heh, this is pretty neat! I honestly didn't expect anyone to try and recreate how the classics handled the AI Tails in single player, but it turns out this actually makes netgames pretty interesting, and slightly more playable!

We've already worked out all the bugs on IRC, so you're good to go. Welcome to releases!
 
Quick update: Just remembered a small bug where assisting players could be hurt by the main player's Elemental Shield flame trail. That has been fixed. If you downloaded the Lua right after it came out, you might want to redownload it.
 
Play this with combi ring and let the games begin!

Combiring alone is hard enough, I speak with experience.
But thinking about that it either makes no difference since every player is bound to each other and will respawn next to them anyways and/or it gets slightly easier because only one player has to deal with rings ect. rendering this useless to the combiring chain.
 
So I had hosted an server with this lua today and I have to say that I am terrible as a lead player. I outrun the other players most of the time when TRYING to play cooperative. But later I have tried to outrun the other players on purpose and this can be then a lot of fun for the other players trying to catch up to the lead player (much like the outrun races in Need For Speed Underground 2) or even outrun him. It is really a lot of fun esp. when one of your best friends teleports above a bottomless pit all the time ;P.

But I still have some suggestions to make:
1. I would suggest to be able to elect players by their node number because it is easier than typing their full name esp. when they use tons of special characters. Also I was unable to elect players who had spaces in their names.
2. It would be nice if the main player changes on mapchange and/or death. I think a command to toggle this feature would be nice so the host does not have to deal with typing all the names into the console and just enjoy randomly elected lead players.

Other than that I had a lot of good laughs with this script.
 
1. Unfortunately I'm not sure if it's possible to find a player's node number in Lua, so name is pretty much the only option.

2. I might add them as toggles, but for many people I think they'll want to keep the mainplayer the same throughout the game.
 
Does using quotes help at all for names with spaces?

It does! Thank you!
but I should have known that better by now

2. I might add them as toggles, but for many people I think they'll want to keep the mainplayer the same throughout the game.

I found it rather boring to have the same mainplayers over and over again so I thought this might be a good idea. Or at least just select a random player when entering mainplayer without a name into the console.
 
Last edited:
1. Unfortunately I'm not sure if it's possible to find a player's node number in Lua, so name is pretty much the only option.
Are you sure? If you have the player object (eg. by using players.iterate), try #player?

EDIT: Oh, but since you're trying to find a player BY node, then just do players[node] and make sure to check it isn't nil?
 
Last edited:
Uploaded a new version which adds console commands for changing the Main Player upon death or upon starting a new level. The MAINPLAYER command should also accept player numbers as arguments now too.
 
UPDATE!

Fixes:
Fixed a problem where only the server could turn the leash off.
Fixed a problem where only the server could turn main player names on.
Fixed coins not giving the main player rings when picked up by other players.
Fixed the new main player respawning when the previous main player died.
Fixed respawning players not having the same scale as the main player.

Changes:
Main player names are now on by default.
Made it so only main players can pick up special stage tokens, Chaos Emeralds, and Fire Flowers.
The lives icon should now display the main player's character's Super icon while they are in Super form.

Known issues:
Non main players can pop monitors on Mario Mode levels. This is to prevent a much worse problem from occurring.
Rings HUD item is not in the correct position on non-aspect-correct resolutions.

Other:
Added Lua garbage collection every time a new level loads. Will this help with anything? I don't know, but I'm trying it.
 
Last edited:
Minor update:

Fixed a warning that was popping up in 2.1.15
Fixed extra lives counter not being transferred when manually switching mainplayers
Improved the HUD for splitscreen
 
I'm out of town at the moment and can't look at it. How exactly is it broken? Is it throwing up an error message? If so, what is that message?
 
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top