Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: FUBAR-BDHR on February 02, 2007, 06:24:05 pm

Title: variable event timing - is it possible?
Post by: FUBAR-BDHR on February 02, 2007, 06:24:05 pm
Ok here's the situation.  I have a standard hull regeneration routine in a repeating event.  Every so many seconds the hull increases by 1%.  Now here's the fun part I want that time to be variable based on difficulty.  I tired setting a variable based on the difficutly level and dividing 1 by that varialbe but FS2 seems to just ignor fractional values.  Apparently a ships damage can go down by less than 1% but can't got up by 1/5% or 1/4% ect.  Can't seem to put a variable in the interval time so that's apparently out.  I could just do the opposite and add the difficulty variable to the hull but a 5% jump is not only really noticable but a bit extreme.  I'm thinking about chained events but remember pulling my hair out trying to get them to not freak out when used with repeating events.  Only other option I see right now is an event for each difficulty level.  But when you multiply that by the number of ships that's an extra 30 repeating events.  Pretty sure all those extra repeating events would cause problems with people running on older systems.  Anyone have a better idea or know a way around this?
Title: Re: variable event timing - is it possible?
Post by: Turey on February 02, 2007, 06:35:59 pm
If you can damage by partial percents, but not increase, why not simply add 1% to the hull, then damage by a partial percent?

For example, if you were trying to do this:
Very Easy: Increase by 1%
Easy: Increase by 1/2%
Medium: Increase by 1/3%
Hard: Increase by 1/4%
Insane: Increase by 1/5%

Do this instead:
Very Easy: Increase by 1%
Easy: Increase by 1%, damage by 1/2%
Medium: Increase by 1%, damage by 2/3%
Hard: Increase by 1%, damage by 3/4%
Insane: Increase by 1%, damage by 4/5%
Title: Re: variable event timing - is it possible?
Post by: karajorma on February 02, 2007, 06:45:28 pm
Set Difficulty Variable
when-argument
-any-of
--easy
--medium
--hard
--insane
-skill-level-at-least
--<argument>
-modify-variable
--RepairSpeed[1]
-- +
---RepairSpeed[1]
---1

Repair Based On Difficulty
when <----- Repeating event, interval of at least 1 second.
- =
--mod
---mission-time
---RepairSpeed[1]
--0
-repair-subsystem
-You know the rest



The first event is basically just a fancy way of setting the variable to have a range of values from 1 for very easy to 5 for insane. You can set that manually if you're not on FS2. The fancy stuff is in the second event. Basically it looks at the mission time and works out if that is exactly divisible by the repair speed. That basically means that you get the event to trigger every second on very easy and every 5 seconds on insane.
Title: Re: variable event timing - is it possible?
Post by: FUBAR-BDHR on February 02, 2007, 06:51:04 pm
That would be perfect just one small problem on my end.  I'm making the missions retail compatable.  The repeating chained events seem to work in testing so far.  At least with one ship.  Just worried about FS2 going nuts with 7 of them.  I've seen it before.

My bad Turey just pointed out that I missred your post.  I though repair-speed was a sexp.  I think what I did was along the same lines. 

Here's what I'm testing now:

$Formula: ( when
   ( true )
   ( modify-variable
      @L1[0]
      ( + @L1[0] 1 )
   )
)
+Name: Event name
+Repeat Count: 999999
+Interval: 1
+Team: 0

$Formula: ( when
   ( = @L1[0] @skill[3] )
   ( repair-subsystem
      "GTC Leviathan 1"
      "Hull"
      1
   )
   ( modify-variable @L1[0] 0 )
)
+Name: Event name
+Repeat Count: 999999
+Interval: 1
+Chained: 0
+Team: 0

skill is the skill in reverse oreder and L1 is the ship so I would have L1 through L6 and one other variable.
Title: Re: variable event timing - is it possible?
Post by: karajorma on February 02, 2007, 06:59:00 pm
Why do you need more than one event for the second bit? Surely you could just have one single event repair all the ships?
Title: Re: variable event timing - is it possible?
Post by: FUBAR-BDHR on February 02, 2007, 07:02:41 pm
No actually I can't.  I have to check each ship to make sure it's damaged.  Retail didn't like adding 1 to a ship alreay at 100.

This just reminded me of another old quarky thing in retail that I'm wondering if it has been fixed.  Nested when statements. Like this


when
-->=
---->regen(1)
---->5
-->when
----->hits-left
--------><shipname>
----->hull  = hull +1 (got tired of counting arrows)

Title: Re: variable event timing - is it possible?
Post by: karajorma on February 02, 2007, 07:19:46 pm
In that case my solution is the better one of the two. You'll only need 4 events to set the variable and one for each ship. With yours you'll need 2 for each ship.

Mine also has the advantage that you don't have to use mission-time in every event (or that you can use mission-time+rand) which means you can have the ships repair at different times rather than having  all 6 ships repair at 5,10,15 seconds etc


Nested When events do work in FS2_Open (I've seen them used in Raider Wars for instance) but I tend to avoid them most of the time because they don't work very well with when-argument
Title: Re: variable event timing - is it possible?
Post by: FUBAR-BDHR on February 02, 2007, 07:58:19 pm
Yours might be better but I already redid it using mine.   :D   Turned out only 6 of the 7 ships are based on skill level.  7th one regenerates fast no matter what.  Now to find a few victims eh I mean testers.
Title: Re: variable event timing - is it possible?
Post by: karajorma on February 03, 2007, 02:04:44 am
*sulks*

I'm still sticking my solution in the cookbook :p
Title: Re: variable event timing - is it possible?
Post by: Mobius on February 03, 2007, 05:34:41 am
Yours might be better but I already redid it using mine.   :D   Turned out only 6 of the 7 ships are based on skill level.  7th one regenerates fast no matter what.  Now to find a few victims eh I mean testers.

:P

*sulks*

I'm still sticking my solution in the cookbook :p

New FRED section of The FAQ? :)



Regenerating ships during a mission is quite...unusual. I did it just two times in early FREDding attempts.
Title: Re: variable event timing - is it possible?
Post by: karajorma on February 03, 2007, 05:55:39 am
New FRED section of The FAQ? :)

I have a few answers I've read or given over the last few months bookmarked for addition to the cookbook.
Title: Re: variable event timing - is it possible?
Post by: Mobius on February 03, 2007, 06:15:45 am
Ok here's the situation.

...The GTD Aquitaine... :)


Should you call it FREDbook or something similar?
Title: Re: variable event timing - is it possible?
Post by: karajorma on February 03, 2007, 08:39:44 am
A cookbook is a term for examples of coding solutions for specific problems. Which is exactly what the FRED Cookbook is. It's just a little thin on recipes at the moment :)
Title: Re: variable event timing - is it possible?
Post by: Mobius on February 03, 2007, 08:55:34 am
I'm hungry...
Title: Re: variable event timing - is it possible?
Post by: karajorma on February 03, 2007, 09:40:23 am
Here's one you may have missed then :D Should keep you from getting too hungry until I can get BtRL out and take a look at the FAQ.

http://www.hard-light.net/forums/index.php/topic,44483.msg908119.html#msg908119