Wall cling for Lerk

YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
edited November 2011 in Modding
<div class="IPBDescription">with the recipe</div>Implementation of this idea : <a href="http://www.unknownworlds.com/ns2/forums/index.php?showtopic=115188&st=0" target="_blank">http://www.unknownworlds.com/ns2/forums/in...115188&st=0</a>

It was very easy to do, so I'll show how to do it, someone could maybe learn something ! Basically I adapted the code from Skulk.lua into
Lerk.lua :

Add the wall sticking range in the variables:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->Lerk.kNormalWallWalkRange = 0.2<!--c2--></div><!--ec2-->

Init some variables in Lerk:OnInit(), self.wallWalking will tell you if you're attached to the wall:

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->self.wallWalking = false
self.wallWalkingNormalCurrent = Vector.yAxis
self.wallWalkingNormalGoal    = Vector.yAxis<!--c2--></div><!--ec2-->

Copy two functions that allows to check if you are close to a wall a gives you back the wall orientation :

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->function Lerk:TraceWallNormal(startPoint, endPoint, normals)
...

function Lerk:GetAverageWallWalkingNormal(extraRange)
...<!--c2--></div><!--ec2-->

Then in Lerk:PreUpdateMove call this function to check if you are close to the wall, and set wallWalking to true if so :

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    if not self:GetIsOnGround() then
        local goal = self:GetAverageWallWalkingNormal(Lerk.kNormalWallWalkRange)
    
        if goal ~= nil then
                self.wallWalkingNormalGoal = goal
                self.wallWalking = true
        else
            self.wallWalking = false
        end
    end<!--c2--></div><!--ec2-->

Put the gravity to zero if attached to the wall in Lerk:AdjustGravityForce(input, gravity) :
<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    if self.wallWalking then
        return 0
    end<!--c2--></div><!--ec2-->

Increase the friction if attached to the wall in Lerk:GetFrictionForce(input, velocity),
so you don't slide too much on the wall :

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->    if self.wallWalking then
        frictionScalar = 4
        return Vector(-velocity.x, -velocity.y, -velocity.z) * frictionScalar
    end<!--c2--></div><!--ec2-->

That's it !

In addition one could add some crouch key condition for attaching to the wall using self.crouching. Also a condition on the speed and the angle you hit the wall would be nice. One can play with the view tilt as well.

Mod in the attachment, "blabla.. steamapps\common\natural selection 2\NS2.exe" -game LerkCling to launch. Comment and suggestions.


<center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/mfFKXm8OnKM"></param><embed src="http://www.youtube.com/v/mfFKXm8OnKM" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>

Zip file : <a href="http://www.unknownworlds.com/ns2/forums/index.php?act=attach&type=post&id=36029" target="_blank">http://www.unknownworlds.com/ns2/forums/in...st&id=36029</a>

