Author Topic: Questions about when-argument  (Read 7084 times)

0 Members and 1 Guest are viewing this topic.

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
I see. Thanks for explaining that. I removed the repeat count and now it works! Don't know if they were related or whether it was an isolated anomaly, but it works now!
I will now list the pros and cons of what has happened so far:

Pros:
- I now have impressive-looking events that add a random element to my mission, making it more interesting and fun
- I have learned a lot about FREDding today
- I am one step closer to a demo release
- General Battuta and The_E are very helpful

Cons:
N/A

Thank you so much for your help, guys.
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Questions about when-argument
There is an issue with The E's solution which is relatively minor here but in other circumstances you could have a problem. You've kind of tripped over it with the repeat count. The issue is that you can't guarantee a maximum amount of time for the game to actually find a valid cargo. If you have 4 items of cargo you should be able to pick one after 4 loops at most. The solution here however only picks one of the options at random and there is no reason why it can't simply keep picking the 3 destroyed cargoes and ignoring the one that is intact.

For that reason I'd use this version instead. Notice this is all one event. I included the spaces for clarity.

when-argument
-random-multiple-of
      Cargo 1
      Cargo 2
      Cargo 3
      Cargo 4
-true

-when
--is-destroyed-delay
---<argument>
---0
--invalidate-argument

-when
--and
---has-arrived-delay
----Freighter
----0
---not
----is-destroyed-delay
-----<argument>
-----0
--add-goal
---Freighter
---ai-dock
---<argument>
---cargo dockpoint
---cargo dockpoint
---89
--invalidate-all-arguments

Unlike The E's solution (which it's heavily based on) this version only requires 4 repeats. Which means that after 4 * repeat delay you are guaranteed to have either picked something or had the event failed to find a cargo.

Trigger count and repeat count are another common point of confusion. Trigger count will alone do everything you need.

Trigger count says: 'This is the number of times the event can become true. It will become incomplete (and ready to trigger) again after it has become true.' Think of it as a semi-automatic gun; you're determining how many bullets there are in the clip but the trigger still needs to be pulled each time.

Repeat count says: 'Once the event becomes true, repeat its effects this number of times, at this fixed interval.' Think of it as a burst fire weapon that will fire X number of times each time the trigger is pulled once.

You're close but not quite correct. Both of them become incomplete and ready to trigger again. What is different between then is WHEN they will trigger again.

Repeat Count = Wait until the delay is over than then test again immediately. Then wait again. Do not trigger during the waiting time.
Trigger Count = Wait until the delay is over than then test again immediately. Then test every frame same as a normal event.
Both = Wait until the delay is over than then test again immediately. Then wait again. Do not trigger during the waiting time. If you run out of repeats, stop testing. If the event triggers a number of times equal to the trigger count, stop testing.

It's a small enough difference that with a 1 second delay most people don't notice that they aren't doing the same thing. Make the delay 10-20 seconds and use something like the Distance SEXPs as the trigger and you will very quickly see exactly how they differ.

Both counts actually have the correct name. The Repeat count is the number of times the game will test to see if an event has happened again before it will stop testing. The Trigger count is the number of times that test can actually come true before the game will stop testing.
« Last Edit: November 09, 2010, 12:16:51 am by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
Oh, thanks so much, karajorma! I'd actually run into the problem again where one of my transports just sits there with no orders. It might be because of what you pointed out. I'll go test it now.
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
Double post. Oh well.

Um, is there an invalidate-all-arguments SEXP? If there is, I can't seem to find it. I can get around it by simply copying the list, but yeah.

Also, for your solution, karajorma, should I set the repeat count to 4 and leave the trigger count at 1?

EDIT:

