Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Snail on October 25, 2007, 12:26:57 pm

Title: SEXP hits-left-subsystem Question
Post by: Snail on October 25, 2007, 12:26:57 pm
Is there a bug in the SEXP hits-left-subsystem? In a certain campaign, I've got a friendly capital ship facing off an enemy capital ship. There are several ships attacking the enemy capital ship's main beam cannon. When the enemy ship's main beam cannon is damaged to below 70%, the enemy ship will depart. It is also set to depart should the friendly ship be destroyed.

Here's the thing: Even after integrity is below 70%, it does not depart. Only about a minute after the integrity is below 70% does the ship depart. Though it's not a fatal error, I would like to know why it's happening.

Good day.
Title: Re: SEXP hits-left-subsystem Question
Post by: TrashMan on October 25, 2007, 04:12:03 pm
How exactly did you set up the SEXP?

Write it down here so we can see it.
Title: Re: SEXP hits-left-subsystem Question
Post by: karajorma on October 25, 2007, 04:58:47 pm
The leading suspect here has to be a delay on the departure cue.

The others in the line up would be :-

Engine Subsystems below 30% (and being repaired later).
AI-Warpout orders countermanded by higher priority orders
Event isn't actually triggering when you think it is (add a message to it and see when that plays).
Title: Re: SEXP hits-left-subsystem Question
Post by: Snail on October 26, 2007, 10:21:55 am
How exactly did you set up the SEXP?

Code: [Select]
$Formula: ( when
   ( <
      ( hits-left-subsystem
         "*******"
         "turret07"
      )
      70
   )
   ( send-message-list
      "#Command"
      "High"
      "******* withdraws"
      0
   )
   ( add-goal
      "*******"
      ( ai-warp-out 89 )
   )
   ( ship-guardian-threshold
      13
      "Alpha 1"
   )
)
+Name: ******* Departs
+Repeat Count: 1
+Interval: 1
+Team: 0

Ship guardian'd Alpha 1 so that when the ship jumps out, it doesn't ram him and kill him.

Engine Subsystems below 30% (and being repaired later).
AI-Warpout orders countermanded by higher priority orders
Event isn't actually triggering when you think it is (add a message to it and see when that plays).

The Engine subsystem is never repaired, so if that is the problem the enemy ship probably wouldn't depart at all.

The enemy ship actually has no orders initially, and just sits there vaping the friendly ship's escorting cruisers. Once that is finished, the enemy ship will turn to attack the friendly ship. Usually, its main beam cannon is disabled before the escorting cruisers are destroyed. I don't think that is the problem.

There's already a message, and it seems that the game isn't constantly checking to see if its below 70%. The event is not chained, either. From what I can see, the event isn't triggering when I want it to.

EDIT:
Aww **** I hope no one saw that. :doubt:
Title: Re: SEXP hits-left-subsystem Question
Post by: TrashMan on October 26, 2007, 12:45:40 pm
HM....the event looks good from here...Havn't got a clue :confused:
Title: Re: SEXP hits-left-subsystem Question
Post by: Snail on October 26, 2007, 01:03:30 pm
HM....the event looks good from here...Havn't got a clue :confused:

Yes I is not n00b.

It seems to me that the circumstances isn't being checked constantly.
Title: Re: SEXP hits-left-subsystem Question
Post by: Mobius on October 26, 2007, 01:08:37 pm
Is there a bug in the SEXP hits-left-subsystem? In a certain campaign, I've got a friendly capital ship facing off an enemy capital ship.

INFA SA, I suppose. I'm also having strange problems(shared special hitpoints, ships whose class has changed crash the game when they jump in), there could be something wrong with FRED-INF.
Title: Re: SEXP hits-left-subsystem Question
Post by: Snail on October 26, 2007, 01:11:40 pm
I was trying to hide the fact it was INFASA. :\

But from what I know the only difference between FRED-INF and normal FRED is that the FRED-INF has boosted ship limits. But the coders are always hiding something.
Title: Re: SEXP hits-left-subsystem Question
Post by: karajorma on October 26, 2007, 01:13:35 pm
Quite frankly I doubt the problem is what you claim it is. I can't think of any reason why a SEXP would be checked inconsistently. It would either be checked or not checked.

Eliminating the SEXP as the cause is easy. Make a test mission with just one event and check if the SEXP fires when it should do. If you can that to misbehave then is when I'd start looking at the SEXP as the cause of this problem. Till then the smart money is on eliminating the mission as the cause first.

Does the message play only seconds before the ship jumps out?

