Author Topic: Kind of a hack  (Read 2094 times)

0 Members and 1 Guest are viewing this topic.

Offline WMCoolmon

  • Purveyor of space crack
  • 213
In the last maneuvering thrusters build, I added a variable to subsystems in Lua: Position. This should let you do subobject translation, with clever scripting.

The limitations are that due to how FS2 culls graphics, if the ship goes out of view, so will the subsystem (no matter where it is).

Also, collisions will probably not work properly and be unreliable.

Finally, that variable edits the model data stored in memory. So, if you move a subobject, it will move it for ALL ships using that model, and it will not be reset between missions.

So it has very limited usefulness, but I figured I would mention that if anyone wants to play with it.
-C

 

Offline Vasudan Admiral

  • Member
  • 211
    • Twisted Infinities
Hmm, it sounds interesting - could you show us a sample implementation perhaps? It would greatly help scripting novices like myself. ;)
Get the 2014 Media VPs and report any bugs you find in them to the FSU Mantis so that we may squish them. || Blender to POF model conversion guide
Twisted Infinities

  

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Sample mission: http://fs2source.warpcore.org/temp/wmc/test.fs2
Sample  scripting table (With build): http://fs2source.warpcore.org/temp/wmc/translation.zip

The key scripting stuff is here, it's a little updated with the stuff in the Zip
Code: [Select]
doTest = function()
--Ship subobject is on
shipname = "Mohawk"
--The subobject to moe
subobject = 'radar01a-dish'
--The speed (on the x axis) to move it at
speed = 10

--Get a handle to the ship the subobject is on
theship = mn.getShipByName(shipname)

if theship == not nil then
--This is simple; we add to the current subobject position to make it move.
--If you want something to move UP, use ma.newVector(speed * ba.getFrametime(), 0, 0)

--The getFrametime() call returns how many seconds have passed in this frame. By multiplying by the speed,
--we get the total distance to move this frame (rate * time = distance)
theship[subobject].Position = theship[subobject].Position + ma.newVector(speed* ba.getFrametime(), 0, 0)
end

--Return 1 for this function, so that we can use script-eval-num on this safely.
return 1
end
-C

 

Offline Trivial Psychic

  • 212
  • Snoop Junkie
In theory, could this be used to create turret barrel recoil?  Naturally, in a situation with a triple-barrel turret and weapons mounted to these firepoints firing at different times, each barrel would need to be a separate subobject of the turret base, so that all 3 barrels wouldn't recoil if only one point was firing.  The scripting would need to reference a specific submodel, and the "arms" sections in any multi-barrel multi-part turret are unified as one subobject.  That could get messy.  I know for a fact that MODview wouldn't allow you to assign different firepoints of the same turret entry onto different arms subobjects.  Granted, you could simply create 3 separate turret entries with single firepoints each, each bound to a different barrel on the same base.  This would be a bit similar to the way the flank turrets of the Aeolus (single-parters) were made to mount 6 firepoints.  The problem comes then however, when a swarming primary is fired from such a turret.  Would the separate turret barrels recoil for each swarm shot?  Sounds like another reason we need PCS2... assuming that the scripting functions in question can do the visual effect I've suggested.
The Trivial Psychic Strikes Again!

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
It's an interesting thought, but I doubt it. I could use roughly the same method...

Just for fun, I've added a GunPosition variable that should function the same, except for the gun barrel of the subsystem (if there is one).

http://fs2source.warpcore.org/exes/latest/C03042006.zip
-C