Hmmm, just tried kara's solution, and it doesn't seem to be working (and this is when none of the cargo has been destroyed). Like, my transports warp in and just sit there. :( I'm not sure what could be causing the problem, but just on a guess, in this part
Quote

-when
--is-destroyed-delay
---<argument>
---0
--invalidate-argument
Should that not be an every-time? Or am I completely misreading it?

Please help me almighty HLP.
« Last Edit: November 09, 2010, 02:03:01 am by CommanderDJ »
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Questions about when-argument
Um, is there an invalidate-all-arguments SEXP? If there is, I can't seem to find it. I can get around it by simply copying the list, but yeah.

I'm sure I added one. Probably only in 3.6.13 builds only. As you say, copying the list will work too.

Quote
Also, for your solution, karajorma, should I set the repeat count to 4 and leave the trigger count at 1?

Doesn't matter in the least which one you change to 4 as long as you set the delay to 0.

Quote
Hmmm, just tried kara's solution, and it doesn't seem to be working (and this is when none of the cargo has been destroyed). I'm not sure what could be causing the problem, but just on a guess, in this part
Quote

-when
--is-destroyed-delay
---<argument>
---0
--invalidate-argument
Should that not be an every-time? Or am I completely misreading it?

Definitely shouldn't be an every-time. Every-time has absolutely no effect on is-destroyed-delay. Bear in mind that there is very little difference between what people think every-time is for and when if you have a delay of 0 in repeats.

I'm not certain why that wouldn't work (even if your delay wasn't 0). What exactly is happening? Try adding a message to both when parts of the event as well as the main body of the when-argument and tell me which messages get set off. i.e do this

Code: [Select]
when-argument
-random-multiple-of
      Cargo 1
      Cargo 2
      Cargo 3
      Cargo 4
-true
-send-message
--TESTMESSAGE1
-when
--is-destroyed-delay
---<argument>
---0
--invalidate-argument
--send-message
---TESTMESSAGE2
-when
--and
---has-arrived-delay
----Freighter
----0
---not
----is-destroyed-delay
-----<argument>
-----0
--add-goal
---Freighter
---ai-dock
---<argument>
---cargo dockpoint
---cargo dockpoint
---89
--invalidate-all-arguments
-send-message
--TESTMESSAGE3
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
Okay, just tested it. I'll post the event here just to make sure I've got it correct. (this is slightly different to the example we've used so far, but just in terms of the number of cargo containers (there's 6 instead of 4)):
Code: [Select]
-when-argument
--random-multiple-of
---Cargo 1
---Cargo 2
---Cargo 3
---Cargo 4
---Cargo 5
---Cargo 6
--true
--training-msg
---TEST 1

--when
---is-destroyed-delay
----0
----<argument>
---invalidate-argument
----<argument>
---training-msg
----TEST 2

--when
---and
----has-arrived-delay
-----0
-----Transport
----not
-----is-destroyed-delay
------0
------<argument>
---add-goal
----Transport
----ai-dock
-----<argument>
-----topside docking (it's an Elysium transport)
-----cargo dockpoint
-----89
---invalidate-argument
----Cargo 1
...
----Cargo 6
---training-msg
----TEST 3

I'm pretty sure I copied yours word for word and just changed the number of cargoes and the name of the Transport, but yeah, it's there for reference.
This event was set with a repeat count of 6, a trigger count of 1, and a delay of 0.

What happened was I only got the first test message, and that came up in the very first second of the mission. Nothing happened when the Transport arrived. :(

EDIT: Just tried it again with normal messages, and the first message triggers like six times right at the start of the mission with no break in between them. The second and third messages still don't come up.


« Last Edit: November 09, 2010, 02:52:11 am by CommanderDJ »
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Questions about when-argument
Yeah, I just realised what the problem is and it should have been obvious. The event will trigger immediately upon the start of the mission and with a repeat/trigger count of 6 it will stop being checked after 6 frames.

Change the repeat count to as high as FRED will accept and it will work. Replacing the true at the top with the has-arrived-delay would also solve the problem.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
Oh my God, thanks so much. It works. Hah, it only took three of HLP's top people, but eventually you guys got it. Thanks for helping out a lowly FREDder. Hopefully you will soon be able to play the mission this is used in.

Now (just as an aside) suppose I wanted the event to both check if the cargo has been destroyed and if it has departed (ie docked with something else and been taken away).

I assume I'd change

Code: [Select]
--when
---is-destroyed-delay
----0
----<argument>
---invalidate-argument
----<argument>

to

Code: [Select]
--when
---or
----is-destroyed-delay
-----0
-----<argument>
----has-departed-delay
-----0
-----<argument>

Right? And would I also change the not statement in the second when accordingly? Or would that require additional fiddling?
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Questions about when-argument
That should do it.

There is a departed or destroyed SEXP though that will check both for you. :D
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
****ingdammit

Something's still not right, the transport's still not docking! However, I have an exam tomorrow, so I'd better go now. I'll sleep on it and come back tomorrow with a fresh mind for a fresh start. If the problem appears again, I'll post here and let you know. Thanks so much for giving up your time for me (that goes for all three of you). Hopefully the problem will go away by itself tomorrow and I won't have to bother anyone. If I do have to bother you, hopefully we'll get this solved fairly soon.
« Last Edit: November 09, 2010, 06:13:42 am by CommanderDJ »
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
Okay. This is working... mostly. 8 out of 10 times all my transports using this will dock successfully and leave (I have three transports doing this, one after the other, and I'll need to put in three more). The only difference between the events for the respective transports is that the first only checks if cargo is destroyed, and the other two check destroyed-or-departed. Now, the first one always works, the other two work most of the time, like I said. It seems maybe arguments aren't being invalidated properly or something. Do you want me to do the test message thing again?
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Questions about when-argument
It can't hurt. If you know how to output an argument in a message (via a variable) I'd suggest doing that in the test messages too.

Alternatively, just post the Event. I can often diagnose problems just looking at them.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
Okay. This is going to be a long post. As I said, I have three events doing this for three transports. They only differ minorly, but I'll post them all here just in case

Event 1:
Code: [Select]
-when-argument
--random-multiple-of
---Cargo 1
---Cargo 2
---Cargo 3
---Cargo 4
---Cargo 5
---Cargo 6
--has-arrived-delay
---1
---Tugboat

--when
---is-destroyed-delay
----0
----<argument>
---invalidate-argument
----<argument>


--when
---and
----has-arrived-delay
-----1
-----Tugboat
----not
-----is-destroyed-delay
------0
------<argument>
---add-goal
----Tugboat
----ai-dock
-----<argument>
-----topside docking
-----cargo dockpoint
-----89
---invalidate-argument
----Cargo 1
----Cargo 2
----Cargo 3
----Cargo 4
----Cargo 5
----Cargo 6

Event 2 (this transport comes in after the first has docked, so it checks both if the cargo has been destroyed and if it has been docked with the first transport):
Code: [Select]
-when-argument
--random-multiple-of
---Cargo 1
---Cargo 2
---Cargo 3
---Cargo 4
---Cargo 5
---Cargo 6
--has-arrived-delay
---1
---Tugboat#2

--when
---or
----is-destroyed-delay
-----0
-----<argument>
----has-docked-delay
-----Tugboat
-----<argument>
-----1
-----0
---invalidate-argument
----<argument>

--when
---and
----has-arrived-delay
-----1
-----Tugboat#2
----not
-----or
------is-destroyed-delay
-------0
-------<argument>
------has-docked-delay
-------Tugboat
-------<argument>
-------1
-------0
---add-goal
----Tugboat#2
----ai-dock
-----<argument>
-----topside docking
-----cargo dockpoint
-----89
---invalidate-argument
----Cargo 1
----Cargo 2
----Cargo 3
----Cargo 4
----Cargo 5
----Cargo 6

Event 3 (this third transport comes in after both the earlier ones have departed, so this event checks destroyed-or-departed):
Code: [Select]
-when-argument
--random-multiple-of
---Cargo 1
---Cargo 2
---Cargo 3
---Cargo 4
---Cargo 5
---Cargo 6
--has-arrived-delay
---1
---Truck

--when
---destroyed-or-departed-delay
----0
----<argument>
---invalidate-argument
----<argument>

--when
---and
----has-arrived-delay
-----1
-----Truck
----not
-----destroyed-or-departed-delay
------0
------<argument>
---add-goal
----Truck
----ai-dock
-----<argument>
-----cargo dockpoint
-----cargo dockpoint
-----89
---invalidate-argument
----Cargo 1
----Cargo 2
----Cargo 3
----Cargo 4
----Cargo 5
----Cargo 6

Okay, there's those. Now, like I said before, I'm getting inconsistency with these events. Sometimes they work and sometimes they don't. I did some testing, and it may possibly be related to interval time for some obscure reason. Here's what I've got:
For all the events' interval time set to 0, the first always works, and the second never does. The third transport never arrives as the second one never leaves so I can't test that.
When the interval time for events 1 and 3 is set to 0 and for event 2 it's set to 1, the first and second transport worked three out of three times I tested, but the third only worked once.
When the interval time for events 2 and 3 is set to 1 and for event 1 its set to zero, the first transport worked three out of three times, and I got inconsistency with both the second and third transports.
Now I don't know if this is in any way related, but yeah... it's there just in case.

Thanks for looking at it, karajorma.

[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Questions about when-argument
What repeat counts did you have for the events? What happens if you just stick the number of repeats to maximum. Also, what happens if you change the name of Tugboat#2 to something not using a '#'?
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
I removed the # from the Tugboat name, and set the repeats to maximum. They were initially at six. It's better now, only 1 time out of 8 the second transport didn't dock, and another time, the third transport didn't dock. Hmmm.
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Questions about when-argument
Do you use any mods? If not, I'd like to look at this mission.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline CommanderDJ

  • Software engineer
  • 210
Re: Questions about when-argument
I have some additional ships for the campaign, but they're not in use for this mission. I'll PM you the mission.
[16:57] <CommanderDJ> What prompted the decision to split WiH into acts?
[16:58] <battuta> it was long, we wanted to release something
[16:58] <battuta> it felt good to have a target to hit
[17:00] <RangerKarl> not sure if talking about strike mission, or jerking off
[17:00] <CommanderDJ> WUT
[17:00] <CommanderDJ> hahahahaha
[17:00] <battuta> hahahaha
[17:00] <RangerKarl> same thing really, if you think about it

  

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Questions about when-argument
Haven't had much of a look at this but I have noticed that your interval time for the 2nd two ships is 1 second rather than 1 frame. Set the interval to 0 and you may have more luck with this.

I'd suggest making a test mission just involving the cargo and tugboats to see if that has the issue too.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]