Author Topic: Stealth ships  (Read 4082 times)

0 Members and 1 Guest are viewing this topic.

Hi, is there a way beyond using SEXPs to make a stealth ship targetable by other either at a short range or by a time basis?? I've looked through the ships.tbl and there seems to be no such line. If so would it be hard to implement this in a future version, something like
$Stealth Distance: (float in meters)
$Stealth Duration: (float in seconds)
$Stealth Recharge Time: (float in seconds)
??
Thanks for your answers!

Edit: also flags like "remains locked" and "stealth lock" for secondaries in the weapons.tbl would be nice ;)
« Last Edit: November 30, 2014, 12:51:02 pm by krevett62 »

 

Offline Cyborg17

  • 29
  • Life? Don't talk to me about life....
All of those things could be done with sexps and scripting.

 
Blue Planet act 3 has some rather clever & complexe use of stealth mechanics, it might be worth investigating if you haven't already.

 

Offline Droid803

  • Trusted poster of legit stuff
  • 213
  • /人 ◕ ‿‿ ◕ 人\ Do you want to be a Magical Girl?
    • Skype
    • Steam
Would be quite straightforward to do with SEXPs alone methinks.
(´・ω・`)
=============================================================

 
I was just asking about this because I find it boring to have to SEXP in each mission you want your stealth ships involved :)
Can someone points me to the mission I shall look into BP?
Thanks.

 

Offline niffiwan

  • 211
  • Eluder Class
Using a LUA sexp library could take the pain of out using multiple sexps in each mission :)

Also, the BP2:WiH missions you're probably after are "Everything Is Permitted" and "Her Finest Hour".
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 
Have a look at bp2-18.fs2 (Nothing is True), bp2-19.fs2 (Everything is Permitted), bp2-21.fs2 (Her Finest Hour) and bp2-22.fs2 (Eye of the Storm).

And if you don't want to copy all those SEXPs across all your missions, what niffiwan linked is what you are looking for.
« Last Edit: December 02, 2014, 03:19:41 am by X3N0-Life-Form »

 
Thanks for thes answers I'll check these missions and probably learn to use Lua scripts as it seems the best way to do what I'm looking for!

 

Offline Axem

  • 211
The catch with making a sexp library as I described is that it only works for action sexp operators and not evaluation sexp operators, which is what you would need for a good stealth system.

Still you could use the stealth sexps in those WiH missions and use them as a prototype for a greater and more generic stealth system done in Lua!

 
Ok for now I didn't manage to achieve something useful with Lua scripting. I have a rather good experience with neverwinternights script system and managed to do some serious things but I have absolutly no experience in Lua and I'm quite loss for now.

Here's my problem: I'd like the script to cloak then decloak alternatively ships by classes (for exemple cloaked 20sec, then decloaked and targetable 15sec and so on...). The script must be able to handle multiple ships at once and would run continuously to check for every ship concerned. How would I start this?

Just a side question but if the player targets a ship and that ship becomes stealthy does that player lose the targeting?

Axem you seem quite proficient in Lua scripting maybe you can help me?

Thanks all.

 

Offline Axem

  • 211
Yes, if a ship becomes stealthy, any target lock is instantly broken.

If you're unfamiliar with lua scripting and FreeSpace, I would read up on the Lua Documentation, these helpful tutorials that some studly person wrote, and look through the scripting forum to see how other people have written scripts for FreeSpace.

With all that in mind, you can start to design a stealth system script. Start small and simple and slowly build your way up to a more complex solution.

Now if I were making the script, I'd have a lua table that kept track of any stealth ships,their stealth info, last time they fired a weapon etc etc and used that to activate or deactivate stealth flags.

I don't have any time to put something together but if you have any specific questions about something in lua I could try to help.

 
Ok I've already read your tutorials but I have difficulty for really understanding how the code works in FS0!

To keep using unique information about a ship can I use his signature to have a unique position in a table?
Also which condition/action should I use?

I'm starting with

$Ship type: Basilisk --I want to apply this code only to basilisk class ship
$On Frame:
[
 The code here
]

Am I going in the right direction?

Also I'm putting all of this in a xxx-sct.tbm in the tables folder.

Thanks.

 

Offline Axem

  • 211
I'm not so sure On Frame would work with Ship Type or Ship Class (Note those are different things! Ship type is stuff like "fighter" or "bomber" while ship class is the stuff like "GTF Ulysses").

$On Frame is a game-level action, which might be more suited to go under a $State: GS_STATE_GAME_PLAY conditional hook. It probably should be made clear on the wiki page what actions would work with what hooks.

But you're sort of on the right track anyway. You can definitely use the object signature to keep track of unique objects. It'd probably be a good idea to use the On Frame for things like if stealth is expiring due to a timer or if it's too close to something since it will be evaluated on every frame, and then whatever other conditional actions you would want to trigger changes in the stealth like weapons firing or other things.

 

Offline m!m

  • 211
The behavior you described sounds like it would be easier to use Lua coroutines (you can find that in the FSOLuaUtils library) but if you don't have experience with Lua yet you might want to wait until you use that. Coroutines are quite an advanced concept.

  
Ok for now I managed to mimic starlancer's behavior for basilisk (they're intended to be IA-controlled) it's very basic but it works (if they come later in mission it still works as the counter will be incremented by the loop until decloaktime gets greater than missiontime).

Code: [Select]
#Conditional Hooks

$Application: FS2_Open
$State: GS_STATE_GAME_PLAY
$On Frame:
[
local num = #mn.Ships
for i = 1, num do
ship = mn.Ships[i]
if ship:isValid() then
if ship.Class == tb.ShipClasses['Basilisk'] then
name = ship.Name
time = mn.getMissionTime()
if not decloaktime then
decloaktime = 20
end
if not cloaktime then
cloaktime = 35
end
if time <= decloaktime then
mn.runSEXP("(ship-stealthy !" .. name .. "!)")
elseif time > decloaktime and time <= cloaktime then
mn.runSEXP("(ship-unstealthy !" .. name .. "!)")
else
mn.runSEXP("(ship-stealthy !" .. name .. "!)")
cloaktime = cloaktime + 35
decloaktime = decloaktime + 35
end
end
end
end
]

#End

Each ship will have exactlyu the same sequence of cloaking/decloaking times and the script will not check for weapon usage but at least it's a start to begin with.
Also I don't like using loops like this (especially on frame) as it could be time-consuming in heavy missions.

Edit: if a moderator could move the topic to the scripting subforum it could be more appropriate ;)
« Last Edit: December 05, 2014, 10:53:52 am by krevett62 »