Comments

  • DestroidDestroid Join Date: 2011-10-25 Member: 129240Members
    edited November 2011
    Awesome, thanks for that Yuuki!

    Tested and working as intended, good move making him walk really slow on the wall.

    But I keep breaking my game when trying to port this to the Gorge >_<
  • B1ackSmokeB1ackSmoke Join Date: 2011-01-25 Member: 78855Members
    All these mods are great. Feels/looks like an actual flying alien now.

    -B1ackSmoke
  • SkymanderXSkymanderX Green Marine - The Few, The Proud, The Green. Join Date: 2011-07-29 Member: 113006Members
    Again thanks so much for making this upon my request.
  • HackepeterHackepeter Join Date: 2003-06-08 Member: 17107Members, Constellation
    Nice Job Yuuki! Feels very natural, I wonder how it would be on a public game.
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    edited November 2011
    Thanks for the comments! I don't know how it look from the outside actually, but probably a bit weird, specially when you hang on the ceiling. One should rotate the model, and maybe add some animations to make it look good.

    From the gameplay point of view, I don't think it would change much. It's more something what you would use while waiting of healing than during combat. It could be useful to keep altitude and use it at the right moment to gain speed, but the current flight model do not really allow that.

    >But I keep breaking my game when trying to port this to the Gorge >_<

    Hum, it should work more or less in the same way I think, what kind of errors do you get ?
  • HackepeterHackepeter Join Date: 2003-06-08 Member: 17107Members, Constellation
    <!--quoteo(post=1884409:date=Nov 9 2011, 03:40 PM:name=Yuuki)--><div class='quotetop'>QUOTE (Yuuki @ Nov 9 2011, 03:40 PM) <a href="index.php?act=findpost&pid=1884409"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->Thanks for the comments! I don't know how it look from the outside actually, but probably a bit weird, specially when you hang on the ceiling. One should rotate the model, and maybe add some animations to make it look good.<!--QuoteEnd--></div><!--QuoteEEnd-->

    type "thirdperson" in the console while cheats are on to see how it looks. Maybe you could just rotate the player model exactly like the view if he is clinged? Would be a bit abrupt without an nice animation but should be fine as a placeholder :)
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    I'll try that. I had a quick look in ns2docs and it seems there is a function for it !

    function Skulk:AdjustModelCoords(modelCoords)
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    It was looking really bad indeed, the lerk was flapping around, attached to the ceiling by the head ^^

    I tried to fix it, it's a bit buggy, and there is no smooth transition, but it looks better. I also added roll and pitch on the model while flying (he goes straight like a tank right now) it makes it look much more organic I think :

    <center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/VVoNfjj1Bvc"></param><embed src="http://www.youtube.com/v/VVoNfjj1Bvc" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>
  • aeroripperaeroripper Join Date: 2005-02-25 Member: 42471NS1 Playtester, Forum Moderators, Constellation
    Ceiling lerk is watching you...

    This might make it too easy for lerks to spike spam from dark far away corners though. I know the devs changed his ability to get him more into direct combat and out of vents and at the end of long hallways.
  • HackepeterHackepeter Join Date: 2003-06-08 Member: 17107Members, Constellation
    <!--quoteo(post=1884483:date=Nov 9 2011, 11:57 PM:name=Yuuki)--><div class='quotetop'>QUOTE (Yuuki @ Nov 9 2011, 11:57 PM) <a href="index.php?act=findpost&pid=1884483"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->It was looking really bad indeed, the lerk was flapping around, attached to the ceiling by the head ^^

    I tried to fix it, it's a bit buggy, and there is no smooth transition, but it looks better. I also added roll and pitch on the model while flying (he goes straight like a tank right now) it makes it look much more organic I think :<!--QuoteEnd--></div><!--QuoteEEnd-->

    It looks awesome! good job :)
  • twilitebluetwiliteblue bug stalker Join Date: 2003-02-04 Member: 13116Members, NS2 Playtester, Squad Five Blue
    edited November 2011
    That looks very impressive Yuuki!

    I've just tested your mod, and I would strongly suggest adding an activate wall cling key (ctrl?). Otherwise it is too easy to stick to walls by accidental. Wall cling could switch off for a short time when the jump key is pressed, to prevent re-sticking.

    You can also improve the efficiency of the check by only performing the wall walk check when the key is pressed down.
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    edited November 2011
    Yes this would be needed, but I don't think I will implement anything because at this stage I doubt anybody will really use it (except for experimentation).
  • Cyberwarrior00785Cyberwarrior00785 Join Date: 2010-02-20 Member: 70651Members
    how do you install this?
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    Download the zip in my first message, unzip in ns2 directory and start the game using "pathToSteam\steamapps\common\natural selection 2\NS2.exe" -game LerkCling then create a local server put cheats on (cheats 1) and go lerk (j2, lerk).
  • PricePrice Join Date: 2003-09-27 Member: 21247Members
    edited November 2011
    Great work!
    Can you not set some animation on wallwalking?
    Maybe the "glide" animation would fit good
    <img src="http://img263.imageshack.us/img263/8664/glidens2.jpg" border="0" class="linked-image" />
    For the code to change it, maybe you look into the fade weapon code "Blink_Client" or the fade code itself i have no idea.
    but you know the fade shrinks if he use blink, maybe you can use that with position.
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    The lerk cannot really walk on wall, it just hang there. I tried to add the landing animation when attaching to the wall, but it was repeating itself all the time...
  • mediallymedially Join Date: 2011-11-17 Member: 133659Members
    thank you for a good post)
  • PricePrice Join Date: 2003-09-27 Member: 21247Members
    <!--quoteo(post=1885827:date=Nov 20 2011, 01:01 PM:name=Yuuki)--><div class='quotetop'>QUOTE (Yuuki @ Nov 20 2011, 01:01 PM) <a href="index.php?act=findpost&pid=1885827"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->The lerk cannot really walk on wall, it just hang there. I tried to add the landing animation when attaching to the wall, but it was repeating itself all the time...<!--QuoteEnd--></div><!--QuoteEEnd-->
    oh ehm i guessed you use the wallwalking code for attaching the lerk on a wall:
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->  if self.wallWalking then
            return 0
        end<!--c2--></div><!--ec2-->
    the skulk uses the wallwalking... i try 1 month ago with lerk too and he could stay in air because i used the wallwalking code and change it.
  • SkymanderXSkymanderX Green Marine - The Few, The Proud, The Green. Join Date: 2011-07-29 Member: 113006Members
    Is there anyway we can petition this to be in the game? Lol i love this feature
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    Keep the thread up and improve the mod is the way to go. I guess that for something to be added into the game must be awesome beyond reasonable doubt :)

    Here I made some changes, I added some conditions on speed and angle to the clinging instead of a key, I works ok, but may need some tweaking :

    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->            if goal ~= nil then
                
                    local dot = math.abs(velocity:DotProduct(goal))
                    local velLength = self:GetVelocity():GetLength()
                
                    //never attach at high speed
                    if velLength < 10 then

                        if dot > 0.6 then //landing approach is right
                            self.wallWalkingNormalGoal = goal
                            self.wallWalking = true
                            
                        elseif velLength < 4 then
                            self.wallWalkingNormalGoal = goal
                            self.wallWalking = true
                        
                        end
                    end
                end<!--c2--></div><!--ec2-->

    I also added a powerful flap that allows to detach from the wall.

    <center><object width="450" height="356"><param name="movie" value="http://www.youtube.com/v/yBfxP79fVxE"></param><embed src="http://www.youtube.com/v/yBfxP79fVxE" type="application/x-shockwave-flash" width="450" height="356"></embed></object></center>
  • SkymanderXSkymanderX Green Marine - The Few, The Proud, The Green. Join Date: 2011-07-29 Member: 113006Members
    now add this with the mod that gives the lerk pitch and roll and tada! perfection
  • SkymanderXSkymanderX Green Marine - The Few, The Proud, The Green. Join Date: 2011-07-29 Member: 113006Members
    any new stuff by chance?
  • Electr0Electr0 Join Date: 2011-10-31 Member: 130337Members
    Wow this is good, it would be such a shame not to make it official, i actually think all three lower lifeforms should get some sort of ability, the skulk can wall walk all over freely, the lerk can fly to a spot and hang there and the gorge should be able to get to high places by shooting out a grappling hook and swinging from place to place.
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    >any new stuff by chance?

    Well I should update it for the current build, because the animations are broken now. But I'm not sure it's really useful because it will be probably broken again in next build, so it's a lot of work for not much. Maybe when the mod download will work we could try to play with it.
  • vizioNzvizioNz InversionNS2.com Join Date: 2003-12-21 Member: 24595Members, Constellation, NS2 Playtester
    This is very cool. Could you add an affect as you are clinging on to something that the screen sways back and forth (like a bat)? Don't stop working on this, it's awesome!
  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    <!--quoteo(post=1889393:date=Dec 9 2011, 03:51 PM:name=Yuuki)--><div class='quotetop'>QUOTE (Yuuki @ Dec 9 2011, 03:51 PM) <a href="index.php?act=findpost&pid=1889393"><{POST_SNAPBACK}></a></div><div class='quotemain'><!--quotec-->>any new stuff by chance?

    Well I should update it for the current build, because the animations are broken now. But I'm not sure it's really useful because it will be probably broken again in next build, so it's a lot of work for not much. Maybe when the mod download will work we could try to play with it.<!--QuoteEnd--></div><!--QuoteEEnd-->

    Constant update, iterations and fixes are all part of writing code, it helps you write more solid code as well, because you get fed up of editing your stuff when you do it the long way round :)

    Keep going, this is a great mod, sure, maybe wait for 190 release before getting it working properly again, but keep up with it :)
  • SkymanderXSkymanderX Green Marine - The Few, The Proud, The Green. Join Date: 2011-07-29 Member: 113006Members
    does this now work with the current build?
  • YuukiYuuki Join Date: 2010-11-20 Member: 75079Members
    Probably not, would be redone easily with the instruction from my first post. But the lua reload don't work for me so it's a bit of a pain.
Sign In or Register to comment.