Author Topic: every-of is not very random  (Read 4801 times)

0 Members and 1 Guest are viewing this topic.

Offline Roanoke

  • 210
Re: every-of is not very random
I rebuild the BHX missions every time I figure out a way to shave off a few SEXP tree nodes.

I can imagine people like yourself, Karajorma, Goob etc redoing even campaigns rather than have messy, older style SEXPs when you've got these lovely new, better ways of doing things.  :p

On that point, I fancy doing some FREDing. Get's tiresome spending most of my computer time in Studio Max.

 

Offline Goober5000

  • HLP Loremaster
  • 214
    • Goober5000 Productions
Re: every-of is not very random
I can imagine people like yourself, Karajorma, Goob etc redoing even campaigns rather than have messy, older style SEXPs when you've got these lovely new, better ways of doing things.  :p

That's not the issue.  More often I redo missions (multiple times) rather than have messy, older plot or execution if I think of a new, better way of doing things. :p

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: every-of is not very random
Yep. I'll only change a mission if it will result in better gameplay. If the internals are messy cause I'm using older SEXPs then so be it.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Re: every-of is not very random
I can imagine people like yourself, Karajorma, Goob etc redoing even campaigns rather than have messy, older style SEXPs when you've got these lovely new, better ways of doing things.  :p

Kara is right. It's no fun messing with missions with no visible improvement at the end of it. I only do it with BHX becayse I have to. The more elegent the code is the less SEXP nodes and variables it uses, an invisible improvement yes, but one which makes it more likely I can add the final finishing touches to the missions without breaking the given limits.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Re: every-of is not very random
Okay, can I use when-argument/every-argument/every-of/any-of/random-of/whatever to check a list of ships and send a message every time the hits of that ships drops below a certain amount? I tried this:

Quote
$Formula: ( when-argument
   ( any-of
      "Cap 1"
      "Cap 2"
      "Cap 3"
      "Cap 4"
      "Cap 5"
   )
   ( < ( hits-left "<argument>" ) 50 )
   ( send-random-message
      "<argument>"
      "Normal"
      "bhx damage a"
      "bhx damage b"
   )
)
+Name: damage
+Repeat Count: 1
+Interval: 1
+Team: 0

But it didn't work. Only worked for the first ship to drop below 50% hull. The rest didn't send the message, and the message has <argument> in it too.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: every-of is not very random
You're using when-argument so it's only going to occur once unless you set a repeat count. (You don't mention if you have or not) However if you do it will trigger continuously because the condition will be true every time the SEXP is evaluated unless you repair the ship that is triggering it.

What you need to do is change it slighty to this

Code: [Select]
$Formula: ( when-argument
   ( any-of
      "Cap 1"
      "Cap 2"
      "Cap 3"
      "Cap 4"
      "Cap 5"
   )
   ( < ( hits-left "<argument>" ) 50 )
   ( send-random-message
      "<argument>"
      "Normal"
      "bhx damage a"
      "bhx damage b"
   )
   (invalidate-argument
      "<argument>"
   )
)
+Name: damage
+Repeat Count: 1
+Interval: 1
+Team: 0

And add a repeat count. Once you've done that it should work the way you want.

If you check the FRED Cookbook I actually have a very similar example listed. Unfortunately solution 3 won't work properly due to a bug in the random-of SEXP. I intend to fix that soon though :) Won't be of much use to you until you have more variables to play with though.

EDIT : I've just realised that I've never used when-argument within another Every-Time-Argument. If it works you could probably do the third solution on that page and not only have a message played for every ship but have a different message played for every ship. Certainly something worth trying to see if it works, no?
« Last Edit: February 24, 2006, 12:15:58 pm by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Re: every-of is not very random
I'll get back to you on this, and whether send-random-message works with the seed. Haven't forgotten. Thanks for the help above. If I can get the above code to work it will be very useful in certain circumstances. Maybe I can add a random element to what ships do if they go to low hit points? Get some of them to go kamikazi and things? :D
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline CP5670

  • Dr. Evil
  • Global Moderator
  • 212
Re: every-of is not very random
Does that work for the original problem with modify-variable?

I was going to try tricking it into thinking the argument is part of the sexp, replacing this:

modify-variable
----turrettotal
----+
--------turrettotal
--------1

with this:

modify-variable
----turrettotal
----+
--------turrettotal
--------1
--------string-to-int
------------<argument>

Although I don't yet know if this actually works.

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Re: every-of is not very random
modify-variable
----turrettotal
----+
--------turrettotal
--------1
--------string-to-int
------------<argument>

 :lol:

That you should even be considering doing that (and that I am now considering it too) I believe is conclusive proof there's something wrong with how this stuff is working. Still I'm going to experiment with this too. I don't care how horrible the hack is if it means I can replace a huge list of events with just one.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

 

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Re: every-of is not very random
Although I don't yet know if this actually works.

Tried it last night. Don't think it works.
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.

  

Offline IPAndrews

  • Disgruntled Customer
  • 212
  • This site stole my work
Re: every-of is not very random
Code: [Select]
$Formula: ( when-argument
   ( any-of
      "Cap 1"
      "Cap 2"
      "Cap 3"
      "Cap 4"
      "Cap 5"
   )
   ( < ( hits-left "<argument>" ) 50 )
   ( send-random-message
      "<argument>"
      "Normal"
      "bhx damage a"
      "bhx damage b"
   )
   (invalidate-argument
      "<argument>"
   )
)
+Name: damage
+Repeat Count: 1
+Interval: 1
+Team: 0

And add a repeat count. Once you've done that it should work the way you want.

Hey this code works, and is incredibly useful! One for your cookbook I think. I can replace so many similar events with one event that covers multiple ships this way. With certain limitations of course. The "I'll only run if I involve <argument>" thing. Oh, try adding a nested conditional in there (any conditional you care to mention) and the event will stop working. But hey, let's get positive again. It's better than nothing!   :cool:
Be warned: This site's admins stole 100s of hours of my work. They will do it to you.