Page 1 of 1

Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 5:56 am
by t3hplayer
When a player fires a weapon, is it possible to determine how much damage was done?

Or, even not specific to a particular weapon or shot, is there any way to figure out how much damage was done by a particular player, like in coop?

Thanks.

Edit: To be clear, I don't want to just know this out of curiosity. Is there some bit of ACS code that can tell me how much damage was done with the most recent player shot, for example?

RE: Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 6:18 am
by Mr.Man
Well, look in the decorate file of the weapon, and at its damage, put random(100,200) for example.

RE: Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 6:24 am
by t3hplayer
Mr.Man wrote: Well, look in the decorate file of the weapon, and at its damage, put random(100,200) for example.
I probably wasn't clear in my post. Suppose a player fires a shotgun, for example. If all the bullets hit a wall, that shot did 0 damage. If a couple of the bullets hit an enemy, then some damage was done. If all the bullets hit an enemy, then more damage was done. Is there any way to know what amount of damage was done?

RE: Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 6:48 am
by Mr.Man
I guess each pellet does the same damage, and the more pellets hit an enemy, the more it deals. If it does 25, 4 shots kill a player.
You can look this up i guess? I dont know if this is even right, it might be.

RE: Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 9:27 am
by IdeIdoom
Hit scan weapons do the random(5,10,15) damage per pellet.
Usually players calculate for the one in the middle with how many pellets they hit.

RE: Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 10:12 am
by Hypnotoad
t3hplayer wrote: Edit: To be clear, I don't want to just know this out of curiosity. Is there some bit of ACS code that can tell me how much damage was done with the most recent player shot, for example?
If you know the player/enemy he is shooting then yes, if you do not know what or who he will be shooting, then this becomes much harder and I am not sure if it is possible to do reliably yet using ACS.

RE: Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 11:03 am
by Guardsoul
It´s possible via ACS (but very very hard to implement). There is an example of that in WrathOfCronos 1.6 b I think.

RE: Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 1:15 pm
by Ijon Tichy
since monsters don't necessarily target or have any reference to who shot them, and no way to determine at all where the damage came from, there is no reliable way to do this

RE: Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 1:19 pm
by Ænima
The "award damage dealt not kills" DMFLAG tracks damage, but it's hard-coded. :/

RE: Possible to determine how much damage a player did?

Posted: Thu Dec 05, 2013 2:45 pm
by Catastrophe
Yeah, there's no way you can calculate through ACS on how much player-damage you've done. The main problem is that if two people shoot you at the same time in the same tic then it'll fuck up.

RE: Possible to determine how much damage a player did?

Posted: Fri Dec 06, 2013 2:43 am
by t3hplayer
Hypnotoad wrote:
t3hplayer wrote: Edit: To be clear, I don't want to just know this out of curiosity. Is there some bit of ACS code that can tell me how much damage was done with the most recent player shot, for example?
If you know the player/enemy he is shooting then yes, if you do not know what or who he will be shooting, then this becomes much harder and I am not sure if it is possible to do reliably yet using ACS.
Yeah, that's what I was thinking. Unfortunately, there are likely to be many monsters on-screen at any given time. I suspect it's doable with instant attacks, like melee or bullets, but I suspect it's not really doable for missiles.
Guardsoul wrote: It´s possible via ACS (but very very hard to implement). There is an example of that in WrathOfCronos 1.6 b I think.
Is the source available for WoC? I poked around a bit on the WoC threads both here and on the Zdoom forums, but I didn't see a download for it.
Ænima wrote: The "award damage dealt not kills" DMFLAG tracks damage, but it's hard-coded. :/
That might be good enough, actually. I can probably be happy with just a looped script that recalculates based on score change since the last iteration. Shouldn't be too much of a hack.
Ijon Tichy wrote: since monsters don't necessarily target or have any reference to who shot them, and no way to determine at all where the damage came from, there is no reliable way to do this
That's sorta what I was figuring, but I wasn't certain if there was or wasn't a way for monsters to know who attacked them / players to know what they hit. All I knew is that if there is a way, it wasn't obvious to me.

Thanks for all the input, guys. I'll look into the DMFLAG Ænima mentioned. I don't need to know the exact damage done, rather I just want some kinda metric I can use to award points to players based on damage done (as opposed to based on enemies killed). That DMFLAG might be the ticket.

RE: Possible to determine how much damage a player did?

Posted: Fri Dec 06, 2013 2:54 am
by Ænima
t3hplayer wrote:
Ænima wrote: The "award damage dealt not kills" DMFLAG tracks damage, but it's hard-coded. :/
That might be good enough, actually. I can probably be happy with just a looped script that recalculates based on score change since the last iteration. Shouldn't be too much of a hack.


