Sapheros
Member
Okay, so I'm trying to lua the old Hinote 2.0 wad and give her some moves...
Here is her code, it only has the peelout, jumpthok, ability-to-turn-super, recover, and uncurl script:
My main goal is trying to do 2 things: 1. trying to use her other sprites from her Flare Jump, Basically using those sprites while she Jump Thoks and Using Fire Sprites as projectiles and for abilities like her Jump Thok. And 2. Having a shorter underwater time.
All I'm looking for is how to assign sprites with lua.
I'll appreciate any and all help.
Here is her code, it only has the peelout, jumpthok, ability-to-turn-super, recover, and uncurl script:
Code:
--Jump Thok ability, version 2.0
--Porting started by Wolfy, but Sryder13 did pretty much all of 2.0, so he gets all the credit for this one
--Original Riders coding by Chaos Zero 64
--To switch the script's selected skin, scroll down to the mobjthinker hook near the bottom.
-- This was directly taken from what I did for Rosy
-- Copied from the exe because otherwise it will return false when it should've returned true when transforming
local function LuaSuperReady(player)
if ((player.pflags & PF_SUPERREADY) and not player.powersuper and not player.powers[pw_tailsfly]
and not (player.powers[pw_shield] & SH_NOSTACK)
and not player.powers[pw_invulnerability]
and not (maptol & TOL_NIGHTS) -- don't turn 'regular super' in nights levels
and player.pflags & PF_JUMPED
and ((player.charflags & SF_SUPER) or All7Emeralds(player.powers[pw_emeralds])))
return true;
else
return false;
end
end
-- This function is mostly stuff taken from the exe and converted to lua
local function CheckIfCanUseAbility(player)
if (player.cmd.buttons & BT_JUMP
and not (player.previouspflags & PF_JUMPDOWN) -- They aren't holding the jump button down are they?
and player.previouspflags & PF_JUMPED -- Make sure they have actually jumped already
and not player.exiting and not P_PlayerInPain(player)
and not LuaSuperReady(player))
--if (P_InQuickSand(player.mo)) -- This doesn't work yet, re-enable when it does to make this work properly, can't even be remade because it uses FOF's
--return false;
--end
if (P_IsObjectOnGround(player.mo) or player.climbing or (player.previouspflags & (PF_CARRIED|PF_ITEMHANG|PF_ROPEHANG)))
return false;
elseif ((player.previouspflags & PF_MACESPIN) and player.previoustracer)
return false;
elseif (not (player.previouspflags & PF_SLIDING) and ((gametype != GT_CTF) or (not player.gotflag)))
return true;
end
end
return false;
end
-- Another lua conversion from SRB2 code
local function LuaSpawnThokMobj(player) --spawns thok mobjs, supports custom thokitems
local mobj;
local type = player.thokitem;
local zheight;
if (player.skincolor == 0)
return;
end
if (player.spectator)
return;
end
if (type == MT_GHOST)
mobj = P_SpawnGhostMobj(player.mo); -- virtually does everything here for us
else
if (player.mo.eflags & MFE_VERTICALFLIP)
zheight = player.mo.z + player.mo.height + FixedDiv(P_GetPlayerHeight(player) - player.mo.height, 3*FRACUNIT) - FixedMul(mobjinfo[type].height, player.mo.scale);
else
zheight = player.mo.z - FixedDiv(P_GetPlayerHeight(player) - player.mo.height, 3*FRACUNIT);
end
if (not (player.mo.eflags & MFE_VERTICALFLIP) and zheight < player.mo.floorz and not(mobjinfo[type].flags & MF_NOCLIPHEIGHT))
zheight = player.mo.floorz;
elseif (player.mo.eflags & MFE_VERTICALFLIP and zheight + FixedMul(mobjinfo[type].height, player.mo.scale) > player.mo.ceilingz and not(mobjinfo[type].flags & MF_NOCLIPHEIGHT))
zheight = player.mo.ceilingz - FixedMul(mobjinfo[type].height, player.mo.scale);
end
mobj = P_SpawnMobj(player.mo.x, player.mo.y, zheight, type);
-- set to player's angle, just in case
mobj.angle = player.mo.angle;
-- set to player color and skin
mobj.color = player.mo.color;
mobj.skin = player.mo.skin;
-- vertical flip
if (player.mo.eflags & MFE_VERTICALFLIP)
mobj.flags2 = $1|MF2_OBJECTFLIP;
end
mobj.eflags = $1|(player.mo.eflags & MFE_VERTICALFLIP);
-- scale
P_SetScale(mobj, player.mo.scale);
mobj.destscale = player.mo.scale;
end
mobj.target = player.mo; -- the one thing P_SpawnGhostMobj doesn't do
end
-- if thoksound is replaced with true, thoksound will play. otherwise, no sound for you.
local function DoPlayerJumpThok(player, thoksound) --performs jumpthok.
if not (player.previouspflags & (PF_ROPEHANG|PF_CARRIED|PF_ITEMHANG|PF_MACESPIN))
local actionspd = player.actionspd; --for ease of typing
if (player.mo.eflags & MFE_UNDERWATER) --yay you're underwater! slow down.
actionspd = $1 >> 1; -- half speed, don't know why bitshift was used
end
if (actionspd > player.normalspeed) --if you're too fast
actionspd = player.normalspeed --SLOW DOWN.
end
--actionspd = $1 / 3; --(BALANCE)TD leftover. makes the jumpthok execute slower, so the thrust is less instant.
P_InstaThrust(player.mo, player.mo.angle, FixedMul(actionspd, player.mo.scale)); -- ZOOM
if (not(player.pflags & PF_THOKKED) -- Never do the jump more than once, even if you have multiability
and player.thokitem == mobjinfo[MT_PLAYER].painchance) -- This is so that custom characters that like to use the thokitem don't break
player.pflags = $1&~PF_JUMPED
P_DoJump(player, false)
end
if (player.mo.info.attacksound and not player.spectator and thoksound) --if thoksound argument is true
S_StartSound(player.mo, player.mo.info.attacksound); -- Play the THOK sound
end
LuaSpawnThokMobj(player); -- Spawn the thok mobjs
player.pflags = $1&~PF_SPINNING; -- Not spinning or revving anymore
player.pflags = $1&~PF_STARTDASH
player.pflags = $1|PF_THOKKED; -- They thokked!
if (maptol & TOL_2D) --if in 2D/SRB1
player.mo.momx = $1/2 --slow momentum down, make it more controllable
player.mo.momy = $1/2 --same with y momentum for balance
end
--player.mo.momy = $1/3 --(BALANCE)from homing version, reduces momentum upon execution
--player.mo.momx = $1/3
end
end
addHook("MobjThinker", function(mobj)
if mobj.player --Affects players only.
local player = mobj.player
-- initialise the extra variables he'll be using
-- These need to be here because they'll be being compared later
-- It is ONLY safe to do this, otherwise jumpthok cannot be added mid-game and keep functionality
if (player.previouspflags == nil)
player.previouspflags = PF_JUMPDOWN;
end
if (player.powersuper == nil) -- Used to check if the player is not already super(just turned super) in LuaSuperReady()
player.powersuper = 0;
end
if (player.mo and player.mo.skin == "hinote") -- skin restriction
player.charability = CA_NONE
if not (player.pflags & PF_NIGHTSMODE)
if (CheckIfCanUseAbility(player) and (not (player.pflags & PF_THOKKED) or player.ability2 == CA2_MULTIABILITY)) -- If they can use their ability and haven't already.
if (not(player.homing)) -- Not already homing, leftover from homing version
DoPlayerJumpThok(player, true);
end
end
end
--[[if (player.mo.momz < 0)
and (player.pflags & PF_THOKKED)
and not (player.mo.state >= S_PLAY_FALL1 and player.mo.state <= S_PLAY_FALL2)
player.pflags = $1 & ~PF_JUMPED
player.mo.state = S_PLAY_FALL1
end ]]
--optional riders fall code. to use, remove the --[[ and ]].
end
player.previouspflags = player.pflags;
player.powersuper = player.powers[pw_super];
end
end, MT_PLAYER)
addHook("ThinkFrame", do
for player in players.iterate
if player.mo and player.mo.skin == "hinote"
if not (player.pflags & PF_NIGHTSMODE)
and not (player.pflags & (PF_ROPEHANG|PF_CARRIED|PF_ITEMHANG|PF_MACESPIN))
and not (player.exiting)
and not (player.pflags & PF_SLIDING)
and not (player.pflags & PF_TIMEOVER)
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_JUMPDOWN)
and not (player.mo.state == S_PLAY_SPRING)
and not (player.mo.state == S_PLAY_FALL1)
and not (player.mo.state == S_PLAY_FALL2)
and not (player.mo.state == S_PLAY_DIE)
and not (player.mo.state == S_PLAY_PAIN)
and not (player.mo.state == S_PLAY_ATK1)
and not (player.mo.state == S_PLAY_ATK2)
and not (player.mo.state == S_PLAY_ATK3)
and not (player.mo.state == S_PLAY_ATK4)
and not (player.weapondelay)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
and not P_IsObjectOnGround(player.mo)
and not player.climbing
and not (player.mo.state == S_PLAY_ABL1)
and not (player.mo.state == S_PLAY_ABL2)
and not (player.mo.state == S_PLAY_SPC1)
and not (player.mo.state == S_PLAY_SPC2)
and not (player.mo.state == S_PLAY_SPC3)
and not (player.mo.state == S_PLAY_SPC4)
player.mo.state = S_PLAY_FALL1
end
end
end
end)
addHook("MobjSpawn", function(mo) mo.recovering = 0 end, MT_PLAYER)
addHook("ThinkFrame", do
for player in players.iterate
if player.mo and player.mo.skin == "hinote"
if not (player.pflags & PF_NIGHTSMODE)
and (player.cmd.buttons & BT_USE)
and not (player.pflags & (PF_ROPEHANG|PF_CARRIED|PF_ITEMHANG|PF_MACESPIN))
and not (player.exiting)
and (player.mo.state == S_PLAY_PAIN)
and not (player.mo.state == S_PLAY_DIE)
and not (player.pflags & PF_SLIDING)
and not (player.pflags & PF_SPINNING)
and not (player.pflags & PF_TIMEOVER)
and not (player.pflags & PF_JUMPED)
and not (player.pflags & PF_JUMPDOWN)
and not (player.pflags & PF_JUMPSTASIS)
and not (player.mo.state == S_PLAY_ATK1)
and not (player.mo.state == S_PLAY_ATK2)
and not (player.mo.state == S_PLAY_ATK3)
and not (player.mo.state == S_PLAY_ATK4)
and not (player.weapondelay)
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
and not P_IsObjectOnGround(player.mo)
and (player.mo.recovering == 0)
P_SetObjectMomZ(player.mo, FRACUNIT*10, false)
player.mo.state = S_PLAY_ATK1
player.pflags = $1|PF_JUMPED
S_StartSound(player.mo, sfx_jump)
player.mo.recovering = 1
end
if player.mo.recovering == 1
and not (player.cmd.buttons & BT_USE)
player.mo.recovering = 0
end
end
end
end)
freeslot("S_PLAY_PEEL1", "S_PLAY_PEEL2", "S_PLAY_PEEL3", "S_PLAY_PEEL4")
states[S_PLAY_PEEL1] = {SPR_PLAY, 16, 1, nil, 0, 0, S_PLAY_PEEL2}
states[S_PLAY_PEEL2] = {SPR_PLAY, 17, 1, nil, 0, 0, S_PLAY_PEEL3}
states[S_PLAY_PEEL3] = {SPR_PLAY, 18, 1, nil, 0, 0, S_PLAY_PEEL4}
states[S_PLAY_PEEL4] = {SPR_PLAY, 19, 1, nil, 0, 0, S_PLAY_PEEL1}
addHook("MobjSpawn", function(mo) mo.peelout = 0 end, MT_PLAYER)
addHook("MobjSpawn", function(mo) mo.peel = 0 end, MT_PLAYER)
addHook("MobjSpawn", function(mo) mo.out = 0 end, MT_PLAYER)
addHook("ThinkFrame", do
for player in players.iterate
if player.mo and player.mo.skin == "hinote" then
if (player.cmd.buttons & BT_CUSTOM1)
if P_IsObjectOnGround(player.mo)
and player.speed == 0
and not (player.pflags & PF_SPINNING)
and not (player.pflags & PF_STARTDASH)
if player.mo.peelout == 0
S_StartSound(player.mo, sfx_spin)
player.mo.peelout = 1
player.mo.out = 1
end
if player.mo.peelout == 1
if not (player.mo.state >= S_PLAY_PEEL1)
and (player.mo.state <= S_PLAY_PEEL4)
player.mo.state = S_PLAY_PEEL1
end
end
end
end
if not (player.cmd.buttons & BT_CUSTOM1)
and player.mo.peelout == 1
and P_IsObjectOnGround(player.mo)
player.mo.state = S_PLAY_SPD1
S_StartSound(player.mo, sfx_zoom)
P_InstaThrust(player.mo, player.mo.angle, 70*FRACUNIT)
player.mo.peelout = 0
player.mo.peel = 1
player.mo.out = 1
end
if player.pflags & PF_JUMPED
player.mo.peelout = 0
player.mo.peel = 0
player.mo.out = 1
end
if not (player.cmd.buttons & BT_CUSTOM1)
and player.peelout == 1
end
if (player.cmd.buttons & BT_CUSTOM1)
and P_IsObjectOnGround(player.mo)
player.normalspeed = 0
else
player.normalspeed = 36*FRACUNIT
end
if player.mo.out == 1
and player.speed >= 40*FRACUNIT
player.mo.out = 0
end
if player.speed >= 40*FRACUNIT
and player.panim == PA_RUN
and player.mo.peel == 1
and not player.powers[pw_sneakers]
P_SpawnGhostMobj(player.mo)
end
if player.speed < 40*FRACUNIT
and player.mo.out == 0
player.mo.peel = 0
end
if (player.speed > 50*FRACUNIT) // checks the players speed
and player.mo.peel == 1
and not (player.pflags & PF_SLIDING)
and not (player.pflags & (PF_ROPEHANG|PF_CARRIED|PF_ITEMHANG|PF_MACESPIN))
and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
and not player.powers[pw_super]
and not (P_CheckDeathPitCollide(player.mo))
and not (player.mo.state == S_PLAY_PAIN)
player.mo.friction = FRACUNIT-60
end
if player.mo.peelout == 1
and (player.pflags & PF_SPINNING)
and (player.pflags & PF_STARTDASH)
player.mo.peelout = 0
end
end
end
end)
addHook("MobjThinker", function(char)
if (char.skin == "hinote")
and not (char.player.charflags & SF_SUPER)
char.player.charflags = $1|SF_SUPER
end
end, MT_PLAYER)
All I'm looking for is how to assign sprites with lua.
I'll appreciate any and all help.
Last edited: