Hard Light Productions Forums
Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: Wanderer on January 30, 2007, 10:24:35 am
-
Something little brighten up the ship deaths...
#Global Hooks
$Simulation:
[
missiontime = mn.getMissionTime()
frametime = ba.getFrametime(true)
if missiontime < 1 then
flaktexture = gr.loadTexture("lglow3")
nullvec = ba.createVector(0,0,0)
detotexture = gr.loadTexture("EXP_flash", true)
detotimes = { 2000000 }
detoinfo = {}
detoshipdead = {}
math.randomseed( os.time() )
end
for i=1,#mn.Ships do
detoship = mn.Ships[i]
detoshipname = detoship.Name
detoshiphp = detoship.HitpointsLeft
if detoshiphp < 1 and detoshipdead[detoshipname] == nil then
detoshipdead[detoshipname] = 1
detoshiptype = detoship.Class.Type.Name
if detoshiptype == "Freighter" then
detoshipvel = detoship.Physics.Velocity
detoshippos = detoship.Position
detonum = math.floor(10+2*math.random())
for k=1,detonum do
detorandtimer = 1+2*math.random()
detorandvector = ba.createVector(100*(math.random()-0.5),100*(math.random()-0.5),100*(math.random()-0.5))
detoprojection = detoshippos + detorandvector + (detoshipvel/(1/detorandtimer))
detotime = detorandtimer + missiontime
table.insert(detotimes,detotime)
table.insert(detoinfo,math.floor(detotime*10000),detoprojection)
end
table.sort(detotimes)
end
end
end
while detotimes[1] < missiontime do
detotimer = detotimes[1]
ts.createParticle(detoinfo[math.floor(detotimer*10000)],nullvec,frametime,math.random(50,200),PARTICLE_BITMAP,-1,false,detotexture)
table.remove(detoinfo,math.floor(detotimer*10000))
table.remove(detotimes,1)
table.sort(detotimes)
end
]
#End
Basically it creates series of flashes (animation) around (or inside) the ship when it dies. 'lglow3' is a standard bitmap graphic and 'exp_flash' is an animation (eff)
-
Wow. I think I will try it!
-
You should note that the particular script posted above draws effect only if the dying ship is of 'Freighter' type. It is relatively straightforward to modify that for other shiptypes (like capital) - or to use shipclasses (like GTFr Triton) instead - as well.
Also the effect i used it isnt really that pretty.. However if you can get it from here (http://koti.mbnet.fi/vekkup/FS2/EXP_flash.rar)
-
I'm gunna have a look....
-
help. ::) <-- Annoyed with self
LUA ERROR: attempt to call a string value
LUA Debug:
------------------------------------------------------------------
Name: (null)
Name of:
Function type: C
Defined on: -1
Upvalues: 0
Source: =[C]
Short source: [C]
Current line: -1
------------------------------------------------------------------
LUA Stack:
------------------------------------------------------------------
------------------------------------------------------------------
-
What build did you use? This script needs new HEAD branch CVS build.. like this http://www.hard-light.net/forums/index.php/topic,45175.0.html
EDIT: Also... some short video clips (http://koti.mbnet.fi/vekkup/flash.rar) (ogg) to show the effect... use for example VLC player.. Enlarged ones are just tests and the 'standard' ones use the same values as the script above
-
Damn, I really am CLUELESS (n00b squad) "How do you fire teh lasers?".
-
Errr... So did you still have issues with it?
-
no no. :)
-
:bump::bump:
I think this long comatose state requires two bums :P
Decided to alter the script a bit and remake it as well.
Now the script 'supports' most of the Terran and Vasudan ships of FreeSpace 2 - and it ain't exactly rocket science to expend that. In package there is also a script for scripted flak effects. The scripts, graphic effects and required builds are in the download. It comes as a mod directory (might be worth checking that the mod.ini inside the directory points to your 'mediavps' directory) and three HEAD branch builds. Remember to use NEW and SEPARATE pilot files with these builds.
Download link (http://koti.mbnet.fi/vekkup/FS2/FreeSpaceOpenScriptingThings.7z)
If people would like to test and comment these it would be great. As for missions... Any mission with dying terran or vasudan ship listed in the mod will do.
Should you want to disable either of the scripts just rename the related .tbm file(s) to .txt.
-
Thanks for this scripting example :) .
Now it seems to me Lua is much more like C++ then I initially expected - please don't look at my first example script, I'd get very deep red of being ashamed... :shaking:
I hope now I'll be able to get some scripting working myself within the "foreseeable future" (don't nail me down to specify this, please :nervous: ;) ).
-
lua's nothing like c++. no bracket hell, no needing to call special functions to use dynamic memory, no semicolons, and no pointers. if lua is rocket science, then c++ is m theory.
-
If you run into probs with the scripts just ask for help here.. I mean some of the Lua errors (ie. the error message is next to useless) are rather cryptic.
-
Sorry for the newb question, but what do I have to do to try out this script here in our own data ? :)
-
I can't view the files videos. Winamp is refusing to play them. :doubt:
-
Sorry for the newb question, but what do I have to do to try out this script here in our own data ? :)
Umh? Extract the archive into the FreeSpace dir... Assuming you have allowed paths to be created it creates mod directory named 'Scripting' and places few HEAD branch exe files into the 'main FreeSpace directory'. Use launcher to select the mod and try a mission where Terran/Vasudan capital ship gets destroyed. If you mean by 'our own data' a mod or TC data then there is little more to do. First you need to clear the current FreeSpace ship references from the script and replace these with values that are suitable for the models in use.
These for each ship... First three define the 'box' where the detonations are allowed to happen. Fourth defines the radius of a detonation effect (-+ 50%) and last defines the flash that appears when the ship truly gets removed from 'ship index list' ie. die.
arrayShipW["GTD Orion"] = 500
arrayShipH["GTD Orion"] = 500
arrayShipL["GTD Orion"] = 1900
arrayShipDetRadius["GTD Orion"] = 500
arrayShipFlashRadius["GTD Orion"] = 2500
I can't view the files videos. Winamp is refusing to play them. :doubt:
As said 'OGG' (theora) files. Get VLC player or something like it that isn't as inept as WinAmp - at least i haven't had much luck getting WinAmp to play theora clips.
-
So that cleared the questions? Please if you have questions about that post those here or PM me.
-
I'm kind of liking the effect that you're using, but at the same time I'm not really sure I do, it looks like cheese. :nervous:
-
Well.. I'm sorta proud of the graphics :P And kinda proves i am not exactly a graphics wiz... But that kinda shows the limits of my graphics skills.
But you can always change the effect to any animation the game accepts that you want to. Also it is trivial to change the script to use randomly selected explosion flashes or species specific explosions - like having different sets for vasudans and terrans - should you want to have more variance for the explosions.
-
It's a huge improvement though. :)
-
we should get this in-game and looking pretty ASAP for the .vp's
-
You think this should be included to the mediavps?
The script itself (one in the linked FreeSpaceOpenScriptingThings.7z) should work with taylor's new XT builds. However i'm not sure if any scripts should be included into any mediavp package as long as the code support for the scripting is not in committed to the stable branch.
-
I just committed it to SVN last night, along with the new warp effects code, although people seem to have problems in general with stable builds right now. There's a lot of problems that'll be fixed when taylor commits his Xt branch.
-
NOO! My long standing excuse to wave off all the script just got removed... ;)
:yes: Great :D
-
Better deaths for big ships would definitely spice things up :)