Author Topic: id like a couple new functions in scripting  (Read 6884 times)

0 Members and 1 Guest are viewing this topic.

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: id like a couple new functions in scripting
the goal i think is to make a freelancer style control setup.
This is included in the pilot file upgrade (which also includes a large rewrite to the io code).  Since adding a new set of control types breaks pilot files, it hasn't been added earlier.  Just FYI.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: id like a couple new functions in scripting
oh ok. it was just a thought anyway. my real goal was player operated turrets, which seems to be working. aiming is a different matter, i wanted to render a crosshair on the screen that indicates which way the turret was pointing. is there an easy way to convert an orientation matrix to a vector? if i could do that then i could just get the screen coords of that vector.

another problem. the turret apears to rotate right  no matter which way the ship is oriented. however when you fire it, if you have any roll whatsoever, the turren fires at a funky angle. both of theese problems come from the fact that i suck at calculus or whatever. oh heres the code, its based off the example in this thread, which i dont fully understand. it works with any bomber with turrets and this build.

Code: [Select]
#Global Hooks

$GameInit:

[

--all this stuff is for multires support, for getting true width and height, and for generating factors to scale coords by

w = gr.getScreenWidth()
h = gr.getScreenHeight()

if w >= 1024 then
wf = w / 1024
else
wf = w / 640
end

if h >= 768 then
hf = h / 768
else
hf = h / 480
end

dead = 15
--mousejoy function, returns a value from -100 to 100 depending on the mouse's position

mousejoy = function(deadzone)
local X = ((ms.getX() * wf) - (w/2)) * (200/w)
local Y = ((ms.getY() * hf) - (h/2)) * (200/h)

if X < deadzone and X > -deadzone then X=0 end
if Y < deadzone and Y > -deadzone then Y=0 end

return X, Y
end

--generic crosshair function

crosshair = function(x,y)
gr.setColor(0,255,0,200)
gr.drawGradientLine(x+20,y+20,x+10,y+10)
gr.drawGradientLine(x-20,y+20,x-10,y+10)
gr.drawGradientLine(x+20,y-20,x+10,y-10)
gr.drawGradientLine(x-20,y-20,x-10,y-10)
end
]

$HUD:
[

player = mn.getShipByName("Alpha 1")
mX, mY = mousejoy(dead)

gr.setColor(0,255,0,255)
gr.drawCircle(5,mX+200,mY+200)
gr.setColor(100,100,255,100)
gr.drawRectangle(100,100,300,300)
gr.setColor(128,128,0,200)
gr.drawRectangle(200-dead,200-dead,200+dead,200+dead)


mX = mX * ba.getFrametime(false) / 25
mY = mY * ba.getFrametime(false) / 25

if player ~= nil then
for i=1, player:getNumSubsystems() do

ori = player[i].Orientation
ori.h = ori.h + mX
player[i].Orientation = ori

ori = player[i].GunOrientation
ori.p = ori.p + mY

if ori.p > 0 then
ori.p = 0
elseif ori.p < -math.pi/2 then
ori.p = -math.pi/2
end

player[i].GunOrientation = ori

if ms.isButtonDown(MOUSE_LEFT_BUTTON) then
player[i]:fireWeapon(1, 1000)
end

if ms.isButtonDown(MOUSE_RIGHT_BUTTON) then --hold down y + mouse up or down to change your deadzone
dead = dead + mY
if dead < 1 then dead = 1 end
if dead > 99 then dead = 99 end
end

--lof = player[i].GunOrientation

--if lof:getScreenCoords() ~= false then
-- chX, chY = lof:getScreenCoords()
-- crosshair(chX * wf,chY * hf)
--end

end
end

]
#End

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 Backslash

  • 29
  • Bring Our Might To Bear
Re: id like a couple new functions in scripting
the goal i think is to make a freelancer style control setup.
This is included in the pilot file upgrade (which also includes a large rewrite to the io code).  Since adding a new set of control types breaks pilot files, it hasn't been added earlier.  Just FYI.
Mind, this Freelancer type control setup, at least from the code I tested, is not so easy with fixed-normal player primarys ;)  It's too easy to overshoot, then undershoot, etc.  Remember Freelancer's ships' guns all were turrets.

