addHook("ThinkFrame", function(p)
for p in players.iterate
if p.mo and p.mo.skin == "knuckles" --character that will play the sound
if not P_PlayerInPain(p)
p.readytodosound = 1
p.dosound = 0
elseif p.readytodosound
p.dosound = 1
p.readytodosound = 0
else
p.dosound = 0
end
if p.dosound
S_StartSound(p.mo, sfx_buzz3)
end
end
end
end)
Thanks, i've couldn't finish my idea WAD without your help. Not sure if i can release it on here or Sapheros' homepage.Or, you can do that in Lua:
"sfx_buzz3" is the sound that will be played, and to make it play once, you need to make a custom variable like I did.Code:addHook("ThinkFrame", function(p) for p in players.iterate if p.mo and p.mo.skin == "knuckles" --character that will play the sound if not P_PlayerInPain(p) p.readytodosound = 1 p.dosound = 0 elseif p.readytodosound p.dosound = 1 p.readytodosound = 0 else p.dosound = 0 end if p.dosound S_StartSound(p.mo, sfx_buzz3) end end end end)
P_PlayerDoPain, is the action when the player gets hurt.
EDIT: You always need to use the "sfx_" to use a sound, example, if you want to use the sound "DSBUZZ3" , you will write "sfx_buzz3" I mean, without the "DS", also, can be any sound, including custom ones. I hope this helped you.
Anyway, remember, if you want to use it with another character, replace "knuckles" with the character's SKIN NAME like: "skinname" .
Or, you can do that in Lua
At least the LUA method works fine. I'm really satisfied with the result.Lua has horrible overhead. Something that can be done purely in SOC should be done in SOC.
Lua has horrible overhead. Something that can be done purely in SOC should be done in SOC.
At least the LUA method works fine. I'm really satisfied with the result.
// playerow, the function that actually contains the code we want to run when the player is damaged
//
// target is the mobj_t that was hurt (in this case of course, this should be you)
// inflictor is the mobj_t that dealt the damage
// source is the mobj_t that spawned the inflictor, if it is not the inflictor itself
// damage is the amount of damage that was dealt to "target"
//
// in this example only "target" really matters though, but you can take advantage of the above arguments for alternative sounds perhaps
//
local function playerow(target, inflictor, source, damage)
if target.skin == "knuckles" // is this player using the knuckles skin?
S_StartSound(target, sfx_example) // if so, play a sound!
end
end
// Now, we use addHook to link the function above to the damaging code
// "MobjDamage" is a hook to link a function call to the damaging code, specifically after the game has decided yes the object should definitely be hurt
// playerow of course is the function defined above
// the final argument of addHook for this kind of hook determines what type of object "target" should be in order for the function to run;
// in this case it should only affect players who were damaged, which is why it is set to "MT_PLAYER" here
//
addHook("MobjDamage", playerow, MT_PLAYER)