SRB2 Message Board  

Go Back   SRB2 Message Board > Sonic Robo Blast 2 > Editing > Editing Help

Reply
 
Thread Tools Search this Thread
Old 06-04-2018   #1
Goldenhog
Wandering Protagonist
 
Goldenhog's Avatar
Default Altering player collision with a particular enemy

I have this enemy whom I want to make the player bounce higher than usual and force them out of their spinning frames when they bop it. I'd also like it if this enemy didn't award the player points or release a flicky when destroyed. The former could (maybe?) be done by placing a custom Lua action in the enemy's death frames that grabs the nearest player, A_ZThrusts them upwards and forces their state to S_PLAY_FALL1, but I have no idea where to start with the latter (making the enemy award no points and stopping flickies from appearing).
__________________
Quote:
Originally Posted by Asagi Asagiri
I need power over the people! The stupid, STUPID people!
Goldenhog is offline   Reply With Quote
Old 06-04-2018   #2
742mph
My work is never done yet
 
742mph's Avatar
Default

If a Lua function added to the MobjDeath hook returns true, it'll override the killed object's default death behavior.
__________________
Quote:
<Evilgasm> the opposite of egoraptor is Toa Tahu
742mph is offline   Reply With Quote
Old 06-04-2018   #3
Goldenhog
Wandering Protagonist
 
Goldenhog's Avatar
Default

That sounds just like what I need. Sadly the last time I worked with hooks was years ago (the only thing I'm using Lua for right now is to call functions and actions to do the actual job for me) so I'm a bit out of my depth here.

Code:
local function walkerbounce(target,inflictor,source)
    if inflictor.player
        P_DoPlayerPain(inflictor.mo,target,target)
        return true
    end
end

addHook("MobjDeath", walkerbounce, MT_WALKER)
From what I read in the wiki pages and surmised from my old Gravity Shield code, this should be working? It calls the function walkerbounce when MT_WALKER is destroyed, which then checks if the thing that destroyed it is a player and then should have the player get hit (to test if it's working) with no other effects like points or flickies. But in-game it's all behaving the same as if this code wasn't here at all.
__________________
Quote:
Originally Posted by Asagi Asagiri
I need power over the people! The stupid, STUPID people!
Goldenhog is offline   Reply With Quote
Old 06-04-2018   #4
Zwip-Zwap Zapony
Please just call me Zappy.
 
Zwip-Zwap Zapony's Avatar
Default

Quote:
Originally Posted by Goldenhog View Post
Code:
local function walkerbounce(target,inflictor,source)
    if inflictor.player
        P_DoPlayerPain(inflictor.mo,target,target)
        return true
    end
end
 addHook("MobjDeath", walkerbounce, MT_WALKER)
From what I read in the wiki pages and surmised from my old Gravity Shield code, this should be working? -
It shouldn't be working. You accidentally wrote "inflictor.mo" instead of "inflictor.player" in the P_DoPlayerPain function (the function expects a player, not an object), and if the first player uses player node 0, you should probably check something like "if inflictor.player.valid" instead of "if inflictor.player" (as 0 is considered false by "if" checks).
Zwip-Zwap Zapony is offline   Reply With Quote
Old 06-04-2018   #5
Goldenhog
Wandering Protagonist
 
Goldenhog's Avatar
Default

Thanks for the heads up, but those alone didn't help.

But I did manage to figure it out. The game wasn't entering the hook at all (I added a print to the hook before the if and sure enough it was never getting fired). It does enter the hook if I leave MT_WALKER out or replace it MT_NULL, and if I add additional checks to see if target is the right type then it all works properly.

And it's all the fault of the game running Lua scripts before SOC ones. If I move declaring MT_WALKER from the MAINCFG to the lump where the Lua code is, then having MT_WALKER at the end of the addHook like I did before works like it should.

Anyway, thanks to the both of you for the help.
__________________
Quote:
Originally Posted by Asagi Asagiri
I need power over the people! The stupid, STUPID people!
Goldenhog is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:35 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.