So... your idea is still good.  Plus you've now inspired me to learn more about this scripting, I hadn't realized this much was possible. Good example to learn from. :yes:
i was curious as to what build i would test it in. if it works and  find a way to change the phisycs rotational forces from the script...
What do you mean by this?  I might be able to help, I've been playing with the physics stuff lately... but I don't understand what you need.

 

Offline taylor

  • Super SCP/Linux Guru
  • Moderator
  • 212
    • http://www.icculus.org/~taylor
Re: id like a couple new functions in scripting
Mind, this Freelancer type control setup, at least from the code I tested, is not so easy with fixed-normal player primarys ;)  It's too easy to overshoot, then undershoot, etc.  Remember Freelancer's ships' guns all were turrets.
I've never played Freelancer (unless something is for Linux, I don't really bother it), so I don't actually know how it's mouse control worked.  The new code is from a patch generously sent in by someone else so I'm just trusting that it's appropriate.  But if it's not, the new controls will be there and the code can be adjusted.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: id like a couple new functions in scripting
the main thing i liked about freelancer is that the guns could be aimed independently of the ship. as they always followed the mouse pointer. the ship controll was essentially like what you find in privateer 2 or newer versions of d2xxl (you wanted a linux example) with handle mouse as joystick option and the mouse position cursor enabled. likewise that example i posted but applied to ship rotation instead of turrets. normally its a pita to use, i get about it by creating a dead zone. freelancer made it tolerable by making the mouse pointer the center of attention and slaving the guns off of them, so you essentially aim, and your ship follows your guns. if youve already implemented that kind of mouse control and if turrets can be controlled like the example. then you can emulate freelancer gameplay (but youl have to use turrets).

frelancer had two modes though, the always track mode and the track when mouse1 is pressed mode. this was impotant in freelancer cause everything had a point and click interface. youd click off mouseflight to say pick a target or turn on your autopilot or formation mode. you could turn off mouse tracking to aim your guns while in formation or with autopilot on. i also found it usefull when mining, id fly straight and shoot all the little rocks that passed buy. this is less important to freespace, that is unless somone wanted to do a fl mod. you might want to throw that feature in anyway, incase somone did a point and click hud.
« Last Edit: October 04, 2006, 08:11:23 am 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 Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: id like a couple new functions in scripting
So... any news on the 'plr' front?
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: id like a couple new functions in scripting
im just getting used to using
Code: [Select]
player = mn.getShipByName("Alpha 1")
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: id like a couple new functions in scripting
I can't see that being much use in multiplayer though Nuke.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: id like a couple new functions in scripting
most of what ive been doing is stuff with the ui or the hud and some experimenting with stuff like subobject animation and whatnot. i havent even considered using scripting in multiplayer. is that even allowed? i thought scripting would have been disabled in multi to prevent cheating. then again it would be cool to script multiplayer gameplay types and stuff. youd probibly have to run a crc on the scripting table or any lua files to make sure everyones using the same script. so will scripts be able to communicate with eachother and/or have the possibility of server side scripts whitch would generate output and echo it to the pilot directly or communicate through a client script?
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 DaBrain

  • Screensniper
  • 212
    • Shadows of Lylat board
Re: id like a couple new functions in scripting
SoL needs scripts and subobject animation for the multiplayer. There is no way we'd agree on disabling it!
--------------------------------------------------
SoL is looking for a sound effect artist
Please PM me in case you want to apply
---------------------------------
Shadows of Lylat - A Freespace 2 total conversion
(hosted by Game-Warden)
----------------------------------

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: id like a couple new functions in scripting
im curious as to how multiplayer compatable scripting will work though
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: id like a couple new functions in scripting
I was discussing this with Axem last night. Validating scripting.tbl is about the only sensible option I can think of.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: id like a couple new functions in scripting
i think were gonna need broadcast vars. variables which are seen and accessible by any script running on any machine on a multiplayer server. some could be server global and persist on a dedicated server (for like running a stats ticker, or if somone did a trade engine with multi). some would only have the scope of a single game (capture the headz :D). it would probibly be best implemented as a stack varname.scope.clientindex. then you can make scripts somewhat designed to communicate with eachother.
« Last Edit: October 04, 2006, 10:25:18 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 WMCoolmon

  • Purveyor of space crack
  • 213
