Author Topic: Using scripts for alternate shield effects?  (Read 1969 times)

0 Members and 1 Guest are viewing this topic.

Offline zircher

  • 24
  • Have gun, will travel.
Using scripts for alternate shield effects?
I'm tossing this out to the scripting gurus to determine if this is a viable option.

In the Renegade Legion universe, shields are nigh invulnerable but they have to rapidly flicker due to the massive power requirements.  That makes them very unlike the ablative shields used in other game settings.

The question is, can a modder use weapon hit events to trigger a script that will randomly determine (based on the ship design and perhaps weapon facing) if the target hit is invulnerable or takes normal armor/hull/sub-system damage? 

According to the game fiction, shields would not protect a ship from ramming, asteroid collisions, and the like.  [Shields are not going to protect you from sudden stops that would compromise the structure of the ship and the crew.]  A more specific example would be a fighter that is 60% invulnerable from the front and rear and 40% invulnerable from the sides.  Optionally, if a shield generator sub system is destroyed, that fighter would lose its flicker shield in the respective quadrant that the weapon fire game from.

I don't need any specific code at this time, I was just wondering if the scripting system supports that type of dynamic logic and reaction to in-game events.
--
TAZ

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Using scripts for alternate shield effects?
Code: [Select]
#Conditional Hooks
$Ship class: GTF Erinyes
$On Ship Collision: [
     local phys = hv.ShipB.Physics
     local shld = hv.Self.Shield
     local scalar = .001
     shld.CombinedLeft = shld.CombinedLeft - scalar * (phys.Mass * phys:getSpeed()^2)
]
+Override: true
#End

That should apply collision damage to shields rather than the hull (damage will be applied equally across quadrants; you would have to do some math to figure out which quadrant the collision should occur on). If you're not familiar with physics and am wondering why I squared the speed, take a gander at this. Obviously you don't have to do it like it happens in the real world, I just figure that it'll help give people an intuitive sense of how damage scales because it'll be more like what they're used to.

Now randomly:
Code: [Select]
#Conditional Hooks
$Ship class: GTF Erinyes
$On Ship Collision: [
     if g_CollisionTrigger > 50 then
          local phys = hv.ShipB.Physics
          local shld = hv.Self.Shield
          local scalar = .001
          shld.CombinedLeft = shld.CombinedLeft - scalar * (phys.Mass * phys:getSpeed()^2)
     end
]
+Override:
[
     g_CollisionTrigger = math.random(0,100)
     if g_CollisionTrigger > 50 then
          return true
     else
          return false
     end
]
#End

The important thing to realize here is that the override hook is always executed before the normal hook, and that if you declare a variable in one hook, it will carry over to the next hook(s) until you set it to nil. (This means if you use a big table in one hook, you should set the variable to nil when you get done with it, or else it will stay in memory even after the hook is done)

Didn't test those code samples at all, but aside from typos/mistakes, they should be fully functional
-C

 

Offline zircher

  • 24
  • Have gun, will travel.
Re: Using scripts for alternate shield effects?
Coolness, good to know that the scripting system supports that level of control.  Now we'll just have to get up to speed on Lua and FS2's 'API' when the time comes to implement that logic.
--
Thanks, TAZ.