Is this logical?

For system help, all hardware / software topics NOTE: use Coders Corner for all coders topics.

Moderators: Krom, Grendel

Post Reply
User avatar
Dakatsu
DBB Admiral
DBB Admiral
Posts: 1575
Joined: Mon Feb 20, 2006 12:22 am
Location: St. Petersburg, Florida

Is this logical?

Post 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;
}
User avatar
heftig
DBB Ace
DBB Ace
Posts: 138
Joined: Mon Jun 05, 2006 9:55 pm
Location: Germany
Contact:

Post 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;
}
Post Reply