Page 1 of 1

Is this logical?

Posted: Mon Oct 06, 2008 11:43 pm
by Dakatsu
Coding the basis for a mod, and I am wondering if this would work. I want this weapon to reload only if bCanReload=true, so whenever the reload key is hit, ReloadCheck is done. For the subclasses of the original basis for a weapon, I want them to not only use their own requirements, but it's superclasses. Would this logically work? (AkiFirearm is the parent of SkorpFirearm).

Example, if the weapon has no more magazines (MagCount ==0), I want both AkiFrearm and SkorpFirearm to not be able to reload. If SkorpFirearm is jammed (bJammed), I want it to not be able to reload as well.

Of course I could copy all conditions of AkiFirearm into SkorpFirearm's state, but if I change something in AkiFirearm, I'd have to change all it's subclasses.

AkiFirearm

Code: Select all

simulated function ReloadCheck()
{
     if (MagCount == 0 || bIsReloading || bSightTransition)
        bCanReload=false;
     else
        bCanReload=true;
}
SkorpFirearm

Code: Select all

simulated function ReloadCheck()
{
     Super.ReloadCheck();
     if (bJammed || bUnjamming || !bCanReload)
        bCanReload=false;
     else
        bCanReload=true;
}

Posted: Tue Oct 07, 2008 7:16 am
by heftig
Looks like it should work.

You can simplify the code a bit:

AkiFirearm:

Code: Select all

simulated function ReloadCheck()
{
     bCanReload = (MagCount > 0 && !bIsReloading && !bSightTransition);
}
SkorpFirearm:

Code: Select all

simulated function ReloadCheck()
{
     Super.ReloadCheck();
     if (bJammed || bUnjamming)
        bCanReload = false;
}