SRB2 Message Board  

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

Reply
 
Thread Tools Search this Thread
Old 04-19-2020   #1
Goldenhog
Wandering Protagonist
 
Goldenhog's Avatar
Default Help with fake invincibility

Code:
addHook("ShouldDamage", function(mo,inf,src)
	if (inf or src)
	or P_PlayerTouchingSectorSpecial(mo.player,1,1)
	or P_PlayerTouchingSectorSpecial(mo.player,1,2)
	or P_PlayerTouchingSectorSpecial(mo.player,1,3)
	or P_PlayerTouchingSectorSpecial(mo.player,1,4)
	or P_PlayerTouchingSectorSpecial(mo.player,1,5)
		return false
	end
end, MT_PLAYER)
This is the code I have. It's meant to make the player invulnerable to contact damage, projectiles and non-instakill damage sectors. It works, except when it comes to linedefs. For some reason, standing on lava functions fine but touching a lavafall or walking off of a lava FOF results in damage. Same with spike sectors (i know these are not to be used anymore i was just using an old map for testing) - standing on them works, walking off of them results in damage. Same with THZ's electric floors, etc.
__________________
Quote:
Originally Posted by Asagi Asagiri
I need power over the people! The stupid, STUPID people!
Goldenhog is offline   Reply With Quote
Old 04-20-2020   #2
Lach
nanananananananananananan a
Moderator
 
Lach's Avatar
Default

As of 2.2, ShouldDamage hooks have a fifth function argument for damage types (target, inflictor, source, damage, damagetype). You may find it easier to block specific types or masks of damage rather than check for sector types. https://wiki.srb2.org/wiki/Constants..._.28DMG_.2A.29
Lach is offline   Reply With Quote
Old 04-21-2020   #3
Goldenhog
Wandering Protagonist
 
Goldenhog's Avatar
Default

Yup, that works perfectly. Thanks for the save!

The code as it looks now, for anyone curious:

Code:
addHook("ShouldDamage", function(mo,inf,src,dmg,dmgtype)
	if (inf or src)
	or not dmgtype // (protects from generic-type damage sectors)
	or dmgtype == DMG_WATER
	or dmgtype == DMG_FIRE
	or dmgtype == DMG_ELECTRIC
	or dmgtype == DMG_SPIKE
		return false
	end
end, MT_PLAYER)
__________________
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 08:37 AM.


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