Inventory WEAPON.NOAUTOAIM settings

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.

Inventory WEAPON.NOAUTOAIM settings

Postby peewee_RotA » Sat Jun 05, 2021 6:37 am

The flag WEAPON.NOAUTOAIM makes it so that projectiles and hitscans from the weapon do not try to autoaim adjust towards monsters. But a weird side effect is that if you have a weapon selected with this setting it will also apply to inventory. For example in heretic if I have a weapon set with this flag and use the morph ovum, the eggs no longer auto aim. I think this is relatively minor, but I'm using the inventory to launch a different projectile that happens more often.

Is there a way to make a specific projectile not follow this flag? My inventory item is using "SpawnPlayerMissile" to make the missile. Is there maybe a missile spawn method that ignores this flag?

I'm ok with a work around that always ignores autoaim when it spawns missiles. I could find a way to make that consistent with the inventory across the board.
peewee_RotA
 
Joined: 07 Feb 2014

Re: Inventory WEAPON.NOAUTOAIM settings

Postby Jarewill » Sat Jun 05, 2021 8:29 am

Inventory items always used the properties of the current weapon when used.
I had problems with a few other properties being applied to inventory items.

This might be a very hacky way, but this is a potential fix:
Code: Select allExpand view
Class AimThrower : Inventory
{
    Default
    
{
        Inventory.MaxAmount 10;
        Inventory.Icon "BON1A0";
        +INVENTORY.INVBAR;
    }
    States
    
{
    Spawn:
        BON1 A -1;
        Stop;
    }
    Override bool Use(bool pickup)
    {
        FTranslatedLineTarget t;
        If(!pickup)
        {
            owner.AimLineAttack(owner.angle,8192,t,32);
            If(owner.GetCVar("autoaim")&&t.linetarget)
            {
                owner.SpawnMissile(t.linetarget,"DoomImpBall",owner);
                Return 1;
            }
            Else
            
{
                owner.SpawnPlayerMissile("DoomImpBall");
                Return 1;
            }
        }
        Else{Return 0;}
    }
}

This makes use of the BFG's AimLineAttack function to return a target and then file a projectile at it.
AimLineAttack uses autoaim regardless of weapon's flags, so it will return a target with autoaim.
Then it checks if there is a target and if the player has autoaim enabled.
If yes, it will shoot a projectile aimed at said target, otherwise it will fire a projectile normally.

This is probably a very hacky way to do it, but that's all I could think of.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Inventory WEAPON.NOAUTOAIM settings

Postby peewee_RotA » Sat Jun 05, 2021 4:10 pm

That's handy! Thanks!
peewee_RotA
 
Joined: 07 Feb 2014


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests