Author Topic: Stable branch scripting system  (Read 8741 times)

0 Members and 1 Guest are viewing this topic.

Offline WMCoolmon

  • Purveyor of space crack
  • Moderator
  • 213
Stable branch scripting system
I've merged the new scripting system into the unstable branch. I tested it using some of my test scripts and Nuke's atmospheric flight script, and everything seems to be working. The scripting system should be identical to the one in the unstable branch; if a scripting function or variable depended on a feature not already implemented in the stable branch, I implemented as much of the feature was required.

As a result, the build also includes aspects of Goober's shield system, turret muzzleflashes, weapon detonation radius, and forced-range flak. (Note that I did not implement the SEXPs for these features, and I only implemented the table entry for detonation radius) If you have any particular concern about one of these features, post here and I'll see about getting it fully implemented.

Please report back any new bugs in this build. Or, if you test the build and can't find any problems, report that too. :p

Enter the world of stable-branch scripting
-C

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Stable branch scripting system
cool. the current version of the freespace rts works under it. il have to test my other scripts as well. this probably also means that nukemod '08 will most likely come with some scripts. any chance rtt made it in?
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 Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Stable branch scripting system
As a result, the build also includes aspects of Goober's shield system
Well that's not good.  If it includes the MAX_SUBSYSTEM bump it'll break pilot files.

 

Offline WMCoolmon

  • Purveyor of space crack
  • Moderator
  • 213
Re: Stable branch scripting system
I didn't bump it, but I did add the MODEL_SUBYSTEM_SHIELD_GENERATOR define. I've removed that and reverted SUBSYSTEM_UNKNOWN back to 11. I also commented out the portion of the code where it checks for the status of the shield generator. Is that sufficient to avoid pilotfile corruption?

(I haven't uploaded a new build yet, I still need to go through the other features in the build)
-C

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: Stable branch scripting system
I think so.  The main problem was that the #define bump resized the allocation of subsystems (or something related) in the pilotfile.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Stable branch scripting system
So player.IsMulti or some equivalent isn't in this system, and won't be?  Just want to doublecheck before I abandon the menu system that needed it altogether.
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 WMCoolmon

  • Purveyor of space crack
  • Moderator
  • 213
Re: Stable branch scripting system
It's not in right now. I need to be sure that porting the scripting system over to the stable branch has not introduced bugs before I commit it, and up until that point, I'd rather hold off on committing stuff. The more people who can vouch for this build, the better.

If player.isMulti is that pivotal to you, remind me this weekend. I have zero time this week, a pivotal midterm worth a quarter of my grade in a class, etc, so I will probably forget (although I did write it down). The main reason that I removed the player code is because it looks as though the list of players is used in at least two different ways and may change between states, and frankly, I haven't worked with it enough to feel comfortable putting it in scripting until I know more about it. If you just need that one variable for the current player, that may be a small enough scale that I can implement that this weekend and worry about the rest later.

For testing purposes, I could also implement a function for you in the testing library that checks just that one thing, or possibly move the old pilot code over to that library if you need more than that. I wouldn't count on it being there for future releases, but it would let you keep working on the menu until I came up with the final implementation.

I really don't want to make the move to the new system force people to abandon scripting based on the old system, but I also want to make sure that what I implement is forwards-compatible, since I now have to assume that mods are going to base public releases on it. So I will try to get all the stuff in the old system fully implemented eventually, but not until I'm confident that it's not going to be something that I'll be forced to change with new code or might even stand in the way of new code, or that might force me into a crappy workaround in a future version. In this particular case, I know that taylor has plans to significantly upgrade the pilot files, and that could influence the player code. So I need to PM him about this (and that I will do tonight) and figure out if any of the related code is going to change.
-C

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Stable branch scripting system
It's not pivotal in that I need it immediately, I just wondered if there were plans to put it in the new system, since I only know of the cockpit redux build that had it.  If it made it into 3.6.10 that would be great, I think it would really help development, but hopefully we don't need it any sooner than 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 WMCoolmon

  • Purveyor of space crack
  • Moderator
  • 213
Re: Stable branch scripting system
I went ahead and implemented it. It also gives me an excuse to release a build without the shield system define ;) :

