Character with multiability who can swim underwater

Is it possible to have a character with two abilities, one of them being a swim that only works underwater? I'm unable to get it working with my limited lua knowledge despite trying.
 
CA_SWIM is an ability

CA_SWIM doesn't have an ability for above-ground use.

that being said though, you can perfectly well change a skin's ability depending on the context. using the (player prefix).ability userdata, you can change it to whatever value you want using lua. i won't write the code for you, you'll definitely want to look at a tutorial + the wiki's extensive but slightly unfinished lua documentation.

for this kind of thing, you'll want to look at:

hooks
userdata structures
object flags

i hope this helps!
 
You can change the player's ability when checking if the player is underwater or not.
There is a player flag for being underwater, and the player structure stores the player's current ability in the charability player variable.

What have you tried so far?
 
Here's some code you can use:
Code:
addHook("ThinkFrame", function()
	for player in players.iterate do
		if player.mo.skin ~= "mechatails" then
			continue
		end
		
if (player.mo.eflags & MFE_UNDERWATER) then
    player.charability = CA_SWIM
else
    player.charability = CA_NONE
       end
    end
end)
replace mechatails with the desired skin name and "CA_NONE" with your desired land ability.
 

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

Back
Top