I've noticed that when you take poison damage, there's not really any visual indication you've been poisoned. You just sort of keep taking damage, which can be confusing if the player doesn't know what's causing it. I thought a good solution would be to give the player a powerup which tints the screen for a short period of time, similar to the radiation suit or berserk pack. But the only way I can figure out to give an inventory item to a player when they're hurt by an attack is if I use A_RadiusGive and add it to the monster/projectile/puff. This would give it to the actor closest to the monster or projectile at the point of impact and I can make the radius small so that it's unlikely to give the inventory item to the wrong target, but this is obviously pretty hacky and there's no guarantee the item would transfer at all or that it would definitely go to the right actor.
Is there a way using Zscript to give an inventory item to the victim when the attack impacts them?
Is it possible for attacks to give inventory items when they do damage?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 54
- Joined: Wed Dec 15, 2021 8:38 pm
- Graphics Processor: nVidia (Modern GZDoom)
-
-
- Posts: 1805
- Joined: Sun Jul 21, 2019 8:54 am
Re: Is it possible for attacks to give inventory items when they do damage?
You can actually make the player play a sound whenever they take poison damage by specifying the *poison playersound in SNDINFO: $playersound player male *poison dsplpain
Poison damage is a bit weird, as it isn't picked up by virtuals like DamageMobj, however the PlayerPawn class has a special virtual function called CheckPoison that you can use.
Here's an example that was taken right from the PlayerPawn definition with an added GiveInventory call:
Poison damage is a bit weird, as it isn't picked up by virtuals like DamageMobj, however the PlayerPawn class has a special virtual function called CheckPoison that you can use.
Here's an example that was taken right from the PlayerPawn definition with an added GiveInventory call:
Code: Select all
Override void CheckPoison()
{
let player = self.player;
if (player.poisoncount && !(Level.maptime & 15))
{
player.poisoncount -= 5;
if (player.poisoncount < 0)
{
player.poisoncount = 0;
}
player.PoisonDamage(player.poisoner, 1, true);
GiveInventory("Clip",1);
}
}
-
- Posts: 54
- Joined: Wed Dec 15, 2021 8:38 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: Is it possible for attacks to give inventory items when they do damage?
That sounds great, although I don't necessarily need it to happen every time the player takes poison damage. I just thought when the original attack hurts them, the player would gain a tinted screen for the full duration that they will keep taking poison damage. Ie, the powerup lasts for 30 seconds if the player takes 1 point of poison damage every second, 30 times.
This is all definitely useable, though!
Thank you!
This is all definitely useable, though!
Thank you!
-
- Posts: 54
- Joined: Wed Dec 15, 2021 8:38 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: Is it possible for attacks to give inventory items when they do damage?
Apologies for late response but I haven't been able to get this to work? I tried adding a log and printbold code to make sure this code is even running when I'm poisoned and I can't get that to work either. It's like it isn't running the CheckPoison function at all.
-
-
- Posts: 1805
- Joined: Sun Jul 21, 2019 8:54 am
Re: Is it possible for attacks to give inventory items when they do damage?
Could you show what you are doing currently?
-
- Posts: 54
- Joined: Wed Dec 15, 2021 8:38 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: Is it possible for attacks to give inventory items when they do damage?
Code: Select all
Class ADruidPlayer : PlayerPawn
{
double pvel;
Default
{
PainChance "Holy", 0;
DamageFactor "Holy", 0;
PainChance "Barrier", 0;
DamageFactor "Barrier", 0;
Player.JumpZ 4;
Player.DisplayName "Druid";
Player.StartItem "SummonAnimal";
Player.StartItem "ManaSummonAnimal", 5;
Player.StartItem "ReflectionStaff";
Player.StartItem "DHealSpell";
Player.StartItem "LightningSpell";
Player.StartItem "ThornSpell";
Player.StartItem "FireStormSpell";
Player.DamageScreenColor "Blue",1,"IceOne";
Player.DamageScreenColor "Purple",1,"Poison";
}
States
{
((States here))
}
Override void Tick()
{
pvel=vel.z;
Super.Tick();
FallDamage();
}
Override void CheckPoison()
{
let player = self.player;
if (player.poisoncount && !(Level.maptime & 15))
{
player.poisoncount -= 5;
if (player.poisoncount < 0)
{
player.poisoncount = 0;
}
player.PoisonDamage(player.poisoner, 1, true);
A_PrintBold("POISON!");
GiveInventory("PoisonIndicator",1);
}
}
void FallDamage()
{
double cvel = vel.z;
double jumpvel = pvel+JumpZ;
int damage;
If(pvel<cvel)
{
If(jumpvel<=-11){damage=(int)((0-jumpvel)*2);}
If (damage>0) {
DamageMobj(null,null,damage,"Falling");
}
}
}
}
When I get hit with a poison attack, the poison works like normal, but I get no message from the printbold command, and I don't receive any inventory. I tried a bunch of different methods to make the screen display a message, and replacing the PoisonIndicator item with other common items like the clip suggested above, and neither of those things happen.
-
- Posts: 5019
- Joined: Sun Nov 14, 2010 12:59 am
Re: Is it possible for attacks to give inventory items when they do damage?
CheckPoison() only deals with the Hexen style of poisoning, not the one ZDoom introduced. From your description, you're using the latter, which does damage every interval and that's it. The Hexen one, in addition to inflicting damage, tints the screen green, and the player character coughs upon being poisoned.
-
- Posts: 54
- Joined: Wed Dec 15, 2021 8:38 pm
- Graphics Processor: nVidia (Modern GZDoom)
Re: Is it possible for attacks to give inventory items when they do damage?
Wait a minute. Why didn't I think of this before!?
Code: Select all
Pain.Poison:
PLAY G 4 GiveInventory("PoisonIndicator",1);
PLAY G 4 A_Pain;
Goto Spawn;