http://fs2source.warpcore.org/temp/wmc/C02162008s_d.zip

See "ts.isCurrentPlayerMulti".
-C

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Stable branch scripting system
Awesome, I'll work on converting this script and see if there's anything else it needs, hopefully not though.
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 chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Stable branch scripting system
Btw, this worked just fine.  Got the script converted, used that function and it works like a charm.
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 WMCoolmon

  • Purveyor of space crack
  • Moderator
  • 213
Re: Stable branch scripting system
Excellent. :)
-C

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Stable branch scripting system
Seeing as how you've already got the code for both of these, any way I could get a build with the stuff from this build combined with the stuff from this one?

http://www.hard-light.net/forums/index.php/topic,51599.msg1051903.html#msg1051903

Assuming you think that's anything near stable, and don't plan on any major changes to its functionality.  At least for the Star Wars version.  Not so concerned about the HW stuff.  If it'd be a lot of trouble don't worry about it.
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 WMCoolmon

  • Purveyor of space crack
  • Moderator
  • 213
Re: Stable branch scripting system
The warpin stuff needs another going over, and it needs to be tested under 64-bit Linux. In order to make the code as neat as I did, which lets me get away with adding new warpin effects as if they were...something really easy to add (an analogy escapes me at the moment :p)...I had to do some polymorphism and object-oriented programming. That may not fly with memory management, since I know that there's a debug malloc function, but I'm not sure if there's a debug new function. I'm also not sure if polymorphism has ever been tested anywhere else in the code before.

I also want to double-check that there will never ever be any null pointer problems.

EDIT: And scripting stuff is tied in with Taylor's Xt builds. He found a bug and a fix under 64-bit Linux, that got implemented into his local tree and I did implement it into mine, but I don't know when he's planning on committing that and I just want one copy of the scripting to go into SVN initially.

So in theory I could merge the two right now. In practice, it's not going to happen until one or the other gets committed, at which point I'll start testing both in the same build.
-C

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Stable branch scripting system
No problem, sounds good to me.
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 chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Stable branch scripting system
Ok, I finally got around to being able to test multiplayer with this build, and it appears to not be working either.  Hunter and myself have both tried hosting, and connecting via either search or by manually entering an IP in the multiplayer options.  No game server shows up in the list for either of us, and we're both fairly certain we have our port forwarding taken care of.  We then tested over Hamachi, and still nothing.  I don't know if this is going to be too big of a concern, as from what I can tell Taylor's builds seem to have working multi, and when he releases a build with the scripting hopefully that doesn't change, but the last couple builds of yours I've tried seem to have this same issue.  I don't know if anyone else has tried multi with these builds or not.

Ok, so, apparently, this build may have worked with FS2 files, but not with our separate standalone.  I don't know what would cause it to not work with a standalone.  I do know, that while it's open in the game finder, the multi.log file is growing fairly rapidly, spitting out the following:

Code: [Select]
FreeSpace Multi Log - Opened Thu, Mar 06, 2008  at 08:44PM
----
----
----


03/06 20:44:25~   psnet_init() detected lan connection
03/06 20:44:25~   psnet_get_ip() reports IP : 0.0.0.0

03/06 20:44:25~   Receive buffer set to 4096

03/06 20:44:25~   Send buffer set to 4096

03/06 20:44:25~   Error on IPX startup 10047

03/06 20:44:25~   Network
03/06 20:44:25~   Found no RAS connections
03/06 20:44:37~   multi_level_init()
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Invalid socket id passed to nw_NewCloseSocket() -- -1
03/06 20:44:37~   Error 10038 doing a socket select on read

03/06 20:44:37~   Error 10038 doing a socket select on read

03/06 20:44:37~   Error 10038 doing a socket select on read

03/06 20:44:37~   Error 10038 doing a socket select on read

03/06 20:44:37~   Error 10038 doing a socket select on read

03/06 20:44:37~   Error 10038 doing a socket select on read

03/06 20:44:37~   Error 10038 doing a socket select on read

