Hard Light Productions Forums
Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: Spoon on August 13, 2010, 04:37:12 pm
-
Right now we don't have a sexp that can check what type of weapon a ship has in its primary or secondary banks. Battuta and I came up with some fun ideas that would require a sexp like this.
Possible yes/no ?
-
Yes, want this please! Would allow so many amazing things and (yes, those dangerous dangerous words) I suspect it wouldn't be hard.
-
Can already be done in Lua can't it? (never thought I'd hear myself say that)
-
Very possibly, but if this was available FRED-side it would unlock an endless combination of weapons that simply can't be done in table alone.
-
I could use this too. In fact I asked about something requiring it some time ago. It was suggested that I hack it with variables (though I didn't bother to figure out how).
-
I could use this too. In fact I asked about something requiring it some time ago. It was suggested that I hack it with variables (though I didn't bother to figure out how).
Which is only kinda possible if your weapon has an ammo count anyway.
A nice simple sexp would do away with all the ugly rounabout ways of hackish variables :ick:
-
Right now we don't have a sexp that can check what type of weapon a ship has in its primary or secondary banks. Battuta and I came up with some fun ideas that would require a sexp like this.
Possible yes/no ?
Impossible. There's no way to return a string in game.
However an
is-primary-weapon
-ship name
-weapon name
-bank (optional)
would be very easy to implement.
-
Right now we don't have a sexp that can check what type of weapon a ship has in its primary or secondary banks. Battuta and I came up with some fun ideas that would require a sexp like this.
Possible yes/no ?
Impossible. There's no way to return a string in game.
However an
is-primary-weapon
-ship name
-weapon name
-bank (optional)
would be very easy to implement.
That would be ideal. We don't need it to return a string, just to check if the weapon in a given bank is (one weapon selected from a list of weapons in weapons.tbl).
-
So you'd prefer the bank argument to not be optional and have it work with a list of weapons instead? That's do-able but messier as I'd have to set the option of -1 to check all banks.
-
Didn't JAD do this?
-
So you'd prefer the bank argument to not be optional and have it work with a list of weapons instead? That's do-able but messier as I'd have to set the option of -1 to check all banks.
I'm not sure I"m quite following you. Could you lay out what you have in mind? Your original suggestion seems to be able to do everything that was present in my suggestion.
-
Ahhh. Never mind. I appear to have misread your post. That said there is an issue with the SEXP I noticed while I was reading your post and I thought that you'd noticed the same one.
The problem is that every SEXP argument has a type it can be a ship name, subsystem name, string, number (positive or positive/negative), message priority or whatever. But there is no way for Freespace to determine the type of the argument. Freespace simply assumes that FRED has written out the arguments in a certain order. This actually limits us in what we can make a SEXP do (and greatly limits what improvements we can make to existing SEXPs for that matter).
Version 1
is-primary-weapon
-ship name
-weapon name
-bank (optional)
This is what I described at first. You give the name of the weapon and the ship and it will check if the weapon is there. If you give a bank it would only check that bank. If you want to check more than one ship you'd have to use an <argument> for the ship name. If you want to check multiple ships for multiple weapons it gets rather complicated. You'd have to use multiple SEXPs or <arguments> within <arguments>.
Version 2
is-primary-weapon
-weapon name
-ship 1 <--------------- Start looping at this point
-ship 2
Moving the ship name below the weapon name means that I can now make the game loop through a list of ships instead of simply having one. It will return true if ALL of them carry the weapon. I can use <argument> to make the SEXP work with multiple weapons for multiple ships. Note that the option to specify a bank has vanished.
Version 3
is-primary-weapon
-weapon name
-weapon bank
-ship 1 <--------------- Start looping at this point
-ship 2
As above but now you can specify a weapon bank too. However the bank is no longer optional. You must include the bank which means I'd need to code in a Weapon Bank type if one doesn't exist. This makes coding this SEXP take twice as long. However I'm not the kind to be slapdash with SEXPs so since any SEXP like this should include a method to specify the bank, this is the one I'd have to do. If I was feeling lazy I might simply use a number and have -1 mean all banks but quite frankly I find that rather sloppy coding too.
So why you might ask can't I just code this
is-primary-weapon
-weapon name
-ship 1 <--------------- Start looping at this point
-ship 2 <----------------End loop
-weapon bank (optional)
Well the problem is that there is no way for FS2 to determine the type of argument and realise that you're talking about weapon banks and not a ship called 1, 2 or whatever bank number you are looking for. There's no way of telling it "This isn't a ship. End the loop and move on to the next piece of code."
Version 4
is-primary-weapon
-ship name
-weapon bank
-weapon 1 <--------------- Start looping at this point
-weapon 2
Same as 3 but this time you loop through weapons on one ship and use <argument> if you want to do that for multiple ships.
That means that version 3 or 4 is probably what you're going to get as they're much more flexible than the other two.
-
I'm not going to be picky (beggars can't be choosers :p ), either of these will do for me :nod:
-
:bump:
Was wondering if there is any update to this. I have a campaign idea, but it is dependent on this sexp
-
Can already be done in Lua can't it? (never thought I'd hear myself say that)
would be nice if we could call more than 32 characters of lua from a sexp :D
you usually get around this by writing a function in global init and then call it from the sexp (this also allows you to implement some idiotproofing), unfortunately the whole function call including arguments must fit into 32 characters. minimizing the arguments required, and keeping the function name to a minimum of characters, its still pretty tough to use directly. i kinda wish we had mission embedded scripts so you could put the lua right in the mission file and wouldnt need any other tables for the code to work. such script would need to work with the sexps. youd probibly want hooks for mission init and end, and one for when a sexp is evaluated (this could be ommitted if you just call functions with the existing sexp, but it doesnt get around the character limit).
-
:bump:
Was wondering if there is any update to this. I have a campaign idea, but it is dependent on this sexp
I've not had much time for coding recently. It is on the list of things to do so if you don't have it by the end of next week, remind me.
-
would be nice if we could call more than 32 characters of lua from a sexp :D
There's a general limit on the length of the text of a sexp_node to 32 characters (as set by TOKEN_LENGTH, sexp.h:20).
I fear bumping this could break the network packets that let SEXPs work in multiplayer... but I'm not so across that part of the SEXP system. Perhaps Karajorma could give some details here?
-
I'm pretty certain it would but I don't have the code in front of me at the moment to double check.
-
:bump:
Was wondering if there is any update to this. I have a campaign idea, but it is dependent on this sexp
I've not had much time for coding recently. It is on the list of things to do so if you don't have it by the end of next week, remind me.
Great, Thanks :nod:
-
I'm pretty certain it would but I don't have the code in front of me at the moment to double check.
still, if this turns out to be a hard limit with no way aroud it. if you could embed a majority of the script in the mission, and call it from the sexps with a function call (or a number of function calls) to functions defined in the mission file itself, then your mission could run lua scripts without any dependency on external files. i think that would be a pretty awesome feature. you could see various scripted features as part of a single mission, rather that a massive mod. you also wouldnt have to bog down general scripts from mission specific stuff.
-
Reminder for Kara :p
(If its already in and I missed it, feel free to whip me)
-
Good timing. I was just about to choose my coding project for today. :D
EDIT : Try this (http://fs2downloads.com/Misc-Downloads/Builds/has-x-weapon.7z) out.
I renamed the SEXP to Has-x-weapon instead since that made a little more sense to me. If you remember the discussion on the previous page, I implemented the 4th version of the SEXP since I felt that would be the one that was most useful when combined with when-argument SEXPs.
-
Sweet
Will give this a try asap :nod:
-
Great. Let me know it it works so I can submit it to SVN.
-
Tested it, seems to work fine :D
One minor nitpick though. If you assign a gunbank but then change the weapon type, it switches back to <all weapon banks>
-
Hmmmm. I suspect I know the cause for that but it might take me a while to figure out how to fix it.