Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: Slasher on March 25, 2008, 01:54:00 pm

Title: The "facing" SEXP and other problems
Post by: Slasher on March 25, 2008, 01:54:00 pm
In this hypothetical mission there is Target and the player.

I want to arrange things so that whenever the player is looking directly at Target, Target is tagged.  Whenever the player is looking away from Target, Target no longer shows up as tagged.

However, after having been facing Target for a given number of seconds straight, Target is motivated to do something.  Something = Anything.

If the player looks away from Target (not tagged), then things reset, so to speak.  I've gotten as far as the first part, now I just need to get Target to do Something. 


Title: Re: The "facing" SEXP and other problems
Post by: Mobius on March 25, 2008, 02:00:44 pm
Ok...

Use every-time, ship-tag and ship-untag.

As for the number of seconds, use a variable.

---------------------

every-time

not

facing
Player
Target

modify-variable
NumberOfSeconds
0

----------------------------

when (high repeat count, interval time 1 second)

facing
Player
Target

modify-variable
NumberOfSeconds
+
  NumberOfSeconds
  1

--------------------------------

when

= / >

NumberOfSeconds
<insert value>

do-something

:)
Title: Re: The "facing" SEXP and other problems
Post by: Slasher on March 25, 2008, 02:18:48 pm
Thanks Mobius, so far this seems to work.

Now, if there were forty Targets instead of one.  What would be the least work intensive way of making this work.  For example, if facing Target 22 for a while, Target 22 will do this. 

Also, is there any way to force every-time to evaluate only once every second, or specify a delay of any kind for this SEXP? 
Title: Re: The "facing" SEXP and other problems
Post by: Mobius on March 25, 2008, 02:25:40 pm
Depends...uhm...

Are you going to pick up a random Target? In that case a random argument will greatly reduce the work. can you please be more specific? What do you want to do, exactly?
Title: Re: The "facing" SEXP and other problems
Post by: Slasher on March 25, 2008, 02:31:50 pm
When facing Target X for Y seconds, Target X should go kill something.  But after Target X goes off to do this, success or failure, Target X will revert to his docile state after Z seconds. 

Basically I want the player to be able to invoke this behavior in Target X as many times in a mission as s/he wishes.  The effect will always wear off, but can be reintroduced upon Target X at the player's leisure. 

Say Target X goes hostile against Target A.  Target X doesn't do a good job and Target A is still alive.  Player looks at Target X again to get the ball rolling. 
Title: Re: The "facing" SEXP and other problems
Post by: Slasher on March 25, 2008, 02:47:54 pm
I can get the target to revert to its original state, it's just imbuing the target with the desire to move again, to repeat those results, that's proving problematic right now.
Title: Re: The "facing" SEXP and other problems
Post by: Mobius on March 25, 2008, 03:54:16 pm
Ok, got it. You know, I think to be good at FREDding  :drevil:

If there are many Targets and you want to pick up a random one, create a string variable and use:

when-argument

random-of

<arguments>

<insert condition>

modify-variable
SpecialTarget
 <argument>

And replace the variable when necessary.

As for the rest...

I use string variables to set certain conditions, like "sensors jammed"(<condition to send the message> and variable Communications set to <Ok/Possible> to make the message appear...the variable becomes "NotOk/NotPossible" when an AWACS calibrates its jammers...no messages are sent in that case)

every-time

or

-and

--not
facing
Player
Target

--string-equals
StatusCheckTarget (this is a string variable)
NotActive (=sample of string the variable can be set to)

