Hard Light Productions Forums

Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: Scooby_Doo on April 21, 2007, 02:48:32 am

Title: Confused about executing scripts.
Post by: Scooby_Doo on April 21, 2007, 02:48:32 am
I've been trying to get Wanders auto-gun convergence to work.  I've created the scripting.tbl and put the code in there.  What else am I missing?  :confused:
Title: Re: Confused about executing scripts.
Post by: Wanderer on April 21, 2007, 02:56:22 am
Recent head branch build`(NOT 3.6.9 build)?

Properly named weapons (dummy weapon and a real one)?
Title: Re: Confused about executing scripts.
Post by: Scooby_Doo on April 21, 2007, 02:59:39 pm
I grabbed the build from the lastest builds thread.  Whats a dummy weapon?
Title: Re: Confused about executing scripts.
Post by: Wanderer on April 21, 2007, 04:28:17 pm
Well the script actually runs every single frame of the game (like all lua scripts unless otherwise defined)

It sort of waits for appearance of weapon named 'Corona', which is used in the script as dummy weapon.. That is as soon as game detects any weapon of that particular class, it removes that weapon from game (setting the remaining lifetime of the weapon to 0 s) it tries to search for the shooter of that weapon and then assigns target according to that and calculates new vectors for the weapon. After this the script generates a new weapon of 'Halo' class which is 'pointed' at the newly calculated convergence point.

So the 'Corona' is a dummy weapon. That is in that script the 'Corona' is used only for triggering the rest of the script.
Title: Re: Confused about executing scripts.
Post by: Scooby_Doo on April 21, 2007, 05:25:12 pm
Ok how do you implement different types of existing weapons with Corona then?
Title: Re: Confused about executing scripts.
Post by: Wanderer on April 22, 2007, 12:15:32 am
Huh? What do you mean?

You just create a new weapon (dummy) that has the same performance as the weapon you want to fire (real weapon). Then make sure the new weapon has all the interface anims, muzzleflashes and all such set for it and also that it has no shockwave and no impact explosion. Search for the script i posted and change the name 'Corona' to the name of your new dummy weapon, and the 'Halo' with the weapon you really want to fire.

Script could probably be reworked into working when ship class fires instead of just using defined weapons though - with small 'cost' in weapon range.
Title: Re: Confused about executing scripts.
Post by: Scooby_Doo on April 22, 2007, 12:23:19 am
so for meson i would copy and paste your code, rename Corona to something like meson_dummy
then for tachyon i would repaste it again, rename Cornoa to tach_dummy?
Title: Re: Confused about executing scripts.
Post by: Wanderer on April 22, 2007, 12:38:17 am
Ah.. Well i the gun convergence script was a show off thing sort of 'But I can only show you the door. You're the one that has to walk through it.' to demonstrate what you can do with scripting... and of course to get more people 'to walk through the door' i.e., start experimenting on Lua scripts. It can be modified to work with multiple weapon classes too without copy pasteing it two times (by writing a bit longer script).

But (havent tested) it should work if you copy the actual convergence section (outlined below) and use the first one for Mesons and the second one for Tachyons.

Code: [Select]
if missiontime > 0.5 then
   ...
   <lots of stuff>
   ...
end
Title: Re: Confused about executing scripts.
Post by: Scooby_Doo on April 22, 2007, 01:23:06 am
Ahhh i think I see where

Code: [Select]
if stringWeaponClass == "Corona" and numberWeaponLife > 0.2 then

will be

Code: [Select]
if stringWeaponClass == "Meson_dummy" or stringWeaponClass == "tachyon_dummy" or ...... and numberWeaponLife > 0.2 then

and

Code: [Select]
mn.createWeapon(tb.WeaponClasses["Halo"],orientationWeapon,vectorWeaponPosition,newshooter,-1)

with
Code: [Select]
if stringWeaponClass == "Meson_dummy" then
      mn.createWeapon(tb.WeaponClasses["Meson_real"],orientationWeapon,vectorWeaponPosition,newshooter,-1)
else if if stringWeaponClass == "tachyon_dummy" then
      mn.createWeapon(tb.WeaponClasses["tachyon_real"],orientationWeapon,vectorWeaponPosition,newshooter,-1)
....
else
      mn.createWeapon(tb.WeaponClasses["default_real"],orientationWeapon,vectorWeaponPosition,newshooter,-1)

Correct? I don't see anything else pretaining to the actual weapon, rest seems to be about vectors.
Title: Re: Confused about executing scripts.
Post by: Wanderer on April 22, 2007, 07:52:13 am
Yeah.. Just make sure you get the booleans right though.