Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Shivan Hunter on November 02, 2011, 11:09:21 pm
-
I was amazed they weren't in there already, and I think they'd be incredibly useful. It's not essential (I'm implementing a Taylor series now), but it would be nice.
-
yay! trig functions!
really just call a script eval and run math.cos(x)
-
What would you use them for?
-
You can use them to simplify calculations checking whether an object is facing another object (though there's a simpler way to do it). IIRC, only the player has a check to see if it's pointing at something, and you can try to use trig functions to evaluate angles and stuff.
It would probably be better if you added either Sin or Cos since there are so many ways to transfer between them. Tan (x) and one of the others would probably be more useful than having both Sin and Cos.
EDIT: clarifications.
-
I thought we had the "facing" sexp (in the "training" category) for that.
-
Last time I tried it, it worked only for the player. But I wasn't thorough. I'll test it again tonight.
-
Ah, sorry. Yes, "facing" only checks from the player perspective. "is-facing" (found under ship status) however can be used to check arbitrary objects.
-
I missed it when I was looking for one then. Scratch one possible use. I can't think of any others unless you want to measure angles between ships, and that probably is only useful in scripting a Capital ship battle. There's probably ways to work around it, too.
-
Use a SEXP to spawn a weapon pointing in a particular direction.
-
The problem is that sexps can only work with integers. So this would have to be either a discrete function cycling between 0, -1, and 1, or a modified function like sin(x)*1000.
EDIT:
Use a SEXP to spawn a weapon pointing in a particular direction.
You can already do this by specifying target coordinates.
-
Er, I worded that wrong. I meant to spawn a weapon at some position, but pointing at an arbitrary ship somewhere else. Is that already possible? But I guess you'd want inverse trig functions for that anyway.
-
really just call a script eval and run math.cos(x)
ಠ_ಠ
The problem is that sexps can only work with integers. So this would have to be either a discrete function cycling between 0, -1, and 1, or a modified function like sin(x)*1000.
:(
Oh well. What I was working on didn't turn out all that well anyway, in part for this exact reason.
-
I've been able to hack decimals before. If you want to represent .389 for example just use:
/
389
1000
I haven't tried it for every sexp, but it seemed to work with no problem when I wanted it to place cameras for cut scenes.
-
really just call a script eval and run math.cos(x)
ಠ_ಠ
dont give me that i cant script crap its only one line of code!
-
Er, I worded that wrong. I meant to spawn a weapon at some position, but pointing at an arbitrary ship somewhere else. Is that already possible? But I guess you'd want inverse trig functions for that anyway.
Definitely possible -- and you can even point it at nothing in particular. For one example, take a look at the second version of DEM: Interlude.
I've been able to hack decimals before. If you want to represent .389 for example just use:
/
389
1000
I haven't tried it for every sexp, but it seemed to work with no problem when I wanted it to place cameras for cut scenes.
Do enlighten us with an example mission.
-
Ok. It's really rather simple.....
I was making an example mission, and then I discovered that it's not good to put parentheses in Event names, especially when they are referenced by is-event-true-delay. Let me just correct a few mistakes and I'll have it up.
-
Cyborg17: That would certainly be useful!
really just call a script eval and run math.cos(x)
ಠ_ಠ
dont give me that i cant script crap its only one line of code!
yes, I should make a script to execute a single line of code
hmm
-
Nevermind. I was completely wrong. I thought it seemed too obvious for you guys to miss. Camera skips forward one unit instead of half a unit. Time also rounds up and down.
-
Er, I worded that wrong. I meant to spawn a weapon at some position, but pointing at an arbitrary ship somewhere else. Is that already possible? But I guess you'd want inverse trig functions for that anyway.
Definitely possible -- and you can even point it at nothing in particular. For one example, take a look at the second version of DEM: Interlude.
The Beta spazzout? That seems to use a constant angle of 90. Am I looking at the right thing? I'm talking about get-angle-to-ship or somesuch, so that a mine can spawn a missile pointed in whichever direction the ship is in.
-
Oh, I see what you mean. Yes, that would require a get-[pitch/bank/heading]-to-location sexp, which is definitely doable, but not in SCP yet.
-
(I'm implementing a Taylor series now)
WHY
incidentally this seems as good a place as any to say taht I've been toying with the idea of trying to create SEXP libraries for FRED. You can do ****tons with SEXPs alone but last time I checked (to be fair it has been a while) there really aren't very many good mechanisms for SEXP abstraction. What you would do is define a bunch of generic SEXPs to do something (eg a minefield) and save it as, I dunno, a `.fred' file and then there would be an options screen in the mission editor for including libraries. Then whenever you wanted a minefield (or whatever) all you would have to do is include your appropriate library and use your custom SEXP. Then when you save the mission a text processor would run through your mission events and expand your custom sexp with its arguments to the actual implementation defined in the library.
only problem is that I haven't had the time to work on it any more than thinking about doing it.
-
Time to SEXP up some danmakku...
-
Oh, I see what you mean. Yes, that would require a get-[pitch/bank/heading]-to-location sexp, which is definitely doable, but not in SCP yet.
Bah, it looks like it's necessarily to make the problem more specific. It's not possible to get a single pitch/bank/heading from an object to a given set of coordinates, because that problem has multiple solutions.
However, getting the orientation angle of a particular ship, disregarding any external points or destinations, can be done. Use the get-object-[pitch/bank/heading] sexps.
-
(I'm implementing a Taylor series now)
WHY
I saw where a trig function was not, and said, "no. This will not do."
Besides, it didn't work anyway because of the aforementioned decimal problem.
incidentally this seems as good a place as any to say taht I've been toying with the idea of trying to create SEXP libraries for FRED. You can do ****tons with SEXPs alone but last time I checked (to be fair it has been a while) there really aren't very many good mechanisms for SEXP abstraction. What you would do is define a bunch of generic SEXPs to do something (eg a minefield) and save it as, I dunno, a `.fred' file and then there would be an options screen in the mission editor for including libraries. Then whenever you wanted a minefield (or whatever) all you would have to do is include your appropriate library and use your custom SEXP. Then when you save the mission a text processor would run through your mission events and expand your custom sexp with its arguments to the actual implementation defined in the library.
only problem is that I haven't had the time to work on it any more than thinking about doing it.
That sounds awesome