how can this work

redhot69

amongus
i was trying to code with ai and got this code trying to do an upward thingy thok
addHook("PlayerThink", function(p)
if p.mo.skin ~= "sonic"
if (p.pflags & PF_JUMPED)
and (p.cmd.buttons & BT_JUMP) then
S_StartSound(p.mo, sfx_s3k75)
local boost = 5 * FRACUNIT
local upwardBoost = 6 * FRACUNIT
local angle = p.mo.angle
p.mo.momx = p.mo.momx + FixedMul(boost, cos(angle))
p.mo.momy = p.mo.momy + FixedMul(boost, sin(angle))
p.mo.momz = p.mo.momz + upwardBoost
end
end
end)
 
Allow me to reformat what the AI wrote for you to make it a bit cleaner to read...
The AI's code:
addHook("PlayerThink", function(p)
    if p.mo.skin ~= "sonic"
        if (p.pflags & PF_JUMPED)
        and (p.cmd.buttons & BT_JUMP) then
            S_StartSound(p.mo, sfx_s3k75)
            local boost = 5 * FRACUNIT
            local upwardBoost = 6 * FRACUNIT
            local angle = p.mo.angle
            p.mo.momx = p.mo.momx + FixedMul(boost, cos(angle))
            p.mo.momy = p.mo.momy + FixedMul(boost, sin(angle))
            p.mo.momz = p.mo.momz + upwardBoost
        end
    end
end)
Gotta hand it to the AI, it actually did a pretty good job here! All you need to do is put this code in a .lua file and you should be able to load it up in-game.

Though, it's still not perfect, of course. First off, it looks like it's checking if the player is not playing as Sonic, has jumped and is holding down Jump. Two weird things here:
  1. Surely you mean that you want this ability to be exclusive to Sonic? That'd be ==, not ~= on line 2.
  2. The whole "has jumped and is pressing Jump" biz is a bit weird. A different Hook already exists for that - it's called AbilitySpecial.
Second, I'll admit that this is a clever solution to the actual 'jumpthok' part, but it could be better. Functions already exist for modifying the player's momentum without directly touching the momx, momy and momz variables.
 
Allow me to reformat what the AI wrote for you to make it a bit cleaner to read...
The AI's code's code:
addHook("PlayerThink", function(p)
    if p.mo.skin ~= "sonic"
        if (p.pflags & PF_JUMPED)
        and (p.cmd.buttons & BT_JUMP) then
            S_StartSound(p.mo, sfx_s3k75)
            local boost = 5 * FRACUNIT
            local upwardBoost = 6 * FRACUNIT
            local angle = p.mo.angle
            p.mo.momx = p.mo.momx + FixedMul(boost, cos(angle))
            p.mo.momy = p.mo.momy + FixedMul(boost, sin(angle))
            p.mo.momz = p.mo.momz + upwardBoost
        end
    end
end)
Gotta hand it to the AI, it actually did a pretty good job here! All you need to do is put this code in a .lua file and you should be able to load it up in-game.

Though, it's still not perfect, of course. First off, it looks like it's checking if the player is not playing as Sonic, has jumped and is holding down Jump. Two weird things here:
  1. Surely you mean that you want this ability to be exclusive to Sonic? That'd be ==, not ~= on line 2.
  2. The whole "has jumped and is pressing Jump" biz is a bit weird. A different Hook already exists for that - it's called AbilitySpecial.
Second, I'll admit that this is a clever solution to the actual 'jumpthok' part, but it could be better. Functions already exist for modifying the player's momentum without directly touching the momx, momy and momz variables.
i believe ai is using lua based coding similar to like roblox or some shit i could be wrong tho
 

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

Back
Top