Author Topic: Something about scripting...  (Read 1841 times)

0 Members and 1 Guest are viewing this topic.

Something about scripting...
Hi! First post!

Relatively new to modding... have gotten the hang of tables and PCS but I'm really interested in making a couple of tweaks to things not covered by the tables, mostly just how damage works.

Was wondering - are there any tutorials out there for this sort of thing? Do I need any special tools?

Am looking forward to jumping into the FREDding universe at any rate... although I really have to get FSOpen to work first...

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: Something about scripting...
What are you thinking of doing? Weapons.tbl and armor.tbl cover most of the damage stuff between them.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

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

 

Offline Flipside

  • əp!sd!l£
  • 212
Re: Something about scripting...
http://www.hard-light.net/wiki/index.php/Category:Tables

Armor.tbl was what I was thinking of on Sectorgame, but the first thing is to get FSO running in the first place. What problems are you having?

Edit : Just to clarify, this was asked on Sectorgame, and I directed sevett here with the suggestion that he may find what he was looking for with Scripting, I'd forgotten about Armor.tbl though, so it's my fault if Scripting is the wrong direction to take :)

 
Re: Something about scripting...
I've gotten hang of the tables pretty easily (FreeSpace 2 is so mod friendly!) but I haven't found the armour table yet. I'm installing FSOpen as I type (I had some problems with video drivers which I had to update) so hopefully it'll be all systems go soon!

The ideas I had in mind aren't covered by the tables at all... might sound like a wacky idea but I wanted to work out a damage system based less on every shot doing a certain amount of damage which is subtracted from hit points, and instead every shot either gets through armour and damages your subsystems and possibly explodes you or it bounces off harmlessly. Perhaps this is possible with the armour.tbl, I'll search it out...

Basically I wanted to create a very low tech mod... no shields, projectile weapons, to get a feeling akin to flying WWII aircraft in space.

 
Re: Something about scripting...
ps. Thanks for the wiki link! I searched high and low for help with the tables and don't know why I didn't think to check wikipedia...  :yes:

 
Re: Something about scripting...
Feeling a little silly...

Reading through the tables wiki and seeing that a lot of people have had the same ideas as me already, which I probably would have discovered if I'd gotten Open working before coming on to bother you folks.

EDIT: After reading through, I guess if there was a way to randomise how much damage was done with each hit it would do what I wanted perfectly.
« Last Edit: March 16, 2007, 12:45:44 am by sevett_nems »

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Something about scripting...
Interesting. I don't think that there is a way using armor.tbl.

What you could do is a bit tricky. Do all the fixed-damage stuff with armor.tbl, and then write a script that was something like this:
Code: [Select]
#Conditional Hooks
$Object type: ship
$On Weapon Collision: [
     if sv.Weapon.Class.Name == "Gatling Gun" then
          sv.Ship.HitpointsLeft = sv.Ship.HitpointsLeft - math.random(10,20)
     end
]
#End

Math library tutorial

I think that would work, and would add 10-20 points of damage each time a ship got hit with a projectile of type "Gatling gun" (It's probably a bit much, but oh well.) You can't really get the final damage that a weapon deals without manually doing all the calculations in scripting, or completely overriding FS2Open's behavior in that regard and applying the damage yourself. In which case it'd look something like:

Code: [Select]
#Conditional Hooks
$Object type: ship
$On Weapon Collision: [
     --Apply weapon damage to ship
     sv.Ship.HitpointsLeft = sv.Ship.HitpointsLeft - sv.Weapon.Class.Damage

     --Randomize damage for our gatling gun
     if sv.Weapon.Class.Name == "Gatling Gun" then
          sv.Ship.HitpointsLeft = sv.Ship.HitpointsLeft - math.random(10,20)
     end

     --Destroy the weapon
     sv.Weapon.LifeLeft = 0.01
]
+Override: true
#End

I'd need to do a more indepth investigation of the collision code to determine what else you'd have to deal with. Both of those examples are right off the top of my head to get you (or anybody else) an idea of what to look up to do something like that. (Both examples should be placed in scripting.tbl or a modular table file with the suffix "-sct.tbm" to be run)
-C

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: Something about scripting...
Did you fix the conditional hook crash thing already?
Do not meddle in the affairs of coders for they are soggy and hard to light

  

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Something about scripting...
Did you fix the conditional hook crash thing already?

Not sure. I've been trying to debug things, but I've been hampered since I switched over to Linux and got it working well enough that I virtually never boot to Windows anymore. I've redone the problem functions, but all I can tell right now is that a segmentation fault is occurring. I'm sure that gdb is fully capable of giving me specific information about the problem, or that there's some IDE out there that can tell me what it is, but until I get the time to sort through all the crap and find some documentation that tells me what I need to know, or take the plunge and take the time to set up an IDE, I really can't tell a damn thing. It really annoys me, because you'd think that since all the Linux users tend to be more tech-savvy than their Windows counterparts, they would be interested in having a debugger that just works. (And there may be one, but there are so many "options" that I don't know anything for sure until I try it out for myself)

Anyway

something I realized at lunch today (Yes, just popped into my mind :p) is that the examples in my last post will only work in an intermediate build between 3.6.9 and the most recent builds. For 3.6.9, the examples won't work at all; I'm pretty sure it doesn't even have conditional hooks. For the most recent builds, you need to change all the "sv" instances into "hv". Further, you should only run the examples separately; if you run them both at the same time, the second one will (or should) always be executed instead of the first. Both still go in the same kinds of files, though.
-C