03/06 20:44:37~   Error 10038 doing a socket select on read

03/06 20:44:37~   Error 10038 doing a socket select on read

03/06 20:44:37~   Error 10038 doing a socket select on read

...

03/06 20:45:09~   Error 10038 doing a socket select on read

03/06 20:45:09~   Error 10038 doing a socket select on read



----
----
----
FreeSpace Multi Log - Closing on Thu, Mar 06, 2008  at 08:45PM


At some point in there I hit the refresh button a couple of times.  The log looks pretty much the same regardless of a debug build or not, and nothing else behaved differently in game related to this either.  The strange thing is that multi has worked with this set of files before, the only real difference is the build and the scripting.tbl file.
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 taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: Stable branch scripting system
Quote
03/06 20:45:09~   Error 10038 doing a socket select on read
That is a PSNET2 top level processing error message, so an issue there would most likely prevent you from talking with other clients over the network.  It is separate from FS2NetD though so any FS2NetD traffic would probably still work.  That code has never really been changed by the SCP so it's unlikely that this has a direct cause.

The 10038 error indicates that one of the values passed to the select() command was invalid.  That shouldn't be possible considering the code, so my only guess would be that it is a memory overwrite which is causing it.  Unfortunately that makes it much more difficult to track down.  You might try attaching the scripting.tbl in question though, or at least a comparable one that demonstrates the same issue, so that we can try debugging with that.  Perhaps the script itself is triggering some previously unknown bug.

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
Re: Stable branch scripting system
I thought about that after posting.  Here it is.

