Deathmatch Mod (Lua)

jamesbchjamesbch Join Date: 2004-04-20 Member: 28035Members, Constellation
<div class="IPBDescription">What we need</div>Now that we can customize a little bit the game I think we can make a deathmatch mod. We could modify the lua files to do it so.

What's mandatory :
1/ Shot reaches player and we can detect it
Look for Rifle.lua @ l.161 (target)
2/ We can handle damage or do it: touched = dead
Look for Rifle.lua @ l.190 (TakeDamange ?)
3/ Add more respawn in the map / do real maps for DM (spawn random)
Look for Server.lua @ l.44 (spawn)

Better with:
1/ Step/Jumpsound !
2/ Scoreboard / Score text
3/ Better UI with HP
4/ Death animation
5/ Crouch

What do you think ? It's possible after all isn't it ?

Comments

  • carlgmcarlgm Join Date: 2004-08-26 Member: 30907Members, Constellation
    edited April 2010
    Possible but not worth it and I understand why you might want to do it <b>but</b> this is the engine test, you should test what they've provided. That is what they provided it for and need help confirming any graphical issues excluding issues caused by missing features like weapon clipping etc.

    Wait for the beta/alpha for gameplay and all these features will already be there.
  • SupernornSupernorn Best. Picture. Ever. Made. Ever. Join Date: 2002-11-07 Member: 7608Members, Constellation
    Yes, do it. This is entirely what the LUA code is there for.
  • CowThingCowThing Join Date: 2010-03-03 Member: 70818Members
    It is very possible with just the engine test, though we'd have to go through and learn the code ourselves. Then change a lot of it. Because right now the player object doesn't even have health.
  • rsdrsd Join Date: 2003-02-11 Member: 13405Members
    Very possible I think.

    I'm working on a skulk. Biting animations and model switches are in, but that's simple enough. Looking at the model viewer the skulk run animation appears to be missing though :(

    Good exercise to get familiar with the layout of their Lua code though.

    @carlgm, good work on the negativity. Someone's got to do it.
  • carlgmcarlgm Join Date: 2004-08-26 Member: 30907Members, Constellation
    @rsd I edited my post to clarify.
    Better to work on stuff that's actually going to be worthwhile and should be migrated to alpha/beta/full game. This really shouldn't be.
  • TriggermanTriggerman Graphic Artist Join Date: 2004-11-10 Member: 32724Members, WC 2013 - Supporter
    If someone creates a mod that is actually playable that means that more people will continue to test it and probably also test it with more players on a single server which results in better stress-testing. As long as a mod doesn't distract the developers (which it shouldn't) then there's no harm whatsoever.
  • KerotanKerotan Join Date: 2005-04-17 Member: 48692Members, Constellation
    This is a Engine test not a Natural Selection 2 test, this is exactly what the devs want. People to go out with the engine they have provided and create insane mods!

    I bet you there's already a few mods underway which people have been planning since the announcement of NS2, and I cant wait to get my hands on them.
  • EkhosEkhos Join Date: 2009-12-10 Member: 69563Members
    NOTE:The following is just my own theory that probably wont work as i havn't been able to test it properly but it should be a start.

    Making a simplistic DM-mod isnt that hard, since most of the functions needed are already implementated. Since a targetdummy already can be shot, we just need to find exactly which part handles being hit and copy that into the Player-class.

    If we look in the Rifle.lua L183 it checks if there is a target and that the target has the function TakeDamage. That is the main difference between a target dummy and a player, as the Player-class lacks TakeDamage. In Target.lua L91 they define the TakeDamage functionas the following

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function Target:TakeDamage(attacker, damage, doer, point, direction)
            
            if (self.state == Target.State.Popped) then
            
                self:PlaySound(self.dieSound)
                
                self.state = Target.State.Killed
                
                // Inform the game that a target was destroyed so that points
                // can be awarded, etc.
                Game.instance:DestroyTarget(attacker, self)
                
                // Create a rag doll.
                self:SetPhysicsActor()
                
                // Give the target an impulse at the kill location to make it
                // fly around a bit.
                self.impulsePosition  = point
                self.impulseDirection = direction
            
    end<!--c2--></div><!--ec2-->


    Adding the following function to Player.lua should allow a player to be "hit".

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function Target:TakeDamage(attacker, damage, doer, point, direction)

                // Inform the game that a target was destroyed so that points
                // can be awarded, etc.
                Game.instance:DestroyPlayer(attacker, self)
                // Note that DestroyPlayer is a new function that doesnt exsist in Game.lua, but we will fix this soon
                      
    end<!--c2--></div><!--ec2-->

    In Target.lua the function seems to be defined in two ways, depending on wheter it is a client or a server. This is the server-version as it seems the client-version is only used for an aesthetical purpose.

    Although a player can be "hit" we need to make sure that the game actually reacts to the hit. In the Game.lua we need to add function DestroyPlayer, similair to how the targetdummies uses the DestroyTarget-function. The following version should just add score to whoever shoots someone. (its almost a copy of how the game reacts when a target dummy is hit)

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function Game:DestroyPlayer(player, target)
        
            player.score = player.score + 1
        
    end<!--c2--></div><!--ec2-->

    This isnt a real DM though. What we want to do is somehow "respawn" a player if he or she is hit. Doing a proper respawn is quite hard, but we can circumvent this by just "teleporting" the player to a spawnpoint when the player is hit. The following is partly taken from Server.lua L25. What it does is that it finds a empty spawnpoint where we safely can teleport a player to

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function Game:DestroyPlayer(player, target)
        
            player.score = player.score + 1

    // Get an unobstructured spawn point for the player.
        
        local extents = Player.extents
        local offset  = Vector(0, extents.y + 0.01, 0)
        
        repeat
            spawnPoint = Shared.FindEntityWithClassname("player_start", spawnPoint)
        until spawnPoint == nil or not Shared.CollideBox(extents, spawnPoint:GetOrigin() + offset)

        local spawnPos = Vector(0, 0, 0)

        if (spawnPoint ~= nil) then
            spawnPos = Vector(spawnPoint:GetOrigin())
            // Move the spawn position up a little bit so the player won't start
            // embedded in the ground if the spawn point is positioned on the floor
            spawnPos.y = spawnPos.y + 0.01
        end

        //And now we teleport the poor player to the found position
        //I found the SetOrigin-function in Player.lua L407 and I hope it works like this. This is the part which i doubt the most.
        target:SetOrigin(spawnPos)
        
    end<!--c2--></div><!--ec2-->

    Hopefully you'll understand what i mean, sorry if its confusing but im really bad at explaining things. There might a lot of fatal flaws in this but i think for me this code seems resonable and hopefully this can start a discussion on how to improve it.
  • ComproxComprox *chortle* Canada Join Date: 2002-01-23 Member: 7Members, Super Administrators, Forum Admins, NS1 Playtester, NS2 Developer, Constellation, NS2 Playtester, Reinforced - Shadow, WC 2013 - Silver, Subnautica Developer, Subnautica Playtester, Pistachionauts
    The engine test is for people to help us fix engine problems, but please, go ahead and start attacking the LUA as well. That will be a big part of the engine as well, so enjoy.
  • rsdrsd Join Date: 2003-02-11 Member: 13405Members
    edited April 2010
    Consider it attacked :)

    <!--quoteo(post=1765321:date=Apr 10 2010, 06:16 PM:name=Ekhos)--><div class='quotetop'>QUOTE (Ekhos @ Apr 10 2010, 06:16 PM) <a href="index.php?act=findpost&pid=1765321"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->stuff<!--QuoteEnd--></div><!--QuoteEEnd-->

    I did a very similar dirty-hack-dm to this. Basic concepts are the same - didn't see your post, but came to the same conclusions about the quickest way to get something up and running. (dirty) Code is in my other thread if you want to check it out.
  • PipiPipi Join Date: 2009-12-09 Member: 69550Members
    Just wait for the alpha.. all the lua code made by Flayra will certainly be better afterall.
  • jamesbchjamesbch Join Date: 2004-04-20 Member: 28035Members, Constellation
    <!--quoteo(post=1765340:date=Apr 10 2010, 06:33 PM:name=Pipi)--><div class='quotetop'>QUOTE (Pipi @ Apr 10 2010, 06:33 PM) <a href="index.php?act=findpost&pid=1765340"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Just wait for the alpha.. all the lua code made by Flayra will certainly be better afterall.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Maybe our work will help them ! So while some are playing and bug-tracking others are playing with lua. I think it's the optimal way to "wait".
  • devicenulldevicenull Join Date: 2003-04-30 Member: 15967Members, NS2 Playtester, Squad Five Blue
    We've got an implementation going at <a href="http://unknownworlds.com/ns2/forums/index.php?showtopic=109276" target="_blank">http://unknownworlds.com/ns2/forums/index....howtopic=109276</a>
Sign In or Register to comment.