And which build of FS2_Open are you using?
Title: Re: SEXP hits-left-subsystem Question
Post by: Mobius on October 26, 2007, 01:23:00 pm
And which build of FS2_Open are you using?

3.6.9, INF.
Title: Re: SEXP hits-left-subsystem Question
Post by: Snail on October 26, 2007, 01:54:48 pm
It is the SEXP. I created another test mission. The message doesn't appear until 11 minutes after I destroy the turret. :wtf:
Title: Re: SEXP hits-left-subsystem Question
Post by: karajorma on October 26, 2007, 02:11:26 pm
Post the mission and the bug in Mantis. I'll take a look at it later this evening.
Title: Re: SEXP hits-left-subsystem Question
Post by: Roanoke on October 26, 2007, 02:57:53 pm
gotta be the ship guardian ? I'd try and add a "not-facing" check instead (if that can be applied to AI ships ofcourse, haven't been in FRED for ages).

Not being funny but you did specify the correct turret ?
Title: Re: SEXP hits-left-subsystem Question
Post by: Mobius on October 26, 2007, 03:55:40 pm
It is the SEXP. I created another test mission. The message doesn't appear until 11 minutes after I destroy the turret. :wtf:

I can't believe it.

Not being funny but you did specify the correct turret ?

It could be possible(no offense), we would all prefer it to a bug. But there are too many strange things about FRED INF, too many...
Title: Re: SEXP hits-left-subsystem Question
Post by: Snail on October 26, 2007, 05:23:27 pm
Not being funny but you did specify the correct turret ?

Yes. Definitely.

Post the mission and the bug in Mantis. I'll take a look at it later this evening.

Can you pop down to Inferno Alliance Internal? The mission should be in the last page of the first non-sticky thread. Thanks.
Title: Re: SEXP hits-left-subsystem Question
Post by: TrashMan on October 27, 2007, 04:24:35 am
Heh..I never implied you're a newb Snail, sorry if you got that impression.

It's just thet even the best of us sometimes make n00bish mistakes :p
Title: Re: SEXP hits-left-subsystem Question
Post by: karajorma on October 28, 2007, 06:25:35 am
Okay. It's not a bug. Seems like the code is meant to work like that.  :wtf:


Apparently Hits-left-subsystem doesn't work the way you would think it does. If use the following SEXP

when
- <
--hits-left-subsystem
---Ship Name
---Turret 01
---90

I'd probably expect the game to trigger that as soon as the turret hits 90%. That's not what the game does though. Instead it looks at what type of subsystem this is (a turret) and then works out how much damage has been done to all the turrets on that ship and then gives you the average. What I'm wondering now is how come in 7 years of FREDding I've never noticed this! :wtf:

Apparently though I'm not the only person confused by this one though. For instance look at this piece of FREDding from bearbaiting.

Code: [Select]
$Type: Primary
+Name: GUN 1b
$MessageNew:  XSTR("Destroy Sathanas forward beam cannon 1", 1567)
$end_multi_text
$Formula: ( or
   ( =
      ( hits-left-subsystem
         "Sathanas"
         "turret01"
      )
      0
   )
   ( is-subsystem-destroyed-delay
      "Sathanas"
      "turret01"
      0
   )
)
+Invalid

I suppose if I'd looked carefully enough I might have wondered why there was a completely redundant check for the turret being destroyed if the SEXP already checks if it has 0 hits left. Now it's obvious that James Agay tested the hitpoints first and after scratching his head/screaming at the monitor over why it wasn't working he just checked if they were destroyed too.

The calculations for engines are even stranger. The game will do the averaging normally until it gets below 15%. After that as long as any engine is running the game will report any of them as being at 15% even though the subsystem may even have been destroyed and the only engine left is at 1%

From the looks of it your ship was simply remaining in the mission until all of its turrets had taken 50% damage and then it could leave. I can't really start changing the hits-left-subsystem SEXP as it's been used in who knows how many campaigns which have no doubt been balanced on the weird behaviour it displays. I will however alter the text for it in FRED and make a new SEXP that works the way you would think it should work.
Title: Re: SEXP hits-left-subsystem Question
Post by: Snail on October 28, 2007, 06:52:28 am
:wtf: Okayyyyyy...

Is there an alternative?
Title: Re: SEXP hits-left-subsystem Question
Post by: karajorma on October 28, 2007, 06:56:13 am
I should be able to cook up a working SEXP pretty easily. Part of the code does what we want. I simply need to get it to skip all the adding stuff together and taking the average nonsense.