Re: id like a couple new functions in scripting
So... any news on the 'plr' front?

I looked into it awhile back (couple weeks ago+) and IIRC I ended up expanding the 'Self' variable to cover more instances, because I couldn't easily recreate the 'Player' bug. I'm hoping it'll be nice and just disappear. It's on my to-do list.

Scripting is not disabled in multiplayer. Ironically, I think hud_gauges is, because people were worried about somebody moving around the escort gauge or something to give themselves an advantage. :rolleyes:

I think validating the scripting.tbl and assorted modular table files is the most efficient solution to prevent cheating at this point. I'm kinda curious how HL2 does it, though; if it's all done with the sv_cheats thing, or if there's something more going on under-the-hood. It'd be nice to have minor modifications that don't really upset balance to be possible (interface changes and such) but it'd be a hassle to do all that and still make it possible for mods to get the kind of scripting control that they'd want/need for the core gamplay.
-C

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: id like a couple new functions in scripting
Scripting is not disabled in multiplayer. Ironically, I think hud_gauges is, because people were worried about somebody moving around the escort gauge or something to give themselves an advantage. :rolleyes:

that is sorta whack. i dont think the hud would let you cheat in any major way really. unless youre displaying data which shouldnt be displayed. but theres no reason to prevent the script from running if all the players have to be running the same scrript.

then again i think the implementation of hud scripting could use some work. things like per gauge overrides. so that i can use a different lead indicator, radar, and scripted shield icons, without having to loose the other functions, mainly aspect lock and targeting. you really cant add new gauges because the huds pretty full already.  also maybe better scripting - hud_gauges.tbl interaction. like being able to mix and match scripted gauges for built in ones.
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 Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: id like a couple new functions in scripting
Following are just my thoughts....

It would be just fine (if it is possible) to (multi) game simply refuse to start unless the scripting.tbls (and why not hud_gauges.tbls) are identical in every respect. Best might that above combined with something that dls the scripting.tbl and the assorted tbms from the host (that is, if they do not match) - quite like multiplayer missions are handled - and then prompts to restart the game.

And the player bug might be hard to replicate as i do believe (Warning: i aint a coder! ;)) it to be related to optimization settings used when compiling builds...
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: id like a couple new functions in scripting
Great those are my favorite bugs. I always discover them right when I'm about to release something.
-C

 
Re: id like a couple new functions in scripting
Um, Nuke, will you have available the ability to use the joystick for actually moving the ship around still while using the mouse (or even a second stick) for aiming the turrets? I personally hate the Freelancer control system; the only part of it that I liked even remotely was the Turret View option for firing turrets. I always missed my joystick in that game. ;-;

The reason I'm asking about a second joystick possibility is that I have a gamepad with dual analog sticks (PS2 style controller) and, for a capital ship control mod, I think it would be really neat to have the right stick control aiming the guns while the left stick controls the ship's movement.

Normally, i use a dual-hatswitched Logitech Strike Force 3D, though.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: id like a couple new functions in scripting
right now mu script barely works at all, mouse controls turrets and theres no real way to aim them. it only seems to work with the ship pointing one way. i still dont know the proper math to get them to fire straight no matter which way they point.
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: id like a couple new functions in scripting
It would be just fine (if it is possible) to (multi) game simply refuse to start unless the scripting.tbls (and why not hud_gauges.tbls) are identical in every respect. Best might that above combined with something that dls the scripting.tbl and the assorted tbms from the host (that is, if they do not match) - quite like multiplayer missions are handled - and then prompts to restart the game.

Xfering the tables is something I've thought of and instantly rejected quite a few times. The main problem is that there is generally a very good reason why tables don't match.

Suppose I go online with TBP v3.2 and start a game with someone who has TBP 3.3. Right now we'll both get the hacked tables warning and can chat and sort out that I have to upgrade to play. If the tables xfered though I'd get the new tables but I wouldn't have the new ships. So when I tried to play online it would crash out for me. But worse due to the table changes when I went back to singleplayer it wouldn't load the missions any longer because some ship names were changed between the two releases.

And I dread to think what would happen if I hosted a game and someone with FS2 joined it :nervous:

I think we have a small enough multiplayer community as it is without people being scared to go online because they've heard that trying to play can screw up the game.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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