CREATING A "NO FRIENDLY FIRE" MONSTER CLASS THROUGH ACS

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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!)
Post Reply
HYDROSYNTH+077503
Posts: 15
Joined: Tue Aug 22, 2023 3:03 pm
Preferred Pronouns: He/Him
Graphics Processor: Not Listed

CREATING A "NO FRIENDLY FIRE" MONSTER CLASS THROUGH ACS

Post by HYDROSYNTH+077503 »

Hello, I am New to ZDOOM modding Scene, and i am attempting to create what i's just calling as a "NO FRIENDLY FIRE" ACS Script. this ACS is meant to prevent my Custom monsters from ever harming each other. Although i may have forgotten the Hitscan Damages.however, i don't know why my SLADE3 won't compile the Scripts. It said they're BAD DECLARATIONS. Can you lads Tell me what i did wrong on the script?

I put the script using notepad and Attached it to the post.

Code: Select all

#include "zcommon.acs"

script "PreventSplashDamage"

    int attackerTID;
    int targetTID;

    while (1)
    {
        if (ThingCount(0, 0, attackerTID) && ThingCount(0, 0, targetTID))
        {
            attackerTID = ActivatorTID();
            targetTID = TargetTID();

            if (ThingCountName("Monster", attackerTID) && ThingClassString(targetTID) == "CustomProjectileClass")
            {
                SetActorPropertyFixed(targetTID, APROP_Damage, 1.0);
            }
        }

        Delay(1);
    }


script "NoProjectileDamage"

    while (1)
    {
        int attackerTID = ActivatorTID();
        int targetTID = ActivatorTID(1);

        if (ThingCountName("Monster", attackerTID) && (ThingClassString(targetTID) == "Projectile" || ThingClassString(targetTID) == "Missile"))
        {
            DamageThing(targetTID, 0);
        }

        Delay(1);
    }


script "NoDamage"

    while (1)
    {
        int targetTID = ActivatorTID();

        if (ThingCountName("Monster", targetTID))
        {
            int actorClass = GetActorClass(targetTID);

            if (actorClass != StrParam("Monster"))
            {
                DamageThing(targetTID, 0);
            }
        }

        Delay(1);
    }


script "ApplyDamage"

    while (1)
    {
        int targetTID = GetActorProperty(0, APROP_TargetTID);

        // Your existing code to apply damage

        // Call the NoDamage script to exclude the "Monster" class from taking damage
        ACS_NamedExecute("NoDamage", targetTID);

        Delay(1);
    }
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: CREATING A "NO FRIENDLY FIRE" MONSTER CLASS THROUGH ACS

Post by ramon.dexter »

SetActorPropertyFixed

Where did you find such a function? It doesnt exist in acs.
HYDROSYNTH+077503
Posts: 15
Joined: Tue Aug 22, 2023 3:03 pm
Preferred Pronouns: He/Him
Graphics Processor: Not Listed

Re: CREATING A "NO FRIENDLY FIRE" MONSTER CLASS THROUGH ACS

Post by HYDROSYNTH+077503 »

Hey there. I apologize for the late reply. You see, I had help with the A.I. Chat Bot called "POE CHATGPT" ,I have then asked it to help me assemble the script and it ended up giving me this( the listed code). I thought it was going to be a smooth implementation of scriptcode, but instead it was it just error after error after error. I finally caved in and posted the code asking for help.
HYDROSYNTH+077503
Posts: 15
Joined: Tue Aug 22, 2023 3:03 pm
Preferred Pronouns: He/Him
Graphics Processor: Not Listed

Re: CREATING A "NO FRIENDLY FIRE" MONSTER CLASS THROUGH ACS

Post by HYDROSYNTH+077503 »

Also P.S. I on purposefully called the Custom monster class "Monster" at the time of the script creation. I was a little lazy and Impatient at the Time.
User avatar
ramon.dexter
Posts: 1562
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

Re: CREATING A "NO FRIENDLY FIRE" MONSTER CLASS THROUGH ACS

Post by ramon.dexter »

Ok, so some faulty AI wrote the script. The best way is to completely forget there is any "AI" and learn yourself coding. Using this "AI" will bring more problems than it could solve. No, coding is not hard. If english is your native language, you've got a good starting point.
HYDROSYNTH+077503
Posts: 15
Joined: Tue Aug 22, 2023 3:03 pm
Preferred Pronouns: He/Him
Graphics Processor: Not Listed

Re: CREATING A "NO FRIENDLY FIRE" MONSTER CLASS THROUGH ACS

Post by HYDROSYNTH+077503 »

You're right. I Apologize, you see, I thought the A.I. was going to introduce a better way to script ACS, but instead it only caused problems. I'll start relying on myself for the code scripting. Thanks for the feedback.
User avatar
RKD
Posts: 148
Joined: Sat Mar 19, 2022 9:52 am
Location: Argentina

Re: CREATING A "NO FRIENDLY FIRE" MONSTER CLASS THROUGH ACS

Post by RKD »

Using AI will never give you proper code ready to use, unless a miracle happens. But for this case, I'm pretty sure you could try adding flags like +NOINFIGHTING, +NOTARGET and/or +NEVERTARGET in your monster actor properties. Their descriptions are on the actor flags list on the wiki, under the "(In)abilities" section.
Post Reply

Return to “Scripting”