LAUNCHER and LASER ->VIRTUAL WEAPON HELP?

Freeform discussion about anything related to modding Transcendence.
Post Reply
bluemako
Anarchist
Anarchist
Posts: 5
Joined: Fri Aug 16, 2013 1:23 am

Hi guys. Newb here. Questions on virtual weapons:

BG: One of the mods I'm on the process of making is a ship (I tried out making a couple, one based on Freespace2 "Ulysses" and the other invented) and one of the weapons that I loved from freespace was the Swarm missile. It fires four missiles on a target or dumbfire ahead. There's that long laser thingy as well...

Problem/Questions:

1) I wanted to simulate the four missiles and got around to it by putting the initial missile ammo lifetime=0, then fragment into four. However, ammo count only deducts one from current inventory. I've been looking for a virtual weapon/ammo tut and the best one I got so far was that one with Artalost's comment: "Use aWeaponType as your weapon UNID when creating shots unless you have multiple weapons using the same ammo, in which case you'll need a virtual weapon for each ammo type. Returning nil will fire the normal shot, which you may or may not want depending on what you're doing." I've also been trying to study refs such as digdugs weapon extended mod to see how he coded the dragonfly (great mod digdug :D)...and I'm still not yet read the entire functions for trans....
So the question for this would be: "what would be the possible codes to put in here? i reckon there's the <onfireweapon> branches and the <createweaponfire> codes for this to work, and item counts?

2) Thinking for another set, a disposable launchers (am i right in assuming putting charges here is the way) for say, Battletech style salvos like the SRM20 or LRM20 (firing 20 shots per weapon fire). So would this be almost the same encoding as question 1?

3) I saw a lightsaber mod somewhere here (I ought to study those codes as well), and was thinking of such laser weapons say, a continual press means that the weapon fires (obviously) but the sound would come out as lots of weapons firing.
What i mean here is this: The first one I coded was at a very fast fire rate, and that's where the problem arose. I coded another with a repeating trait and a slow fire rate, but this only proves even more or less wrong, as you cant control the actual length of the beam. Any ideas how to get around this? Temperature count or charges?

Thanks guys for a response to this. Also, I don't have the intention of stealing the codes I am studying this things from, I just wanted to get an idea how the things should function and I would ask permission first to those who made the first mods/codings for such things and give them due credit if I would be able to put/base from those codes onto my own mod.

:mrgreen:
"Fortune favors the Brave!"
User avatar
Atarlost
Fleet Admiral
Fleet Admiral
Posts: 2391
Joined: Tue Aug 26, 2008 12:02 am

Virtual ammo is actually not the right solution here. Virtual ammo is for when you want to use multiple ammo types on something that is not a launcher. You want this:

Code: Select all

(setq AU_multishotammohandler (lambda (ammoUnid maxCount)
				(block (fireCount maxCount doNotFire)
					(setq fireCount (objGetData gSource "fireCount"))
					(if (or (not fireCount) (gr fireCount maxCount))
						(setq fireCount 1)
					)
					(setq doNotFire (not (objRemoveItem gSource (itmCreate ammoUnid 1) 1)))

					(if (geq fireCount maxCount)
						(objAddItem gSource (itmCreate ammoUNID 1))
					)
					; count off a shot so we know when the engine has handled ammo use on its own
					(objSetData gSource "fireCount" (add 1 fireCount))
					doNotFire
				)
		))
It should be called with

Code: Select all

<OnFireWeapon>
				(AU_multishotammohandler [color=#00FF00]4[/color] aWeaponType)
			</OnFireWeapon>
in a launcher context. The 4 is the amount of ammo you want consumed per keypress. If you change your mind about how many missiles to fire that's where you make the change.

I think. I haven't done ant T-script in ages.

To fire multiple shots it's better to use configuration tags (see the Trident for an example) rather than fragmentation. You'll get more controlled shot placement. If you want configuration randomization see the Moskva 21, also in the base game.
Literally is the new Figuratively
bluemako
Anarchist
Anarchist
Posts: 5
Joined: Fri Aug 16, 2013 1:23 am

Nice! Thanks Atarlost! Hopefully I can post the mod this week when I am satisfied with the result and balance of the actual ship!
"Fortune favors the Brave!"
Post Reply