Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Scooby_Doo on December 08, 2006, 03:19:31 am

Title: Chained repeating event alone with explosion effect
Post by: Scooby_Doo on December 08, 2006, 03:19:31 am
Ok I've got a question.
I've got an event it's chained (5 delay, repeat count 10000000, interval time 30000  [is this milliseconds?])

Code: [Select]
Event Name
    - every-time
          - true
          - explosion-effect

The explosion is going off constanstly, if i switch every-time to when the it does it only once.

How do I correctly have the explosion go off at intervals?

Also is it possible to have it do it randomly, Im guessing something like this:
Code: [Select]
Event Name
    - every-time
          - <
             -rand
                -0
                -100
             -50
          - explosion-effect
Title: Re: Chained repeating event alone with explosion effect
Post by: taylor on December 08, 2006, 03:29:12 am
Repeating, chained, events don't work due to a code issue (Mantis bug #82 (http://scp.indiegames.us/mantis/view.php?id=82)).  I had that fixed at one point, but before I finally had a chance to commit the changes I realized that the timing of all events had changed and thigns were happening sooner than they were supposed to.  I have yet to figure out why that was happening, or how to get around it.  Needless to say, I never committed the code.

I don't really have a suggestion for you (since I'm not a FREDer), just giving a FYI on why the chained event which repeats doesn't (and won't) work as you need it to.
Title: Re: Chained repeating event alone with explosion effect
Post by: Scooby_Doo on December 08, 2006, 03:35:27 am
Ah ok, then it wasn't me then... I'll just have to wait till it gets fixed
Title: Re: Chained repeating event alone with explosion effect
Post by: karajorma on December 08, 2006, 04:42:12 am
Actually the big mistake is using every-time.

Every-time repeats every frame and pays no attention to whether it was triggered previously or not. You should be using a repeating when (The delay is seconds not milliseconds so make sure you change that to 30).

As for making it go off randomly if you use when and change to rand-multiple instead of rand that will work. Rand picks a random number the first time the SEXP is used. In all subsequent calls it will use the same number. Rand-multiple on the other hand will pick a random number each time it's called.
Title: Re: Chained repeating event alone with explosion effect
Post by: Scooby_Doo on December 08, 2006, 05:27:25 am
Oh it's in seconds... thats where I was going wrong. Things are looking a lot better now..

Now I've got one more question. get-object-x/y/z  returns the objects x/y/z and I see you can choose a subsystem, now how would one go about having it so it randomly chooses with subsystem to select so that the explosions don't appear to be coming out of one spot... I suppose you could just use the ships x/y/z and use a random value that attempts to match the general dimensions, but I can already see problems with that (explosions going off in empty space).

Title: Re: Chained repeating event alone with explosion effect
Post by: 0rph3u5 on December 08, 2006, 07:14:22 am
Oh it's in seconds... thats where I was going wrong. Things are looking a lot better now..

Now I've got one more question. get-object-x/y/z  returns the objects x/y/z and I see you can choose a subsystem, now how would one go about having it so it randomly chooses with subsystem to select so that the explosions don't appear to be coming out of one spot... I suppose you could just use the ships x/y/z and use a random value that attempts to match the general dimensions, but I can already see problems with that (explosions going off in empty space).

I've rather complicated solution for you (requries 2 variables (1 number variable; 1 string varibale) - and it might not work)... but it would serve the purpose if it does work


1) the explosion*
Code: [Select]
$Formula: ( when
   ( true )
   ( explosion-effect
      ( get-object-x
         "GTC Fenris 1"
         "@subsys[sensors]"
      )
      ( get-object-y
         "GTC Fenris 1"
         "@subsys[sensors]"
      )
      ( get-object-z
         "GTC Fenris 1"
         "@subsys[sensors]"
      )
      10
      10
      100
      10
      100
      0
      0
      7
   )
)
+Name: explosions on gtc fenris 1
+Repeat Count: 1
+Interval: 1
+Team: 0

2) let it dice the subsystem:*
Code: [Select]
$Formula: ( when
   ( true )
   ( modify-variable
      @dice1[0]
      ( rand 1 5 )
   )
)
+Name: dice for subsys
+Repeat Count: 1
+Interval: 1
+Team: 0

$Formula: ( when
   ( = @dice1[0] 1 )
   ( modify-variable
      "@subsys[sensors]"
      sensors
   )
)
+Name: dice to 1
+Repeat Count: 1
+Interval: 1
+Team: 0

$Formula: ( when
   ( = @dice1[0] 2 )
   ( modify-variable
      "@subsys[sensors]"
      weapons
   )
)
+Name: dice to 2
+Repeat Count: 1
+Interval: 1
+Team: 0

[...]

*this the "editor-output" of the sexps - @xxx(yy) refers to a variable

the great problem No 1. is that FRED complains that the "modify-variable" is not setting the variable to number but to string (Code restriction? Bug?)
great problem No 2. is that the outputing the subsystem via variable might not work...
Title: Re: Chained repeating event alone with explosion effect
Post by: karajorma on December 08, 2006, 08:31:26 am
The bug you mention is already in mantis. You simply need to open the mission in notepad and add a pair of quote marks around the offending term and then it starts working again.

However while once you've fixed that problem your events would work (once you added a method to make the Dice Event occur every 30 seconds) I think that your solution is much more complicated than it needed to be. The solution is to use arguments rather than variables.

(http://homepage.ntlworld.com/karajorma/FAQ/FAQ-Images/Fred-Tips/ExplodeRandomSubsystem.jpg)

Furthermore this solution has one really big advantage. If you add an

-Invalidate-Argument
--< argument >

to the event you can make each subsystem blow up only one time if you so wish. :)

Title: Re: Chained repeating event alone with explosion effect
Post by: Scooby_Doo on December 08, 2006, 05:05:18 pm
Thanks karajorma that did the trick! Now've I've got explosions going off all over the ship.  Unforunately now I realize that this was all in vain.  The ship needs to be dead before this kicks in, at which point subsystems no longer exist.  :sigh:

Title: Re: Chained repeating event alone with explosion effect
Post by: Shade on December 08, 2006, 05:07:47 pm
May be able to fudge it. Let the hull reduce normally to 1%, make it invulnerable and tell it to play dead, set off the explosions, then sabotage the hull down below 0 once you're satisfied with the fireworks.
Title: Re: Chained repeating event alone with explosion effect
Post by: Scooby_Doo on December 08, 2006, 05:39:33 pm
Thats what I pretty much have setup right now.  The only problem is the explosions should keep going off for a long period of time, probably through out the entire mission.
Title: Re: Chained repeating event alone with explosion effect
Post by: karajorma on December 09, 2006, 06:34:23 am
Sounds like a mission design problem at the moment. If you need help with the actual FREDding I'll be more than happy to point something out which would work :)