EDIT: Posted a build (http://www.hard-light.net/forums/index.php/topic,50266.new.html#new) that should deal with the problem.
Title: Re: SEXP hits-left-subsystem Question
Post by: Goober5000 on October 29, 2007, 10:08:33 pm
Err... weird. :wtf:

Looks like the original design should have been hits-left-subsystem plus hits-left-subsystem-type.

EDIT: On further thought, maybe we should "fix" it, even though it would change the original behavior.  The reason is that this bug will show up in a very small number of cases: those being sexps which refer to a subsystem type that has more than one instance on the model (most likely engines or turrets).  Ninety-nine percent of those cases would use is-subsystem-destroyed, leaving 1% questionable.  That 1% might be a small enough margin to risk experimenting on. :)
Title: Re: SEXP hits-left-subsystem Question
Post by: CP5670 on October 30, 2007, 12:44:42 am
Now that I think about it, I sometimes did run into problems getting specified turrets on ships to stay alive using a repeating event that reset the turret's strength whenever it fell too low. I always assumed that the strength was going down too fast for the event to fire in time, but this would explain it. This was back in the retail days, when we didn't have ship-subsys-guardian-threshold.
Title: Re: SEXP hits-left-subsystem Question
Post by: karajorma on October 30, 2007, 06:24:58 am
EDIT: On further thought, maybe we should "fix" it, even though it would change the original behavior.  The reason is that this bug will show up in a very small number of cases: those being sexps which refer to a subsystem type that has more than one instance on the model (most likely engines or turrets).  Ninety-nine percent of those cases would use is-subsystem-destroyed, leaving 1% questionable.  That 1% might be a small enough margin to risk experimenting on. :)

What I did (eventually :rolleyes:) was add a 3rd argument.

By default the game will how the usual behavior. If you supply the 3rd argument (and it evaluates to true) then the game ignores type and simply works out the actual hits left of the subsystem mentioned. That way there is no need to alter the default behaviour and FREDders can still easily get what they probably want to happen.

One reason I was reluctant to actually fix it because of the way the SEXP is used in Argonautica. The SEXPs appear to repair the engine sequentially but cause of the weird design of the SEXP they'll all be repaired at the same time. It's obvious the mission has been balanced for that and if it suddenly starts taking longer to get the engines all working again that could have knock on effects. Especially if that thing about engines having to be at 30% for warpout hasn't been fixed yet. 


Title: Re: SEXP hits-left-subsystem Question
Post by: Snail on October 30, 2007, 03:51:29 pm
I wouldn't like fixes like that since we'll get newbies popping up everywhere screaming about it.
Title: Re: SEXP hits-left-subsystem Question
Post by: Mobius on March 25, 2008, 04:12:11 pm
(http://www.hard-light.net/forums/Smileys/HLP/necrodq3.png)

I'd use the other thread but N00ber5000 locked it. :doubt: (http://www.hard-light.net/forums/index.php/topic,50266.new.html#new)

That 3.6.10 build doesn't solve the problem. I have Snail's same problem in the same mission. Only difference is the value, lowered to about 50.
Title: Re: SEXP hits-left-subsystem Question
Post by: karajorma on March 25, 2008, 04:25:07 pm
Did you add the 3rd argument?
Title: Re: SEXP hits-left-subsystem Question
Post by: Snail on March 25, 2008, 04:29:46 pm
I told him over MSN but he doesn't seem to get the point.
Title: Re: SEXP hits-left-subsystem Question
Post by: Mobius on March 25, 2008, 04:32:50 pm
You mean:

-and
--hits-left-subsystem
<
<value>

--not
is-subsystem-destroyed-delay

etc. etc.


?
Title: Re: SEXP hits-left-subsystem Question
Post by: Snail on March 25, 2008, 04:33:33 pm
Yep, I think that's how it works.
Title: Re: SEXP hits-left-subsystem Question
Post by: karajorma on March 25, 2008, 04:34:37 pm
No. I mean

-hits-left-subsystem
--Ship
--Subsystem
--TRUE

If you miss the 3rd argument it goes back to being false and you end up with the strange effects I mentioned in my earlier posts.
Title: Re: SEXP hits-left-subsystem Question
Post by: Mobius on March 25, 2008, 04:35:57 pm
That

+

-and
--hits-left-subsystem
<
<value>

?
Title: Re: SEXP hits-left-subsystem Question
Post by: karajorma on March 25, 2008, 04:37:52 pm
That's not even possible. FRED simply won't accept that. Do what I posted. Add the third parameter and set it to true.
Title: Re: SEXP hits-left-subsystem Question
Post by: Mobius on March 25, 2008, 04:47:56 pm
Aaah, my mistake! The 3rd argument of the SEXP!!!

Thanks! :yes: