Page 1 of 2

"kill monsters" x Friendly Monsters

PostPosted: Tue Jul 27, 2021 7:01 pm
by Logan MTM
Hi everyone!
Please help, what is the trick to don't kill Friendly Monsters if Player type "kill monsters" on console?
I tryed -ISMONSTER but it makes the Actor can't be Dormant! :(

Thanks you all!

Re: "kill monsters" x Friendly Monsters

PostPosted: Tue Jul 27, 2021 9:13 pm
by cubebert
I could be remembering wrong, but if you give your actor "DamageFactor "Massacre", 0.0", it should be impervious to the kill monsters command, as well as the mdk command.

Re: "kill monsters" x Friendly Monsters

PostPosted: Wed Jul 28, 2021 4:53 am
by Rachael
The player can type "kill baddies" in the console instead and it will ignore friendly monsters.

Re: "kill monsters" x Friendly Monsters

PostPosted: Wed Jul 28, 2021 7:12 pm
by Logan MTM
cubebert wrote:I could be remembering wrong, but if you give your actor "DamageFactor "Massacre", 0.0", it should be impervious to the kill monsters command, as well as the mdk command.

Donesn't work! :(

Rachael wrote:The player can type "kill baddies" in the console instead and it will ignore friendly monsters.

Do you know if ZScript can make "kill monsters" works exactly as "kill baddies"?

It's okay for the player to use "kill monsters" BUT if Friendlys dies, this may corrupt all the gameplay logic.

Re: "kill monsters" x Friendly Monsters

PostPosted: Wed Jul 28, 2021 7:38 pm
by SanyaWaffles
why can't you just use kill baddies command like Rachael said? Why use hacky workarounds if there's a built in engine function.

... that said if you use ZScript, you can ignore 'Massacre' damage in the DamageMobj function.

Re: "kill monsters" x Friendly Monsters

PostPosted: Wed Jul 28, 2021 8:08 pm
by Logan MTM
SanyaWaffles wrote:why can't you just use kill baddies command like Rachael said? Why use hacky workarounds if there's a built in engine function.

Becouse I want the player to be able to use "kill monsters" (freelly for fun) without messing up all the gameplay logic and keep playing?
Why so many "whys"?
Please, show us a bit more of "How to"! :|

Re: "kill monsters" x Friendly Monsters

PostPosted: Wed Jul 28, 2021 8:14 pm
by SanyaWaffles
I... did tell you what you need to do. I just didn't copy/paste code because I was hoping you'd at least try to implement it yourself.

SanyaWaffles wrote:... that said if you use ZScript, you can ignore 'Massacre' damage in the DamageMobj function.

Re: "kill monsters" x Friendly Monsters

PostPosted: Wed Jul 28, 2021 8:36 pm
by Logan MTM
Zscript is new to me and there are no good sample documentation sources available.

Re: "kill monsters" x Friendly Monsters

PostPosted: Thu Jul 29, 2021 1:08 am
by Rachael
Untested, but this is something along the lines of what Sanya was suggesting. This goes into your ZScript definition for the friendlies you need protected.
Code: Select allExpand view
override int DamageMobj(Actor inflictor, Actor source, int damage, Name mod, int flags, double angle)
{
   if (bFriendly && mod == "Massacre")
      return 0;
   else
      return Super::DamageMobj(inflictor, source, damage, mod, flags, angle);
}


Not sure if it'll work but I am sure someone can fix it if needed.

Logan MTM wrote:Why so many "whys"?
Please, show us a bit more of "How to"! :|

Please show a little more patience. People have a right to ask, especially in some cases it can improve the answer you get because it is more tailored to your use case.

Re: "kill monsters" x Friendly Monsters

PostPosted: Thu Jul 29, 2021 6:04 am
by Logan MTM
You right. My apologies.
It's getting interesting. So, ZScript deal with internal code function?

What "Super::" actually means/does?

Re: "kill monsters" x Friendly Monsters

PostPosted: Thu Jul 29, 2021 6:06 am
by Rachael
Super:: calls the parent object's definition of the function. This allows you to intercept a virtual function call, do whatever you want to it, and then let the object behave otherwise as it normally would. In this case that would mean that any damage absorptions or enhancements you might have on it would behave normally because you're returning the value that GZDoom would've returned anyway had you not defined the function in the first place.

Re: "kill monsters" x Friendly Monsters

PostPosted: Thu Jul 29, 2021 6:13 am
by Logan MTM
Thank you. :wink:

Re: "kill monsters" x Friendly Monsters

PostPosted: Thu Jul 29, 2021 7:10 am
by Rachael
You're welcome.

Re: "kill monsters" x Friendly Monsters

PostPosted: Thu Jul 29, 2021 6:28 pm
by Logan MTM
There is something missing.

Code: Select allExpand view
Override Int DamageMobj(Actor Inflictor, Actor Source, Int Damage, Name Mod, Int Flags, Double Angle)
 {
 If(bFriendly && Mod == "Massacre")
  {
  Return 0;
  }
 Else
  {
  Return Super::DamageMobj(Inflictor, Source, Damage, Mod, Flags, Angle);
  }
 }

Spoiler:


I Tryed to figure out by m self what is going wrong but i just got this error message:
Spoiler:

Re: "kill monsters" x Friendly Monsters

PostPosted: Thu Jul 29, 2021 7:39 pm
by SanyaWaffles
Use Super.Damagemobj instead of Super::DamageMobj