Author Topic: SEXP request: Get-primary-weapon & Secondary  (Read 4419 times)

0 Members and 1 Guest are viewing this topic.

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
SEXP request: Get-primary-weapon & Secondary
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 ?
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: SEXP request: Get-primary-weapon & Secondary
Yes, want this please! Would allow so many amazing things and (yes, those dangerous dangerous words) I suspect it wouldn't be hard.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: SEXP request: Get-primary-weapon & Secondary
Can already be done in Lua can't it? (never thought I'd hear myself say that)
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: SEXP request: Get-primary-weapon & Secondary
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.

 
Re: SEXP request: Get-primary-weapon & Secondary
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).

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: SEXP request: Get-primary-weapon & Secondary
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:
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP request: Get-primary-weapon & Secondary
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.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: SEXP request: Get-primary-weapon & Secondary
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).

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP request: Get-primary-weapon & Secondary
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.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Commander Zane

  • 212
  • Spoot Knight of Anvils
Re: SEXP request: Get-primary-weapon & Secondary
Didn't JAD do this?

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Re: SEXP request: Get-primary-weapon & Secondary
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.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP request: Get-primary-weapon & Secondary
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.
« Last Edit: August 15, 2010, 04:33:53 pm by karajorma »
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: SEXP request: Get-primary-weapon & Secondary
I'm not going to be picky (beggars can't be choosers :p ), either of these will do for me  :nod:
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: SEXP request: Get-primary-weapon & Secondary
 :bump:
Was wondering if there is any update to this. I have a campaign idea, but it is dependent on this sexp
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: SEXP request: Get-primary-weapon & Secondary
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).
« Last Edit: August 27, 2010, 03:12:17 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP request: Get-primary-weapon & Secondary
: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.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Echelon9

  • 210
Re: SEXP request: Get-primary-weapon & Secondary
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?

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: SEXP request: Get-primary-weapon & Secondary
I'm pretty certain it would but I don't have the code in front of me at the moment to double check.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Spoon

  • 212
  • ヾ(´︶`♡)ノ
Re: SEXP request: Get-primary-weapon & Secondary
: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:
Urutorahappī!!

[02:42] <@Axem> spoon somethings wrong
[02:42] <@Axem> critically wrong
[02:42] <@Axem> im happy with these missions now
[02:44] <@Axem> well
[02:44] <@Axem> with 2 of them

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: SEXP request: Get-primary-weapon & Secondary
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.
« Last Edit: August 29, 2010, 12:35:06 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN