Author Topic: Flashy deaths  (Read 8713 times)

0 Members and 1 Guest are viewing this topic.

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Something little brighten up the ship deaths...

Code: [Select]
#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)
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Wow. I think I will try it!
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
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
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Snail

  • SC 5
  • 214
  • Posts: ☂
I'm gunna have a look....

 

Offline Snail

  • SC 5
  • 214
  • Posts: ☂
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:
------------------------------------------------------------------

------------------------------------------------------------------

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
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 (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
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Snail

  • SC 5
  • 214
  • Posts: ☂
Damn, I really am CLUELESS (n00b squad) "How do you fire teh lasers?".

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Errr... So did you still have issues with it?
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Snail

  • SC 5
  • 214
  • Posts: ☂

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
: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

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.
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Mav

  • 28
  • location: Shivan fleet - closing in on GTVA space
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: ;) ).
-__ o_O___O_o
I______O_O_______dragons
________o

-----------------------------------
capship shields DO WORK !!!
my models, now with pics
test mission for commanding capships
-----------------------------------
suffering from a late stage of BoE-infection - DON'T call a doctor, it's too late for that anyway ;o)

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
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.
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
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.
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Starman01

  • 213
  • Mechwarrior
    • Wing Commander Saga
Sorry for the newb question, but what do I have to do to try out this script here in our own data ? :)
MECHCOMMANDER OMNITECH

9 out of 10 voices in my head always tell me that I'm not insane. The 10th is only humming the melody of TETRIS.

 

Offline Cobra

  • 212
  • Snake on a Cain
    • Minecraft
    • Skype
    • Steam
    • Twitter
I can't view the files videos. Winamp is refusing to play them. :doubt:
To consider the Earth as the only populated world in infinite space is as absurd as to assert that in an entire field of millet, only one grain will grow. - Metrodorus of Chios
I wept. Mysterious forces beyond my ken had reached into my beautiful mission and energized its pilots with inhuman bomb-firing abilities. I could only imagine the GTVA warriors giving a mighty KIAAIIIIIII shout as they worked their triggers, their biceps bulging with sinew after years of Ivan Drago-esque steroid therapy and weight training. - General Battuta

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
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.
Code: [Select]
      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.
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
So that cleared the questions? Please if you have questions about that post those here or PM me.
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Cobra

  • 212
  • Snake on a Cain
    • Minecraft
    • Skype
    • Steam
    • Twitter
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:
To consider the Earth as the only populated world in infinite space is as absurd as to assert that in an entire field of millet, only one grain will grow. - Metrodorus of Chios
I wept. Mysterious forces beyond my ken had reached into my beautiful mission and energized its pilots with inhuman bomb-firing abilities. I could only imagine the GTVA warriors giving a mighty KIAAIIIIIII shout as they worked their triggers, their biceps bulging with sinew after years of Ivan Drago-esque steroid therapy and weight training. - General Battuta

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
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.
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline Cobra

  • 212
  • Snake on a Cain
    • Minecraft
    • Skype
    • Steam
    • Twitter
It's a huge improvement though. :)
To consider the Earth as the only populated world in infinite space is as absurd as to assert that in an entire field of millet, only one grain will grow. - Metrodorus of Chios
I wept. Mysterious forces beyond my ken had reached into my beautiful mission and energized its pilots with inhuman bomb-firing abilities. I could only imagine the GTVA warriors giving a mighty KIAAIIIIIII shout as they worked their triggers, their biceps bulging with sinew after years of Ivan Drago-esque steroid therapy and weight training. - General Battuta