SRB2 Message Board  

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

Reply
 
Thread Tools Search this Thread
Old 02-13-2015   #1
"Lat'"
Stop it
 
"Lat'"'s Avatar
Default A quick question.

The title. How can I make it so hurt players lose only 1 Ring instead of all of them? (Obviously Lua, I guess.)
Thanks in advice.
__________________
Quote:
Originally Posted by Bronydude2k5 View Post
If you make me a Sash Lilac wad, I'll make you a sonic sprite hack of any choice.
"Lat'" is offline   Reply With Quote
Old 02-13-2015   #2
fickleheart
ms reflec beat stan
 
fickleheart's Avatar
Default

Set up a MobjDamage hook for MT_PLAYER and wire in the code you want, then return true at the end to override the normal damage effect. You'll have to re-create the standard effects you want, but the knockback is as easy as calling P_DoPlayerPain(mo, inflictor, source) or something like that, then you can spawn an MT_FLINGRING, send it flying out how you want, and subtract one from mo.health and mo.player.health.
__________________
OK Google, define "hubris".
fickleheart is offline   Reply With Quote
Old 02-13-2015   #3
Zipper
Soulja boy I tell 'em
Judge
 
Zipper's Avatar
Default

Code:
local function RingLoss (me, bomb, bombguy, pain)
	if not me.player
		return false // this used to limit it to one skn, I guess I can use this as a validity check?
	end

	local player = me.player // let's make things easier and use this as a shortcut to writing me.player.anything!

	P_DoPlayerPain(player, bombguy, bomb) // send yourself into the pain animation
	S_StartSound(player.mo, sfx_s3kb9) //hurt sound
	
	player.health = max($1 - pain, 0) // remove damage from health, set to 0 if this goes under 0!
	me.health = $1 - pain // do the same for the mobj part of the player, doesn't matter about keeping it above 0 apparently
	P_PlayerRingBurst(player,1) //spill a ring
	
	if me.health < 1
		P_DamageMobj(me, bomb, bombguy,10000)
		P_KillMobj(me,bomb,bombguy)
		return true // you're dead, that's it, no point to continuing!
	end
	return true // that's it, we just end P_DamageMobj right here, nothing else happens with damaging after this
end
addHook("MobjDamage", RingLoss, MT_PLAYER)
Ripped straight from Quickman, then did a few adjustments on it to suit your needs. Thankfully MonsterIestyn had done all the commenting beforehand so you can understand what's going on easily.

(pain is by default 1 btw)
__________________
Quote:
<MonsterIestyn> surely it's good ass though
Zipper is offline   Reply With Quote
Old 02-13-2015   #4
"Lat'"
Stop it
 
"Lat'"'s Avatar
Default

Quote:
Originally Posted by Zipper View Post
Code:
Insert lua code here.
Ripped straight from Quickman, then did a few adjustments on it to suit your needs. Thankfully MonsterIestyn had done all the commenting beforehand so you can understand what's going on easily.

(pain is by default 1 btw)
Thanks, this skips me a lot of work ^^
I guess I'll have to learn Lua more, because even if I understood most of the things in there I couldn't do it myself ><
Anyway I guess this solves my problem
__________________
Quote:
Originally Posted by Bronydude2k5 View Post
If you make me a Sash Lilac wad, I'll make you a sonic sprite hack of any choice.
"Lat'" is offline   Reply With Quote
Old 02-13-2015   #5
gregory_house
ʇxǝʇ pǝddᴉlɟ ɹɐoɯ ɥʇᴉʍ ʍoN
 
gregory_house's Avatar
Default

There's also something else to consider, the script above needs a condition so that it can also work when the player that's been hit has a shield.

Plus remember that getting hit in match won't award points to whoever hits you, or show a text saying how you got hit, or have the typical knockback of the weapon used on you, unless all these things are added in the script too.

And the last part of the script that runs only if me.health < 1 isn't really needed, I'd rather have the "hit" part of the script run only if you have at least one ring.



EDIT: Would making the player have only one ring as he gets hit be a valid alternative?
Code:
local function RingLoss (me)
    if not me.player or me.player.health == 1 or me.player.powers[pw_shield] != 0
        return false // 
    end
 
        me.player.lastrings = me.player.health //
        me.player.health = 2 // 
    me.health = 2 // 
    me.player.playerhit = 1 //
    return false // 
end
addHook("MobjDamage", RingLoss, MT_PLAYER)
addHook("ThinkFrame", function ()
        for player in players.iterate
                if player.playerhit == 1
                      player.health = player.lastrings - 1
                      player.mo.health = player.lastrings - 1
                      player.playerhit = 0
                end 
        end
end)
__________________
Intel i7-4770K - ASUS GTX970 4GB OC - 2x8GB Dominator Platinum @1866 CL10 - Samsung 840PRO 256GB

Last edited by gregory_house; 02-13-2015 at 09:51 PM.
gregory_house 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 09:04 PM.


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