Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: bigchunk1 on April 23, 2010, 10:39:12 pm

Title: Ditecting hull integrity of ships in FRED2 SCP
Post by: bigchunk1 on April 23, 2010, 10:39:12 pm
This probably has a simple answer, but I am unable to use the hits-left sexp in freed 2. I tried making a simple sexp with a when command in the events manager eg

 when
    -true               <-(want to change to hits-left)
    -do nothing

I click on "true", click replace operator then click status and then when I mouse over hits-left it is greyed out. Why won't the program let me use the sexp? I even looked up an old article http://www.rainbowsedge.net/FreeSpace/faqs.html which reads as follows.

Q: How can I set up a ship to depart after it's hull is down to say, 20%?
A: Use "hits-left" in a "when" event.

I don't think I am trying to do anything abnormal. All i want to be able to do is detect when a capitol ship is under a certain percentage of health so that I can trigger an event. I would prefer not to use time to try and "guess" when the ship will be low on health. I have been at this for a fiew hours now and this is my first post. My plea to slove my problem. Any help would me much appreciated so I can complete the mission I am working on. I am using FRED2_OPEN 3.6.10
Title: Re: Ditecting hull integrity of ships in FRED2 SCP
Post by: karajorma on April 23, 2010, 10:59:27 pm
Hits-left returns the percentage of hitpoints the ship has left.

This means

when
-hits-left
--Ship Name

means nothing. It simply returns the hitpoints % the ship has. At the start of the mission this will be 100%. So you're basically saying

When
-100

Which as you can see means nothing at all.

What you need to do use the Less Than (<), Greater Than (>) or Equals (=) operators (use this one with care!*) first so that the game knows whether you want the hitpoints to be more or less than the value you enter.

when
- <
--hits-left
--- Ship-Name
--20

That example comes true when the ship has less than 20% hull.

*you should not use = with hits-left in most cases. Certain weapons damage the ship instantly from 22% to 19% which means you never actually hit 20%. <21% is the same as =20% for almost everything you'd want to do.
Title: Re: Ditecting hull integrity of ships in FRED2 SCP
Post by: Droid803 on April 23, 2010, 11:02:40 pm
I wouldn't use = though, since stuff sometimes take damage too fast and skip % altogether.
Title: Re: Ditecting hull integrity of ships in FRED2 SCP
Post by: karajorma on April 23, 2010, 11:11:30 pm
Yeah. I corrected it to add that. :) For other SEXPs which return a number value you can use = though.
Title: Re: Ditecting hull integrity of ships in FRED2 SCP
Post by: General Battuta on April 23, 2010, 11:13:51 pm
These are under the 'arithmetic' menu, by the way.
Title: Re: Ditecting hull integrity of ships in FRED2 SCP
Post by: bigchunk1 on April 24, 2010, 01:07:45 am
That explains why it was greyed out.

Thanks, I'm amazed how quickly the forums here move.