Conditional Firing

Freeform discussion about anything related to modding Transcendence.
Post Reply
User avatar
catfighter
Militia Commander
Militia Commander
Posts: 466
Joined: Fri Nov 08, 2013 5:17 am
Location: Laughing manically amidst the wreckage of the Iocrym fleet.

How would I set conditions on firing a weapon? For example, unless you have a certain item in your cargo hold, the weapon won't work or a weapon shoots a different kind of projectile if you're in a nebula or dust cloud. Also, can this extend to other devices as well? Maybe a shield that get's bonuses based on environment. I read that unlimited-fire weapons intake material from the environment and I was thinking about making this a bit more realistic in terms of what comes out the other end of the gun barrel.
Behold my avatar, one of the few ships to be drawn out pixel by pixel in the dreaded... Microsoft Paint!

Day 31: "I have successfully completed my time reversal experiment! Muahahaha!!!"
Day 30: "I might have run into a little problem here."
Arkheias
Commonwealth Pilot
Commonwealth Pilot
Posts: 95
Joined: Mon Jun 02, 2014 8:06 pm

For the first(ish) question, set the weapon to use some item as ammo. The weapon will now be unable to fire unless you have that item on your ship. Then set the weapon to add one unit of that item to your ship whenever it is fired (see attached code) so that you won't actually run out of the item. The main flaw with this method is that unless you can find a function to retrieve the itemtype of the currently selected ammo, the ammo has to be hard-coded in and the weapon will therefore be limited to one type of ammo.

Code: Select all

<Events>
	<OnFireWeapon>
		 (objAddItem gplayerShip (itmCreate 0x4001 1) 1)
	</OnFireWeapon>
</Events>
For the second part about having a weapon/device operate differently in a nebula, as far as I know there is no way to directly tell if a ship is inside a nebula or not. I believe I read in a thread somewhere that being in a nebula now gives your ship a +2 bonus to its stealth rating and a -4 penalty to its perception rating. In the thread I posted about the DRADIS device that will be included in the next version of my Cabbage Corp mod I included the code necessary to retrieve the current perception value of a ship. Unfortunately this function only works for npc ships, but it could theoretically be used to determine if a ship is in a nebula by comparing its current perception value to some baseline value.
Cabbage Corp, the only mod with cabbages!

Please feel free to submit bug reports or issues related to the Cabbage Corp mod on the GitHub page, the forum thread, in a private message or even on the Xelerus page. Suggestions are fine too.
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

You can try sysGetEnvironment in the funclist http://forums.kronosaur.com/viewtopic.php?f=8&t=6926 .
This should return &evnebula; or something similar when in nebula.
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Image
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
Post Reply