Hard Light Productions Forums

Modding, Mission Design, and Coding => The FRED Workshop => Topic started by: MetalDestroyer on August 18, 2011, 07:15:33 am

Title: Use Cloaking device as long as primary doesn't fire
Post by: MetalDestroyer on August 18, 2011, 07:15:33 am
Well,

I got the SEXP working on AI. However, for unknown reason, the mission crash after several minutes.
I use "Every-time" sexp to engage cloak and decloak. I'm suspecting the "every time" sexp conditional to be the cause of this behavior. If so, how to add some sort of permanent cloak as long as the AI ship doesn't open fire ?

Here, the mission file. Don't forget to open the file with notepad to replace ship by Freespace 2 one.
 

[attachment deleted by ninja]
Title: Re: Use Cloaking device as long as primary doesn't fire
Post by: mjn.mixael on August 18, 2011, 08:28:02 am
I haven't looked at the mission yet, but try this.

Quote
When-Argument (trigger count 999999999999999999999999999999999999999999999999 and interval 0)
  • any-of
    • list of ships
  • or
    • has-primary-fired
      • <argument>
      • 0
      • 50
    • has-primary-fired
      • <argument>
      • 1
      • 50
    • decloak sexp
      • <arguemnt>

When-Argument (trigger count 999999999999999999999999999999999999999999999999 and interval 0)
  • any-of
    • list of ships
  • or
    • not
      • has-primary-fired
        • <argument>
        • 0
        • 7000
    • not
      • has-primary-fired
        • <argument>
        • 1
        • 7000
    • cloak sexp
      • <arguemnt>

No idea if this will work as I just wrote it real quick here.. but worth a shot?
Title: Re: Use Cloaking device as long as primary doesn't fire
Post by: MetalDestroyer on August 18, 2011, 08:52:31 am
The AI doesn't cloak at all. Perhaps, I mess somewhere since I really don't know how to use the value of "any-of" sexp operator

Code: [Select]
$Formula: ( when-argument
   ( any-of "Alpha 2" "Alpha 3" )
   ( not
      ( primary-fired-since
         "<argument>"
         0
         6000
      )
   )
   ( ship-effect
      "Cloak"
      2800
      "<argument>"
   )
   ( ship-stealthy "<argument>" )
)
+Name: AI Cloak
+Repeat Count: 1
+Trigger Count: 999999
+Interval: 0

$Formula: ( when-argument
   ( any-of "Alpha 2" "Alpha 3" )
   ( primary-fired-since
      "<argument>"
      0
      50
   )
   ( ship-effect
      "Decloak"
      2800
      "<argument>"
   )
   ( ship-unstealthy "<argument>" )
)
+Name: AI Decloak
+Repeat Count: 1
+Trigger Count: 999999
+Interval: 0
Title: Re: Use Cloaking device as long as primary doesn't fire
Post by: mjn.mixael on August 18, 2011, 09:13:10 am
If you don't have an answer by the time I get home tonight (like 12 hours from now).. I'll actually open up FRED and see what I can figure out.
Title: Re: Use Cloaking device as long as primary doesn't fire
Post by: MetalDestroyer on August 18, 2011, 09:19:44 am
Ok, thanks.
Title: Re: Use Cloaking device as long as primary doesn't fire
Post by: MetalDestroyer on August 18, 2011, 11:48:04 am
Ok, I found out why the mission crash with "every-time" sexp conditional. I forgot to add a condition if the ship is alive. When, the AI is destroyed, the game crashed when trying to execute the cloak script.

Now, the script works perfectly.

However, since you made me discover the when-argument/everytime-argument. It will be really cool if I can use this sexp conditional instead of everytime. I tried but no success. The AI won't cloak.

Code: [Select]
$Formula: ( every-time
   ( and
      ( not
         ( is-destroyed-delay 0 "Alpha 2" )
      )
      ( not
         ( primary-fired-since
            "Alpha 2"
            0
            6000
         )
      )
      ( = @Alpha2CloakStatus[0] 0 )
   )
   ( ship-effect "Cloak" 2800 "Alpha 2" )
   ( ship-stealthy "Alpha 2" )
   ( modify-variable
      @Alpha2CloakStatus[0]
      1
   )
)
+Name: AI Cloak v2
+Repeat Count: 1
+Interval: 1

$Formula: ( every-time
   ( and
      ( not
         ( is-destroyed-delay 0 "Alpha 2" )
      )
      ( primary-fired-since "Alpha 2" 0 50 )
      ( = @Alpha2CloakStatus[0] 1 )
   )
   ( ship-effect
      "Decloak"
      2800
      "Alpha 2"
   )
   ( ship-unstealthy "Alpha 2" )
   ( modify-variable
      @Alpha2CloakStatus[0]
      0
   )
)
+Name: AI Decloak v2
+Repeat Count: 1
+Interval: 1
Title: Re: Use Cloaking device as long as primary doesn't fire
Post by: karajorma on August 18, 2011, 09:49:22 pm
Basic bug fixing steps, try adding a message to that event to see if it's triggering and the problem actually lies with the cloaking. At least that way you know whether the problem is your event or the SEXP itself. :)