Code Suggestion: Logic

Started by Hammish, September 26, 2014, 03:26:01 AM

Hammish

   I don't know if this is possible, how much work it would take, or if it's already possible... but can you, or can you look at, eventually making item requirement fields into actual logic gates?  Also not a super-huge priority here and I know you guys are looking toward launch at this moment, but I figured I would toss it on the drawing board as something that could be potentially useful in the long-term if there isn't currently a way to do it. :)

   I'm essentially looking for NOT gates in the long run, with the ability to set  requirements such as: Requires X effect to be present, but requires Y effect to not be present in order to equip.

Lurler

Sure, it's definitely possible and shouldn't be that hard to do.
How exactly would you like this to be structured in the file? If you can make a formal version of this proposal I will be able to tell exactly how difficult it is to implement.

Hammish

Hmmm, I'm not really sure on the exact syntax desired... and I think I might have thought up a way to do it even inside the existing syntax.  As an example, take the split I did in BTC with regards to drone bays.  Currently I have the missile hardpoint split into two trees, regular missiles and drones.  In order to mount missiles, a ship needs to have use_missile_weapons=1.  In order to use drone bays, a ship has to have use_drone_bays=1.  Thus, any hull with a missile hardpoint has one of those set.

However, I don't think I need to do all that, heh.

Unless I miss my guess, I think I could just set use_drone_bays=1 on any carrier craft.  Drone bays would still require use_drone_bays=1 to equip, but for missile weapons I could just set the requirement of use_drone_bays=0.  Thus any ship with the carrier tag will by default exclude normal drone weapons because use_drone_bays =! 0.  And that right there would be the NOT gate. :)

Or, as another example, I have three sizes of ships: corvettes, frigates and cruisers.  I could give each a variable if needed, and then limit that to class size.  Something doesn't belong on a corvette?  Requirment of corvette=0, ect ect.  Might look a little clunky but it'd work. :)

Lurler

Hm, if I understand what you explained correctly it should work as intended. Basically limiting each hull to a particular sub type of a weapon.

Hammish

Well, restricting to one type of hull I already knew how to do.  If I wanted to make a weapon corvette-only, I'd just put use_corvette_weapons=1 effect on the hull, then a requirement of use_corvette_weapons=1 on the weapon.  That part is easy to learn just from looking at the existing items.

What I was curious about at this point would be what would happen if you put on a requirement of of zero on an item.  So if I wanted to make a weapon that would fit on anything BUT a corvette hull, could I set the requirement of use_corvette_weapons=0?  I thought that might work, but maybe not, given how turrets seem to work currently.  (If I skill up to heavy energy, as an example, I have a use_energy_weapons of 3, but I can still use guns that have a use_energy_weapons requirement of just 1.)  That seems to hint that when the game checks requirements, it just checks to make sure that your current skill level >= the requirement, which in turn would mean everything passes a requirement check of zero.

Of course, if that's how it works, doing a NOT is a bit more complex.  One possibility might to be adding a sister field named Restrictions, maybe.  In order to mount a piece of equipment, it would need to pass all Requirement checks (just like it is now) but fail all Restriction checks.  So an example energy weapon using the above:

<requirements>
   <effects>
      <effect>
         <id>use_energy_weapons_ability</id>
         <value>1</value>
      </effect>
   </effects>
</requirements>
<restrictions>
   <effects>
      <effect>
         <id>use_corvette_weapons_ability</id>
         <value>1</value>
      </effect>
   </effects>
</restrictions>

As long as the player had use_energy_weapons at 1 or more (an effect from the skill), but did NOT have use_corvette_weapons at 1 or more (an effect on just corvette hulls), he'd be able to mount the equipment.

Lurler

I see, thank you for detailed explanation.
And yes, you are probably right, I think it would not be possible now because it is always checked as "current >= required", so you can't just put "0" there.
Hopefully we can implement that in the future.