- =
NumberOfSeconds
<value3> (this is number of seconds 3, obviously greater than 1 and 2. It's equal to value2+1)


modify-variable
NumberOfSeconds
0

----------------------------------

When you activate the target use:

modify-variable
StatusCheckTarget
Active

----------------------------------

The variable NumberOfSeconds should always keep increasing(the event above will reset it to 0 when needed)

when (highest repeat count, interval time 1 second)

-or

--and
---facing
Player
Target

---not
NumberOfSeconds
>
value1-1


--string-equals
StatusCheckTarget
Active


modify-variable
NumberOfSeconds
+
  NumberOfSeconds
  1

----------------------------------

every-time

=
NumberOfSeconds
<value3> (obviously: value1 < value 2 < value3. value3 is value2+1)


modify-variable
StatusCheckTarget
NotActive

clear-goals (or whatever you want to reset the Target. You may wish to move it back to its precedent position, use waypoints-once for that...you can tell it to ignore its target and many other things)


Please tell me if it works  :nervous:
Title: Re: The "facing" SEXP and other problems
Post by: Slasher on March 27, 2008, 06:30:12 am
EDIT: Most of this has been rendered irrelevant now, see two posts down.

I have a new problem.  I can't define the second argument for the change-iff SEXP as a variable, specifically a string variable.  I tried to strong arm my way around this by editing it in via WordPad, but now the game crashes.  I'm not sure how to proceed.
Title: Re: The "facing" SEXP and other problems
Post by: Slasher on March 27, 2008, 07:14:41 am
EDIT: Most of this has been rendered irrelevant now, see next post down.

Sorry to keep convoluting this further, hopefully the madness will stop here. 

If I want to "convert" one target, as it were, and then immediately convert another, and I want the effect to run on its own clock for each individual target, how could I do this without a handful of events and variables for each ship?

For example, if Target A is converted, then two seconds later I convert Target B, Target A should revert back to its original state two seconds before Target B.  I don't want Target A, Target B....Target Z all reverting back at the same moment.

[edit]:  Okay, I'm pretty sure now there is no really short way of doing this.  In order to get what I want, each individual ship would need its own timer (variable) to keep track of how long it has been friendly. 

I could use a single event to reset each fighter to hostile as its timer gets to a set value, but each ship would require its own variable (value set at mission-time that it became friendly) and thus each eligible ship requires its own event. 

FRED2 does not want to let me define the arguments for any-of as number variables.  WordPad allows me to circumvent this problem for the time being, however.

Still working on this...

[shadow edit2!]:  Okay, FRED2 also does not like me using <argument> in the modify-variable SEXP.  If all arguments of any-of are number variables, or for that matter any variable, will using the arguments to any-of for modify-variable cause bad things to happen? 
Title: Re: The "facing" SEXP and other problems
Post by: Slasher on March 27, 2008, 09:21:51 am
Yes, I think being unable to use number variables as arguments to any-of (and similar SEXPs, I'd assume) is causing the problem here.

(http://img255.imageshack.us/img255/7952/ughwf5.png) (http://imageshack.us)

Variables Neon1 et al. are given a value of whatever the mission time is when they have been in the player's view for a certain amount of time.  These are all defined in other events.  I wish it didn't take that many events, but I haven't come up with a better solution. 

Now, the editor didn't let me use those variables as arguments to any-of, so I had to edit them in using WordPad.  As such, when it came time to reset any of those variables to zero using modify-variable, FRED2 wouldn't let me specify "<argument>" as the variable to be modified.  Again, I WordPadded it into the mission.  This doesn't seem to work as it should in-game, however, and while it could be due to any number of causes, I believe this is the culprit.

Is there any way around this?
Title: Re: The "facing" SEXP and other problems
Post by: Slasher on March 28, 2008, 04:08:19 am
I tried using the 3-23-2008 build of FRED2 which I think was the latest to see if maybe the older version I was using was the problem.  No-go there either.  Is this an oversight I should put into Mantis or was there a reason to not let number variables be referenced in the xxxx-argument SEXPs?
Title: Re: The "facing" SEXP and other problems
Post by: Mobius on March 28, 2008, 11:52:42 am
How do you place variables?

I right click on "string" and select "replace variable".

I can't replace a variable with <argument> when using modify-variable either. I suggest creating another variable and use:

modify-variable
NewVariable
<argument>

...then use "NewVariable" for future references :)


In your face, N00ber. Looks like I can give more than colors :P
Title: Re: The "facing" SEXP and other problems
Post by: Slasher on March 28, 2008, 05:55:48 pm
In other words, use a new variable and set its value as whatever the real variable I'm trying to modify is? 

The problem is there are any number of "timer" variables that may need to be reset to zero at a given time.  It might be zero variables, it might be one, it might be fifty (not likely, just an example).  When a certain criteria is met, a ship's timer variable is given a value of whatever the mission time is at that moment.  This is defined in a separate event for each ship.  The event I show above will check all the time to see if the values of those variables is greater than 15 + the mission time.  If it is, it resets them to zero.  At least, this is how it should work, but every-time-argument and any-of hate my guts.

Basically, each ship timer should work completely independently of another.  In other words, if I start the timer running on one, it should get its full fifteen seconds regardless of whether or not another ship's fifteen seconds is almost up.  If they all reset to zero at once, this doesn't work.

I know this is still doable, it'll just require an extra event for each eligible ship so long as the argument and any-of SEXPs remain b0rked.  :/

Mobius, I can't thank you enough for sticking through all that.  Even though I didn't come to the solution I wanted, you did help me come to a solution and eliminate the unworkable alternatives.  Don't ever let anyone tell you you're good for just colors!  :) :yes:
Title: Re: The "facing" SEXP and other problems
Post by: Mobius on March 29, 2008, 10:26:32 am
You could use the string variable I mentioned above for that. When it becomes Active/NotActive, thanks to one of the events posted above, the timer will be easily set to 0.

You should be able to store the values in variables for every single target...you might wish to create a new series of variables and add the SEXP modify-variable again to store an "absolute value". I hope you're not going to have 50 targets(lol), everything should be easy to handle with a reasonable number of targets...

I'd suggest you to create a new series of variables and name them properly(so that you can't risk confusion) :)
Title: Re: The "facing" SEXP and other problems
Post by: Slasher on April 07, 2008, 09:06:49 pm
Yeah, that's the conclusion I came to.  It would just require a lot more events that I wanted, but you have to work within the confines of the engine I guess.
Title: Re: The "facing" SEXP and other problems
Post by: Mobius on April 08, 2008, 02:27:50 pm
I'd like to see the results ;)
Title: Re: The "facing" SEXP and other problems
Post by: Galemp on April 08, 2008, 03:26:04 pm
This needs to go into Karajorma's FAQ under Fred Gymnastics. :jaw:
Title: Re: The "facing" SEXP and other problems
Post by: Mobius on April 09, 2008, 01:11:16 pm
Lol...

This will hopefully be useful should I want to join a team as FREDder :nervous: :D
Title: Re: The "facing" SEXP and other problems
Post by: Snail on April 09, 2008, 02:15:25 pm
150kb missions :wtf:
Title: Re: The "facing" SEXP and other problems
Post by: Mobius on April 09, 2008, 02:36:49 pm
De Gustibus Non Disputandum Est.