ServerMod / Smod2

SCP:SL ServerMod2
https://discord.gg/8nvmMTr
MIT License
68 stars 30 forks source link

[API] Health, previous states, and new events/event chaining #28

Closed PatPeter closed 4 years ago

PatPeter commented 6 years ago

I'm creating my first plugin for Smod2 and I'm having quite a difficult time getting it to work. Here is a list of all the things I'd like to see in the API in the future that would make it easier to use.

Let me explain what I am personally trying to do so that my requests will make more sense. I have an epidemic of zombies killing themselves intentionally either by tesla gate or by falling to their deaths in the Heavy Containment Y-junction.

If you're better off reading the code, here is my ZombieSuicideHotlineEventHandler.cs file.

These are all the things I've tried in the past 24-hours to get this working:

  1. Respawn SCP-049-2 with health set to 999999 to survive the tesla gate, and then set back down to normal levels assuming they moved. There is no code for this because there is no interface for it, but this was one of my first thoughts. Also doesn't work with Y-junction deaths.
  2. Fire a respawn event, such as OnPlayerSpawn, from OnPlayerDie, so that the player is immediately respawned. As mentioned above, the zombies would be instantly dead.
  3. Change the player's class back to SCP-049-2 using player.ChangeClass in OnPlayerDie, and then teleport using player.Teleport to SCP-049's spawnpoint. player.ChangeClass and player.Teleport do not work in OnPlayerDie.
  4. Add zombies that committed suicide to a Dictionary in the plugin in OnPlayerDie. Then, in OnSetClass if a player is flagged in zombieSuicides, set teamclassOutput to Classes.SCP_049_2. The event OnSetClass does not trigger when a player is killed and set to Spectator. If the player is spawned in in the next NTF/Chaos wave, the player will respawn as SCP-049-2 and die instantly to the tesla gate or infinite pit of death.
  5. Add zombies to a Dictionary in OnPlayerDie. In OnSetClass, set the zombies to SCP-049 to respawn them in a safe space. Then, chain another OnSetClass by moving the player from zombieSuicides to deadDoctors and then set the player to SCP-049-2 in the second OnSetClass. Cannot chain events.

There are more that I thought of during development and I'll add them when I remember them.

I'm also putting all my ideas for plugins here that can't currently be implemented in the API as example use cases for implementing the suggestions above:

george-cosma commented 6 years ago

Intresting ideas, I will get onto adding some of them in the near future, thank you for the suggestions!

PatPeter commented 6 years ago

It's so ironic that I went through all the effort of 17 builds to prevent zombies from killing themselves with the tesla gates and the developers decided to take tesla gates out of the game entirely :\

Rnen commented 6 years ago

In the IEventOnPlayerHurt, why not just check if the player's class is zombie (10) , like

switch ((int)player.Class.ClassType)
{
    case 10:
        if(type == DamageType.TESLA) { typeOutput = DamageType.NONE; damageOutput = 0f; }
        else goto default; 
        break;
    case default:
        typeOutput = type;
        damageOutput = damage;
        break;
}
PatPeter commented 6 years ago

@Rnen That would have worked for the (now defunct) tesla gates, but I was hoping for a solution that would work for both the tesla gates and the Y-junction infinite pit of deaths. Is there any way to teleport zombies after they've jumped to their own deaths in the infinite pits of death?

ButterscotchV commented 6 years ago

Added the suggestions about health modification

Grover-c13 commented 6 years ago

1 - OnAssignTeam is only ever called on the initial round start, i know its a confusing event name. Ive renamed it. So previousTeam will always be unassigned or maybe RIP.

Grover-c13 commented 6 years ago

2- Player.GetTeamClass should get the previous/current team class (its set after the event)

" Either the ability to fire events from within events (such as killing a player after spawning as a punishment), or chaining events together, (for instance if a class is changed for OnSetClass, it calls another OnSetClass until teamclass == teamclassOutput)" anyone can actually call events. Though this sounds like it could get into infinity loops easy unless im misunderstanding.

Use Player.ChangeRole to change role/teams. I know it can look a little confusing with a TeamRole class, a Team enum and then a Role enum. The TeamRole is just a bridging class and usually its just there to be a packet of information.

PatPeter commented 5 years ago

With the ability to pipe plugin events between each other, does this fulfill my original use case? I'll try coding event piping tomorrow.