Code: [Select]
#Conditional Hooks
$State: GS_STATE_MAIN_MENU
$On Frame: [

   if init == nil then

   randomChoice = {"BTL-A4 Y-Wing","T-65c X-Wing","T.I.E. Fighter","TIE/In Interceptor"} --Put your ship classes in quotes here


-- getShipClass seems to be replaced with ShipClass[]
   numChoices = table.getn(randomChoice)
--   randomShip = tb.getShipClass(randomChoice[math.random(1,numChoices)])
   randomShip = tb.ShipClasses[randomChoice[math.random(1,numChoices)]]
   shipName = randomShip.Name
   init = 42
   end

   logo = "fotg"   --This is the name of the logo you want. No extension needed

   imgWidth = gr.getImageWidth(logo)
   imgHeight = gr.getImageHeight(logo)
   screenWidth = gr.getScreenWidth()
   screenHeight = gr.getScreenHeight()
   renderX1 = screenWidth * 0.01
   renderX2 = screenWidth * 0.8
   renderY1 = screenHeight * 0.1
   renderY2 = screenHeight * 0.9
   rendermidX = (renderX1+renderX2)/2
   imageX = (screenWidth*0.5)-imgWidth/2
   imageY = 0



   rotConst = 7 --Modify this to make it turn faster to slower

   if rotate_pct then
      rotate_pct = rotate_pct +  rotConst*ba.getFrametime()
      if rotate_pct > 100 then
         rotate_pct = rotate_pct - 100
      end
   else
      rotate_pct = 40
   end

   randomShip:renderTechModel(renderX1, renderY1, renderX2, renderY2, rotate_pct)
   gr.setColor(255,255,255)
   gr.drawString(shipName,rendermidX-gr.getStringWidth(shipName)/2,renderY2)

   --Handle using the middle mouse to force random ship selection
   --Because we can only tell whether the button was down, we have to check for it last frame
   --by setting the variable middle_was_down
--ms.isButtonDown became io.isMouseButtonDown, and takes an enumeration now
   if not middle_was_down then
--      middle_was_down = ms.isButtonDown("Middle")
      middle_was_down = io.isMouseButtonDown(MOUSE_MIDDLE_BUTTON)
      force_random = middle_was_down
--   elseif ms.isButtonDown("Middle")==true then
   elseif io.isMouseButtonDown(MOUSE_MIDDLE_BUTTON)==true then
      middle_was_down = true
      force_random = false
   else
      middle_was_down = false
      force_Random = false
   end


   --Function to handle a section every frame
   section = function(name, event, num)
      --MENU COLOR
      margin = gr.getScreenHeight()/6
      gr.setColor(255, 255, 255)

      --Get corner coordinates for this box
      x1 = gr.getScreenWidth()-180
      y1 = margin*num+20
      x2 = gr.getScreenWidth()-21
      y2 = margin*num+55

      --When the mouse is OVER this section...
-- ms.getX and getY are now in io, as io.getMouseX and getMouseY
--      if ms.getX() > x1 and ms.getX() < x2 and ms.getY() > y1 and ms.getY() < y2 then
      if io.getMouseX() > x1 and io.getMouseX() < x2 and io.getMouseY() > y1 and io.getMouseY() < y2 then
         --Draw the dark green insides
         gr.setColor(96, 96, 96)
         gr.drawRectangle(x1, y1, x2, y2, true, false)

         --Draw the little target lines now
         gr.setColor(255, 255, 255)
         x = x1+(x2-x1)/2
         y = margin*num

         --Top target line
         gr.drawLine(x, y, x, y+15)

         --Bottom target line
         y = margin*num+65
         gr.drawLine(x, y, x, y+15)

         --Left target line
         x = gr.getScreenWidth()-200
         y = margin*num+40
         gr.drawLine(x, y, x+15, y)

         --Right target line
         x = gr.getScreenWidth()-16
         gr.drawLine(x, y, x+15, y)

         --Handle the button click
--         if ms.isButtonDown("Left") then
         if io.isMouseButtonDown(MOUSE_LEFT_BUTTON) then
            ba.setEvent(event)
            gr.drawRectangle(x1, y1, x2, y2, false, false)
         end
      end

      --Draw the outline
      gr.drawRectangle(x1, y1, x2, y2, false, false)

      --Color should always be pure green, so I'll skip setting the color for the name
      gr.drawString(name, x1 + ( (x2-x1) - gr.getStringWidth(name) ) / 2, margin*num+35)
   end

   if ts.isCurrentPlayerMulti()==true then
      section("Multiplayer", "GS_EVENT_MULTI_JOIN_GAME", 0)
   else
      section("Ready Room", "GS_EVENT_NEW_CAMPAIGN", 0)
   end
   section("Campaign Room", "GS_EVENT_CAMPAIGN_ROOM", 1)
   section("Tech Room", "GS_EVENT_TECH_MENU", 2)
   section("Barracks", "GS_EVENT_BARRACKS_MENU", 3)
   section("Options", "GS_EVENT_OPTIONS_MENU", 4)
   section("Exit", "GS_EVENT_QUIT_GAME", 5)

   gr.drawImage(logo, imageX, imageY)

]
#End

Also attached for ease of downloading.

I wondered about where it would come from, since it only seemed to happen when multi didn't seem to be working.  When it was working I saw no such error in the log.  It also spits them out rather fast, the log grows about 20 kb a second while that window is open.

[attachment deleted by ninja]
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 Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: Stable branch scripting system
There is something a tad odd here...

For example in function 'drawMonochromeImage(Image name/Texture handle, x1, y1, [x2, y2, X start, Y start, Mirror]) ' i used '20' as 4th argument and game complained that it needed to be boolean... Same happened in drawImage() function. Not that i absolutely needed to use it but the boolean thing is odd. Also an attempt to use 'tracer' option with particles triggers an error with stable branch
Code: [Select]
Assert: geometry_map[index].laser == false
File: grbatch.cpp
Line: 624
Happens only with debug builds and i can't see anything wrong with the rendering when using release build so that is a tad odd thing too.
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: Stable branch scripting system
Also an attempt to use 'tracer' option with particles triggers an error with stable branch
Code: [Select]
Assert: geometry_map[index].laser == false
File: grbatch.cpp
Line: 624
Happens only with debug builds and i can't see anything wrong with the rendering when using release build so that is a tad odd thing too.
All of that stuff has changed in my Xt builds, so try one of those and see if it still happens.  Well, I know that it can't happen since that setup no longer exists, but you can just see if it handles the tracers properly and make double sure there is nothing script related at fault.