SRB2 Message Board  

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

Reply
 
Thread Tools Search this Thread
Old 3 Weeks Ago   #1
LunarDestroyer
 
LunarDestroyer's Avatar
Default Spilled Rings

Is there any way to get the mobj number of the player's spilled rings when they get hit? (In the same sort of manner that you can get the mobj number of an object spawned via P_SpawnMobj)
LunarDestroyer is offline   Reply With Quote
Old 3 Weeks Ago   #2
Lach
what the thok mate??
 
Lach's Avatar
Default

I'm not quite sure what you mean by "mobj number," but I'm assuming you're looking to be able to modify rings that are spilt by the player? I've done some work with spilled rings in the past so maybe this will help.

Hooks like MobjDamage execute as soon as P_DamageMobj is used, which happens to be before the rings are lost—so if you want to find the number of rings the player will spill, simply find player.health - 1 in a MobjDamage hook for MT_PLAYER. If you instead want to modify rings once they are spilled, you can use a MobjThinker hook for MT_FLINGRING. They conveniently set their target to the player that spilled them, so you can use mobj.target to find the player that spilled that flingring! MobjSpawn might be more efficient depending on what you're trying to do but unfortunately that occurs before the ring sets its target to the player, so its use is limited.

Hopefully that answers your question, but if not could you be a little more specific? :)
__________________
My recently released addons:
Player-Colored Weapon Rings
Combine Ring Monitor
Lach is offline   Reply With Quote
Old 3 Weeks Ago   #3
LunarDestroyer
 
LunarDestroyer's Avatar
Default

I'm attempting to remake the Combi Ring powerup (the one that makes you drop one big ring when you get hit, with the value of all the rings you lost), or at least, it's effects.

With what you've told me, I was able to modify the ring's attributes (it's scale, and adding a variable for it's worth), but now I'm having trouble with the TouchSpecial part of it, for when the player actually goes to pick the ring up.

Quote:
addHook("TouchSpecial", function(mobj,toucher)
if mobj.ringvalue != nil
toucher.health = $1 + mobj.ringvalue
toucher.player.health = $1 + mobj.ringvalue
end
end, MT_FLINGRING)
The problem is that the moment the player gets hit, the code runs while the ring is still flying away, each frame, causing the player to gain hundreds of rings. I think there might be a way to stop that via checking player.losstime, but I'm not sure how to go about calculating that, or if there's a better way.
LunarDestroyer is offline   Reply With Quote
Old 3 Weeks Ago   #4
Lach
what the thok mate??
 
Lach's Avatar
Default

Well hey, speak of the devil. That is the exact modification I was working on myself. Let me know if you'd like to take a look at it.

In any case, the best way to do this (and the way that I did it) is to put that code in a MobjDeath hook rather than a TouchSpecial, so that it only occurs when the ring actually "dies" (since the player "kills" the ring when touching it). Don't forget the ring itself will count as a ring when adding to the total, although maybe you accounted for that already.
__________________
My recently released addons:
Player-Colored Weapon Rings
Combine Ring Monitor
Lach is offline   Reply With Quote
Old 3 Weeks Ago   #5
Monster Iestyn
Friendly Neighbour-Hood
Moderator
 
Monster Iestyn's Avatar
Default

Try P_CanPickupItem(toucher.player), it's the function MT_RING and MT_FLINGRING objects use themselves to prevent themselves being picked up after being created, or in general when the player is flashing after being hurt.

Basically it checks the player's pw_flashing to determine whether the item can be picked up or not.

Last edited by Monster Iestyn; 3 Weeks Ago at 08:38 PM.
Monster Iestyn is offline   Reply With Quote
Old 3 Weeks Ago   #6
LunarDestroyer
 
LunarDestroyer's Avatar
Default

Yeah, P_CanPickupItem works like a charm. With that, it seems to work perfectly! Thank you to the both of you for helping me out with this.
LunarDestroyer is offline   Reply With Quote
Old 3 Weeks Ago   #7
Lach
what the thok mate??
 
Lach's Avatar
Default

I still recommend using the MobjDeath hook as it is more efficient (since the game only runs the code on the single frame the ring dies as opposed to every frame it is touched), but I'm glad you got it to work either way! No problem.
__________________
My recently released addons:
Player-Colored Weapon Rings
Combine Ring Monitor
Lach 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 06:48 AM.


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