Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.
New to the forum? Say hello in this topic! Also make sure to read the rules.
New to the forum? Say hello in this topic! Also make sure to read the rules.
Be able to set IPlayer behavior when received enough overkill damage
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
-
- Superfighter
- Posts: 97
- Joined: Thu Feb 07, 2019 4:36 am
Be able to set IPlayer behavior when received enough overkill damage
Context: when using IPlayer.SetHitEffect(PlayerHitEffect.Metal) to make robot-like sound effect for player. After the player died and received enough overkill damage, it bursts into blood and gore which breaks the immersion. I'd like something like IPlayer.SetDestroyAnimation() where I can determine if the IPlayer explodes into gore or into metal pieces like the streetsweeper or something.
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 26
Sometimes you just need to think a little bit out of the box, here is the code to replace giblets with metal debris randomly set on fire, plus some effects to try to cover the blood sprite:NearHuscarl wrote: ↑Wed Aug 07, 2019 2:22 amContext: when using IPlayer.SetHitEffect(PlayerHitEffect.Metal) to make robot-like sound effect for player. After the player died and received enough overkill damage, it bursts into blood and gore which breaks the immersion. I'd like something like IPlayer.SetDestroyAnimation() where I can determine if the IPlayer explodes into gore or into metal pieces like the streetsweeper or something.
Code: Select all
Vector2 BL, TR;
bool MetalGibbing = false;
Random RNG = new Random();
const int GIB_AREA_SIZE = 15;
List < String > DebrisList = new List < String > {
"MetalDebris00A",
"MetalDebris00B",
"MetalDebris00C",
"MetalDebris00D",
"MetalDebris00E"
};
public void OnStartup() {
Events.PlayerDeathCallback.Start(OnPlayerDeath);
Events.UpdateCallback.Start(OnUpdate);
}
public void OnPlayerDeath(IPlayer player, PlayerDeathArgs args) {
if (args.Removed) {
Vector2 pos = player.GetWorldPosition();
BL = new Vector2(pos.X - (GIB_AREA_SIZE / 2), pos.Y - (GIB_AREA_SIZE / 2));
TR = new Vector2(pos.X + (GIB_AREA_SIZE / 2), pos.Y + (GIB_AREA_SIZE / 2));
Game.PlayEffect("BulletHitMetal", player.GetWorldPosition());
for (int i = 0; i < 10; i++)
Game.PlayEffect("S_P", player.GetWorldPosition());
Game.PlayEffect(" EXP", player.GetWorldPosition());
MetalGibbing = true;
}
}
public void OnUpdate(float elapsed) {
if (MetalGibbing) {
foreach(IObject Giblet in Game.GetObjectsByArea(new Area(BL, TR))) {
if (Giblet.Name.StartsWith("Gib")) {
IObject debris = Game.CreateObject(RandomDebris(), Giblet.GetWorldPosition(), Giblet.GetAngle(), Giblet.GetLinearVelocity(), Giblet.GetAngularVelocity());
if (RNG.Next(0, 101) < 50)
debris.SetMaxFire();
Giblet.Remove();
}
}
MetalGibbing = false;
}
}
String RandomDebris() {
return DebrisList[RNG.Next(0, DebrisList.Count())];
}
0 x
-
- Superfighter
- Posts: 97
- Joined: Thu Feb 07, 2019 4:36 am
I thought about that workaround, but the giblet objects still appear like 1 frame before being removed. You can still see the blood effect, that's what annoys me. But I will keep that solution in mind if they cannot add my suggestions for whatever reasons
0 x
- Danger Ross
- Superfighter
- Posts: 154
- Joined: Thu Mar 31, 2016 12:56 am
- Title: Dangerous
- SFD Alias: Danger Ross
- Started SFD: 14 june 2012 (launch day)
- Location: California
- Gender:
- Age: 24
Gurt's job isn't to make scripting simpler. If he adds something to the API it's usually to expand the potential of scripting.
Anyways, if it's a bullet that overkills your robot you can use the OnProjectileHit event to check if the shot will gib it or not, and if it does you can remove the bullet and the robot and replace it with metal scraps. OnProjectileHit activates before it hits btw, so it wont gib your robot before activating.
If it's melee damage you can track how much damage it takes using playerModifiers and remove the bot before it gets too close to the threshhold damage.
If it's a rocket or explosive Jak's method is the best solution I can think of.
Anyways, if it's a bullet that overkills your robot you can use the OnProjectileHit event to check if the shot will gib it or not, and if it does you can remove the bullet and the robot and replace it with metal scraps. OnProjectileHit activates before it hits btw, so it wont gib your robot before activating.
If it's melee damage you can track how much damage it takes using playerModifiers and remove the bot before it gets too close to the threshhold damage.
If it's a rocket or explosive Jak's method is the best solution I can think of.
1 x
sorry bucko, you can't punch with swords
-
- Superfighter
- Posts: 97
- Joined: Thu Feb 07, 2019 4:36 am
Thanks everyone for your help. I ended up with similar solution to JakSparro98's one. Adding more debris effects seem to hide the blood pretty well.
https://github.com/NearHuscarl/SFDScrip ... imation.cs
https://github.com/NearHuscarl/SFDScrip ... imation.cs
0 x
- Danger Ross
- Superfighter
- Posts: 154
- Joined: Thu Mar 31, 2016 12:56 am
- Title: Dangerous
- SFD Alias: Danger Ross
- Started SFD: 14 june 2012 (launch day)
- Location: California
- Gender:
- Age: 24
I just realized there's an explosion hit event as well. If you figure out how to use it you may be able to destroy the body before it's blown up into gibs if it works anything like the projectile hit event.
0 x
sorry bucko, you can't punch with swords
- Gurt
- Lead Programmer
- Posts: 1884
- Joined: Sun Feb 28, 2016 3:22 pm
- Title: Lead programmer
- Started SFD: Made it!
- Location: Sweden
- Gender:
- Age: 34
This is a case we have never used ourselves. But the PlayerHitEffect.Metal shouldn't really show the gib effect. Changing this to the next update.
PlayerHitEffect.Metal will play the break sound together with the DestroyMetal effect when the player is gibbed.
PlayerHitEffect.Metal will play the break sound together with the DestroyMetal effect when the player is gibbed.
0 x
Gurt