Author Topic: how can I fudge a grappling hook?  (Read 5360 times)

0 Members and 1 Guest are viewing this topic.

Offline redsniper

  • 211
  • Aim for the Top!
how can I fudge a grappling hook?
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. Reply in this thread from now on please.
« Last Edit: August 15, 2008, 11:09:20 pm by redsniper »
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline Herra Tohtori

  • The Academic
  • 211
  • Bad command or file name
Re: how can I fudge a grappling hook?
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).
There are three things that last forever: Abort, Retry, Fail - and the greatest of these is Fail.

 

Offline Getter Robo G

  • 211
  • Elite Super Robot Pilot
Re: how can I fudge a grappling hook?
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:

"Don't think of it as being out-numbered, think of it as having a WIDE target selection!"

"I am the one and ONLY Star Dragon..."
Proof for the noobs:  Member Search

[I'm Just an idea guy, NOT: a modeler, texturer, or coder... Word of advice, "Watch out for the ducks!"]

Robotech II - Continuing...
FS2 Trek - Snails move faster than me...
Star Blazers: Journey to Iscandar...
FS GUNDAM - The Myth lives on... :)

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Re: how can I fudge a grappling hook?
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. 
No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: how can I fudge a grappling hook?
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.
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: how can I fudge a grappling hook?
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?
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: how can I fudge a grappling hook?
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.
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: how can I fudge 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?

 :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.
-C

 
Re: how can I fudge a grappling hook?
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.

  

Offline redsniper

  • 211
  • Aim for the Top!
Re: how can I fudge a grappling hook?
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.
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline Getter Robo G

  • 211
  • Elite Super Robot Pilot
Re: how can I fudge a grappling hook?
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)
"Don't think of it as being out-numbered, think of it as having a WIDE target selection!"

"I am the one and ONLY Star Dragon..."
Proof for the noobs:  Member Search

[I'm Just an idea guy, NOT: a modeler, texturer, or coder... Word of advice, "Watch out for the ducks!"]

Robotech II - Continuing...
FS2 Trek - Snails move faster than me...
Star Blazers: Journey to Iscandar...
FS GUNDAM - The Myth lives on... :)

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: how can I fudge a grappling hook?
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
Code: [Select]
#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.
-C

 

Offline Colonol Dekker

  • HLP is my mistress
  • 213
  • Aken Tigh Dekker- you've probably heard me
    • My old squad sub-domain
Re: how can I fudge a grappling hook?
Hmmm smoke electors for multiplayer would be nice too :)
Campaigns I've added my distinctiveness to-
- Blue Planet: Battle Captains
-Battle of Neptune
-Between the Ashes 2
-Blue planet: Age of Aquarius
-FOTG?
-Inferno R1
-Ribos: The aftermath / -Retreat from Deneb
-Sol: A History
-TBP EACW teaser
-Earth Brakiri war
-TBP Fortune Hunters (I think?)
-TBP Relic
-Trancsend (Possibly?)
-Uncharted Territory
-Vassagos Dirge
-War Machine
(Others lost to the mists of time and no discernible audit trail)

Your friendly Orestes tactical controller.

Secret bomb God.
That one time I got permabanned and got to read who was being bitxhy about me :p....
GO GO DEKKER RANGERSSSS!!!!!!!!!!!!!!!!!
President of the Scooby Doo Model Appreciation Society
The only good Zod is a dead Zod
NEWGROUNDS COMEDY GOLD, UPDATED DAILY
http://badges.steamprofile.com/profile/default/steam/76561198011784807.png

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: how can I fudge a grappling hook?
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.
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: how can I fudge a grappling hook?
Code: [Select]
#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).
-C

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: how can I fudge a grappling hook?
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)
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: how can I fudge a grappling hook?
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?
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."

 

Offline Backslash

  • 29
  • Bring Our Might To Bear
Re: how can I fudge a grappling hook?
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:

 

Offline Cobra

  • 212
  • Snake on a Cain
    • Skype
    • Steam
    • Twitter
Re: how can I fudge a grappling hook?
Anchor? :D
To consider the Earth as the only populated world in infinite space is as absurd as to assert that in an entire field of millet, only one grain will grow. - Metrodorus of Chios
I wept. Mysterious forces beyond my ken had reached into my beautiful mission and energized its pilots with inhuman bomb-firing abilities. I could only imagine the GTVA warriors giving a mighty KIAAIIIIIII shout as they worked their triggers, their biceps bulging with sinew after years of Ivan Drago-esque steroid therapy and weight training. - General Battuta

 

Offline redsniper

  • 211
  • Aim for the Top!
Re: how can I fudge a grappling hook?
Plus I'm not even trying to use a beam anymore since it doesn't look good for my purposes.
"Think about nice things not unhappy things.
The future makes happy, if you make it yourself.
No war; think about happy things."   -WouterSmitssm

Hard Light Productions:
"...this conversation is pointlessly confrontational."