"kill monsters" x Friendly Monsters

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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.

"kill monsters" x Friendly Monsters

Postby Logan MTM » Tue Jul 27, 2021 7:01 pm

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!
Last edited by Logan MTM on Wed Jul 28, 2021 5:31 am, edited 1 time in total.
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil

Re: "kill monsters" x Friendly Monsters

Postby cubebert » Tue Jul 27, 2021 9:13 pm

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.
User avatar
cubebert
 
Joined: 14 Jun 2020
Operating System: Windows Vista/7/2008 64-bit
Graphics Processor: nVidia (Modern GZDoom)

Re: "kill monsters" x Friendly Monsters

Postby Rachael » Wed Jul 28, 2021 4:53 am

The player can type "kill baddies" in the console instead and it will ignore friendly monsters.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: "kill monsters" x Friendly Monsters

Postby Logan MTM » Wed Jul 28, 2021 7:12 pm

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.
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil

Re: "kill monsters" x Friendly Monsters

Postby SanyaWaffles » Wed Jul 28, 2021 7:38 pm

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.
User avatar
SanyaWaffles
Certified Heretic and Grill Champion
 
Joined: 25 Apr 2013
Location: Eastern Ohio
Discord: SanyaWaffles#5095
Twitch ID: sanyawaffles
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: "kill monsters" x Friendly Monsters

Postby Logan MTM » Wed Jul 28, 2021 8:08 pm

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"! :|
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil

Re: "kill monsters" x Friendly Monsters

Postby SanyaWaffles » Wed Jul 28, 2021 8:14 pm

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.
User avatar
SanyaWaffles
Certified Heretic and Grill Champion
 
Joined: 25 Apr 2013
Location: Eastern Ohio
Discord: SanyaWaffles#5095
Twitch ID: sanyawaffles
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: "kill monsters" x Friendly Monsters

Postby Logan MTM » Wed Jul 28, 2021 8:36 pm

Zscript is new to me and there are no good sample documentation sources available.
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil

Re: "kill monsters" x Friendly Monsters

Postby Rachael » Thu Jul 29, 2021 1:08 am

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.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: "kill monsters" x Friendly Monsters

Postby Logan MTM » Thu Jul 29, 2021 6:04 am

You right. My apologies.
It's getting interesting. So, ZScript deal with internal code function?

What "Super::" actually means/does?
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil

Re: "kill monsters" x Friendly Monsters

Postby Rachael » Thu Jul 29, 2021 6:06 am

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.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: "kill monsters" x Friendly Monsters

Postby Logan MTM » Thu Jul 29, 2021 6:13 am

Thank you. :wink:
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil

Re: "kill monsters" x Friendly Monsters

Postby Rachael » Thu Jul 29, 2021 7:10 am

You're welcome.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: "kill monsters" x Friendly Monsters

Postby Logan MTM » Thu Jul 29, 2021 6:28 pm

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:
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil

Re: "kill monsters" x Friendly Monsters

Postby SanyaWaffles » Thu Jul 29, 2021 7:39 pm

Use Super.Damagemobj instead of Super::DamageMobj
User avatar
SanyaWaffles
Certified Heretic and Grill Champion
 
Joined: 25 Apr 2013
Location: Eastern Ohio
Discord: SanyaWaffles#5095
Twitch ID: sanyawaffles
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests