Hard Light Productions Forums
Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: redsniper on August 15, 2008, 10:54:44 pm
-
I've been messing around with table editing trying to make a grappling hook-type weapon. I've got a primary with a negative mass, which does a pretty good job of sucking enemy ships towards the player, and I've given it a trail that looks sort of like a metal cable. The only problem is that even at full alpha, stars and such are visible through the trail. Do you fellows know any way to render a trail opaque? Or perhaps a better way to simulate a grappling hook?
While I'm at it, how customizable are countermeasures? I want to replace the default with flares or something a little more low tech, can countermeasures be given flags like fof or not?
Copied from here (http://www.hard-light.net/forums/index.php/topic,55523.0.html). Reply in this thread from now on please.
-
I've been messing around with table editing trying to make a grappling hook-type weapon. I've got a primary with a negative mass, which does a pretty good job of sucking enemy ships towards the player, and I've given it a trail that looks sort of like a metal cable. The only problem is that even at full alpha, stars and such are visible through the trail. Do you fellows know any way to render a trail opaque? Or perhaps a better way to simulate a grappling hook?
Make it a beam weapon instead of primary? IIRC beam weapons can use alpha blending... kinda. AS normal beams, additive blending works a lot better for making it look fearsome and mighty bright, but for depicting a rope or steel wire with a grappling device in the end, I suppose it might work.
Dunno if you can give beams a sucking effect with negative mass though, and I don't really know how fighterbeams were worked in TBP, but it should be a viable possibility at least, if the primary weapon rendering just ignores alpha (dunno how that works out exactly).
-
Yay, please continue with this as I experimented unsuccessfully with a tractor beam and the thought of one of my hero mechas grabbing and tossing around a few Star Destroyers for my fic would be awesome to post on screen!
"Chain Attack!" :yes:
-
One of those spur of the moment drunken ideas but could it be a combination of both a beam and a primary with a trail? The primary would fire followed a few milliseconds later by the beam which hits the hook. It might even give it that wavy line effect before ti catches.
-
hmmm... I suppose I could give the player's fighter a beam turret and make this work with some creative use of fire-beam. I'll give it a try... eventually.
-
Alright two problems.
First, I started working on this on my laptop and was pleased to notice that I could alt-tab out of FS, make changes to a table, alt-tab back in and restart the mission, and nearly always the changes would take effect without my having to restart FS. Now that I've resumed working on my desktop, I notice that this little trick doesn't work and that I have to restart every time. Is this a version issue? I thought I was using plain 3.6.9 on my laptop. Maybe there's some obscure setting somewhere that I switched on and forgot about?
Second, I can't get beam-whack to occur with fighter beams. :confused: I haven't thoroughly fiddled with this yet, but I would think all I need is "beam" "player allowed" and a mass value and I should get something right?
-
Apparently a beam has to do some damage in order to get the whack effect. Even so, a beam with negative mass doesn't pull the target directly towards the player like a primary does, it smacks them around laterally more than anything, so that idea's a no go.
I'm starting to think that a modeled cable is the only way to go, since all weapons trails are semi-transparent, but I don't know what I'm going to do about the model vanishing when it hits.
-
While I'm at it, how customizable are countermeasures? I want to replace the default with flares or something a little more low tech, can countermeasures be given flags like fof or not?
:blah: Another feature implementation with potentially massive consequences that people have forgotten about.
Countermeasures have the same table fields as weapons.
The wiki is completely misleading on this. You can use all of the same fields for weapons for countermeasures. Or, you can drop Subachs out of a ship's ass. Weapons and "countermeasures" are completely interchangeable. The only thing that putting something in #Countermeasures does is add the "countermeasure" flag to that weapon.
Though note that for some stupid reason, somebody else added code so that any weapon with the "countermeasures" flag that's launched by the player is affected by "$Player Countermeasure Life Scale:". So you'll have to set that to 1.0 or launching a decoy missile will have a different lifetime than when fired by the AI (and may vary based on difficulty level). The bug will only take effect if you use "Lifetime Min" or "Lifetime max", if you use "Lifetime" it won't be scaled (Further increasing my :wtf: factor at this change)
I'd wondered why none of the missions in the intervening years had taken advantage of this to give the player mine weapons or launch decoy missiles or try to create plasma countermeasures with the laser renderer, I guess this explains why.
And, yes, I did check the code and it looks like countermeasures dropped from the ship will support FOF.
-
I'd wondered why none of the missions in the intervening years had taken advantage of this to give the player mine weapons or launch decoy missiles or try to create plasma countermeasures with the laser renderer, I guess this explains why.
Decoy missiles? Oh that'll work well for Renegade Legion mod if I ever both to go back to that. Has some other interests at the moment. But anyway, don't want to derail this thread.
I've thought about using tow cables or something for a mission or two of mine too. But haven't looked into it too hard at all.
-
Oooh, now we're getting somewhere. So would it be possible to make two different kinds of countermeasure (thinking flares and chaff here) that would both be launched when I press X? Or does that only work for one weapon/countermeasure type at a time?
And if you have multiple entries in the #Countermeasures section, how is it determined which one is used? Is it set up in ships.tbl? Ah, that at least is in the wiki.
-
You mean I can actually implement the Federation Self Replicating Mine I've been aching for all these years (without eating up a seconday slot)?
:D
Think of a Pirahna, but instead of a explosive are it spawns a large mine cluster (the mines won't make more, but they will reapair themselves if not destroyed. i don't rememebr if that part is doable)
-
You mean I can actually implement the Federation Self Replicating Mine I've been aching for all these years (without eating up a seconday slot)?
:D
Think of a Pirahna, but instead of a explosive are it spawns a large mine cluster (the mines won't make more, but they will reapair themselves if not destroyed. i don't rememebr if that part is doable)
You can do the self-repairing bit with a script, assuming it's not possible already and hitpoints work the same way as ships.
fsrm-sct.tbm
#Conditional Hooks
$Application: Freespace 2
$State: GS_STATE_GAME_PLAY
$On Frame: [
--#####VARIABLES#####
--Maximum hitpoints of the weapon
local FSRMHitpointsMax = 50
--Repair rate (hitpoints per second)
local FSRMRepairRate = 20
--#####NOTOUCH#####
--Store number of hitpoints repaired this frame
local repairedThisFrame = FSRMRepairRate * ba.getFrametime()
--Go through and update weapons
local numWeapons = #mn.Weapons
for i=1,numWeapons do
local wpn = mn.Weapons[i]
if wpn.Class.Name == "Federation Self Replicating Mine" and wpn.HitpointsLeft > 0 and wpn.LifeLeft > 0 then
wpn.HitpointsLeft = math.max(wpn.HitpointsLeft + repairedThisFrame, FSRMHitpointsMax)
end
end
]
#End
Oooh, now we're getting somewhere. So would it be possible to make two different kinds of countermeasure (thinking flares and chaff here) that would both be launched when I press X? Or does that only work for one weapon/countermeasure type at a time? And if you have multiple entries in the #Countermeasures section, how is it determined which one is used? Is it set up in ships.tbl? Ah, that at least is in the wiki.
It only works for one at a time, although building off the spawning idea, you might be able to make a weapon that splits apart immediately after being launched to create the countermeasure.
That'd be a little inefficient, you could also try and work around it with scripting...or you could turn it into a tactical element, where it takes a half-second for the 'countermeasure' to actually burst into flares and chaff. So launch when the missile is too close to your ship and it ignores the package entirely.
-
Hmmm smoke electors for multiplayer would be nice too :)
-
This is nice and all (seriously, I appreciate the input), but does anyone have any other ideas for a grappling hook? Are there any tricks to keep rendering a weapon model after it has hit? Would it be possible to script a cable model between the player and enemy? I don't really know the limits of the scripting system or how to begin to use it, though admittedly I haven't really investigated that option yet.
-
#Conditional Hooks
$Application: Freespace 2
$On Game Init: [
GrappleHook.Grapples = {}
GrappleHook.HookModel = "hook"
function GrappleHook.addGrappleHook(weapon, shipHit)
local newGrapple = {}
--Don't add grapples if
--(1) Nil was passed
--(2) Weapon is dead
--(3) Weapon has no parent
if not weapon or not weapon:isValid() or not weapon.Parent:isValid()
return
end
--This is inaccurate - no real way to tell where this
--grapple came from on the source ship right now, besides
--explicitly telling it in the script
newGrapple.startShip = weapon.Parent
newGrapple.StartLocalPosition = ba.newVector(0, 0, 0)
--This is more accurate
newGrapple.EndShip = shipHit
newGrapple.EndLocalPosition = weapon.Position - shipHit.Position
--I don't remember if this is right or not
newGrapple.EndLocalOrientation = weapon.Orientation * shipHit.Orientation:getTranspose()
table.insert(GrappleHook.Grapples, newGrapple)
end
function GrappleHook.doFrame()
for k,g in pairs(GrappleHook.Grapples) do
--Renders grappling hook in the same position that it hit at
gr.drawModel(GrappleHook.HookModel, g.Endship.Position + g.EndLocalPosition, g.EndShip.Orientation * g.EndOrientation)
end
end
]
$Application: Freespace 2
$State: GS_STATE_PLAY_GAME
$On Frame: [
GrappleHook.doFrame()
]
$Application: Freespace 2
$Weapon Class: Grapple hook
$On Ship Collision: [
GrappleHook.addGrappleHook(hv.Weapon, hv.Ship)
]
#End
Something like that. That's more thinking out loud than anything tried-and-true - I haven't tested it, so it may even have some parse errors - but you can at least use it to get started. Right now it looks like the main limit you might run into is a lack of being able to get a normalized vector to represent the facing of one object to another.
That might just be my own sketchy math knowledge in this department, though, and you could certainly write those functions if they aren't built-in already (and you know about 3D vectors).
-
I took a class involving 3d vectors... a year ago. I'll have to play around with that I guess, when I have the time. (lol, free time)
-
So, I've learned a little about the scripting system since last we discussed this, and now I'm trying to turn WMC's thrown-together script up there into something that will work. I'm getting a LUA ERROR: [string "scripting.tbl - On Game Init"]:1: attempt to index global 'GrappleHook' (a nil value), which I think is because GrappleHook isn't defined as anything when the game starts. How exactly would I put in a dummy value or something so as to get around this?
-
I was juuuuust about to finish a new beam weapon flag that allows for tractor beams.... the week they announced the code freeze. :o
As you noticed, damage of <=0 or mass of <=0 gets ignored. Once I remove those limitations, on symmetrical objects (like crates) a negative mass makes for a cool 'dragging' effect. But this illustrates another issue: the current 'whack' code makes beams push things sideways, like a baseball bat. I can fix this with a flag, but the problem is (besides the code freeze :p) I can think of situations where it'd be nice for the weapon to exhibit BOTH behaviors at once. So that means TWO flags (unless there's another way?)
Another minor problem is I still can't think of a good name for the flag :lol:
-
Anchor? :D
-
Plus I'm not even trying to use a beam anymore since it doesn't look good for my purposes.
-
Well if anyone continues to work on the Beam version pls keep me in mind (I will need it later!)
One of the short vid clips I want to make to mess with people's minds are Sinclair in a Star Fury about to ram the Grey Council ship and getting "pulled" away at the moment BEFORE the Minbari grab him. :)
This is what you see flash across your screen...
[attachment deleted by Tolwyn]
-
I had an idea for tractor beams for purposes of towing. It would require code changes however. You simply use a floating dockpoints... that is dockpoints that sit some distance away from the hull. You may be able to get away with making one only for the vessel doing the towing, and use one of the existing dockpoints on the vessel being towed. The part needing code changes is a beam-fire-continuous sexp, which would have an argument to disable or enable the effect with the same sexp. Then you make a beam with the tractor-beam effect (visual), no damage, no mass, and no impact effect. Then make sure that the beam widens, combine the right sound effects, and you've got your tractor beam.
-
You can fudge a grappling hook fairly easily. Just find a grappling hook and some fudge, then pour the fudge on the grappling hook.
Seriously though, a real grappling hook would have rope physics and all that stuff.