Thanks for all the input, guys. I'll look into the DMFLAG Ænima mentioned. I don't need to know the exact damage done, rather I just want some kinda metric I can use to award points to players based on damage done (as opposed to based on enemies killed). That DMFLAG might be the ticket.
Well uhhh ... The problem is that it's hard-coded. Yes you can see the points on the scoreboard (which is your total damage done divided by 100, i think), but there's no way to access that number through an ACS script.

RE: Possible to determine how much damage a player did?

Posted: Fri Dec 06, 2013 3:02 am
by t3hplayer
Ænima wrote:
t3hplayer wrote:
Ænima wrote: The "award damage dealt not kills" DMFLAG tracks damage, but it's hard-coded. :/
That might be good enough, actually. I can probably be happy with just a looped script that recalculates based on score change since the last iteration. Shouldn't be too much of a hack.


Thanks for all the input, guys. I'll look into the DMFLAG Ænima mentioned. I don't need to know the exact damage done, rather I just want some kinda metric I can use to award points to players based on damage done (as opposed to based on enemies killed). That DMFLAG might be the ticket.
Well uhhh ... The problem is that it's hard-coded. Yes you can see the points on the scoreboard (which is your total damage done divided by 100, i think), but there's no way to access that number through an ACS script.
Oh...lame. I was thinking that number was gettable through PlayerFrags().

Edit: I may put in a feature request for a PlayerScore() function to be added in the future. I suspect I'm not the only one for whom such a function would be useful.

RE: Possible to determine how much damage a player did?

Posted: Fri Dec 06, 2013 3:14 am
by Ænima
t3hplayer wrote:
Ænima wrote:
t3hplayer wrote:
Ænima wrote: The "award damage dealt not kills" DMFLAG tracks damage, but it's hard-coded. :/
That might be good enough, actually. I can probably be happy with just a looped script that recalculates based on score change since the last iteration. Shouldn't be too much of a hack.


Thanks for all the input, guys. I'll look into the DMFLAG Ænima mentioned. I don't need to know the exact damage done, rather I just want some kinda metric I can use to award points to players based on damage done (as opposed to based on enemies killed). That DMFLAG might be the ticket.
Well uhhh ... The problem is that it's hard-coded. Yes you can see the points on the scoreboard (which is your total damage done divided by 100, i think), but there's no way to access that number through an ACS script.
Oh...lame. I was thinking that number was gettable through PlayerFrags().
Nope. IIRC, using PlayerFrags in a non-PvP gamemode will just return 0.
t3hplayer wrote: Edit: I may put in a feature request for a PlayerScore() function to be added in the future. I suspect I'm not the only one for whom such a function would be useful.
That would be nice, yes. Even better if it had a dual functionality (return a player's caps if used in CTF, or a player's kills/damage if used in coop).

RE: Possible to determine how much damage a player did?

Posted: Fri Dec 06, 2013 4:15 am
by Watermelon
Mr.Man wrote: Well, look in the decorate file of the weapon, and at its damage, put random(100,200) for example.
Would it hurt to read what someone says for once? Just once. I don't bother people who misread posts cause I do it myself, but every single time I read a post by you, it's like you pick 2 (random) words out of a post and comment on something way off topic/something that doesn't help.





On topic:
It is possible if you give each player their own weapon (requiring 64 weapons with 64 puffs and so on) and then writing that to ACS.
IMO it's not worth it unless you're going to be doing something epic.

RE: Possible to determine how much damage a player did?

Posted: Fri Dec 06, 2013 4:53 am
by t3hplayer
Watermelon wrote: It is possible if you give each player their own weapon (requiring 64 weapons with 64 puffs and so on) and then writing that to ACS.
IMO it's not worth it unless you're going to be doing something epic.
That actually hadn't occurred to me, so thanks for that. I probably wouldn't be entirely opposed to that approach, but I'd need something that would work with projectiles as well as bullets, and I don't think this would, since I don't think there's any trivial way to determine how much damage an explosion did.

Looks like it's a dead-end for now, at least for what I had in mind. Ahh well, not too big of deal. Thanks to everyone for the input.

RE: Possible to determine how much damage a player did?

Posted: Fri Dec 06, 2013 2:27 pm
by Klofkac
I think there can be concept of how to get damage:

Pseudocode:
new = GetActorHealth;
damage = old-new;
old = GetActorHealth;
TheLoop;

But it cannot be utilised really well practically, because it checks damage taken, not dealt.

RE: Possible to determine how much damage a player did?

Posted: Fri Dec 06, 2013 7:43 pm
by t3hplayer
Klofkac wrote: I think there can be concept of how to get damage:

Pseudocode:
new = GetActorHealth;
damage = old-new;
old = GetActorHealth;
TheLoop;

But it cannot be utilised really well practically, because it checks damage taken, not dealt.
Yeah, I thought about this, but one other problem is that I don't know which actors might be getting damaged. I'm doing this with coop, and there could be 50 (or many more) monsters. With bullets it could probably be managed, but then I think about projectiles and BFG tendrils and I'm pretty sure it's nearly impossible to do without some kinda input from the engine side.