Rand Equip Mod 2 with more ships

Freeform discussion about anything related to modding Transcendence.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

I got permission by Periculi to release this version of his Rand Equip Mod 2

-Added most of the ships in the game.
-Now a small percentage of the weapons are enhanced or nerfed at random.
-Ships with launchers now use all the new missiles in the Weapons Extended mod.
-A small surprise.... :D

Download from Xelerus:
http://xelerus.de/index.php?s=mod&id=111


Require Weapons Extended Mod 1.12+
http://xelerus.de/index.php?s=mod&id=83
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

and nice job btw. :)

You could just call it Random Equipment 3. Or.. try bundling it with Weapons Extended.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

before calling it Random Equipment 3 Mod I would like to add a couple of feaures:

Code: Select all

(setq intSetWeaponConfig (lambda (levelChoice)
	(block (choiceWeapon)
		(if (eq levelChoice extended)
		(setq levelChoice (cat (sysGetLevel) "a"))
		)
		
		(switch
			(eq levelChoice 1a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "cv--- ----- ----- -----"))
			(eq levelChoice 1b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "cu--- ----- ----- -----"))
			(eq levelChoice 2a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "vcv-- ----- ----- -----"))
			(eq levelChoice 2b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "vcuv- ----- ----- -----"))
			(eq levelChoice 3a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "-vcv- ----- ----- -----"))
			(eq levelChoice 3b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "-vcu- ----- ----- -----"))
			(eq levelChoice 4a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "--vcv ----- ----- -----"))
			(eq levelChoice 4b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "--vcu v---- ----- -----"))
			(eq levelChoice 5a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "---vc v---- ----- -----"))
			(eq levelChoice 5b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "---vc uv--- ----- -----"))
			(eq levelChoice 6a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----v cv--- ----- -----"))
			(eq levelChoice 6b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----v cuv-- ----- -----"))
				(eq levelChoice 7a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- vcv-- ----- -----"))
				(eq levelChoice 7b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- vcuv- ----- -----"))
				(eq levelChoice 8a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- -vcv- ----- -----"))
				(eq levelChoice 8b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- -vcuv ----- -----"))
				(eq levelChoice 9a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- --vcv ----- -----"))
				(eq levelChoice 9b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- --vcu ----- -----"))
				(eq levelChoice 10a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- ---vc ----- -----"))
				(eq levelChoice 10b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- ---uc ----- -----"))		
			)
				(if choiceWeapon
					(block (enhancedWeapon)
					
						;set the enhanced weapon to the selected weapon, then maybe we will enhance it.
						(setq enhancedWeapon choiceWeapon)
						
						;10% of the weapons will be nerfed or enhanced at random
						(block (roll enhancement)
							(setq roll (random 1 10))
							(setq enhancement (random (list 0x0101 0x0102 0x0103 0x0104 0x0105 0x0f01 0x0f02 0x0f03 0x1002 0x8f01 0x8f02 0x8f03 0x8101 0x8102 0x8103 0x8104)))
							(if (leq (roll 1))
								(block Nil
									(setq enhancedWeapon (itmSetEnhanced choiceWeapon enhancement))
								)
							)
							
						)
					
						(objAddItem gSource enhancedWeapon)
						(shpInstallDevice gSource enhancedWeapon)	
					)))))
If the lambda variable is "extended" the new if will generate the string *number*a and then that will be passed to the switch.
However I don't know why, this code won't generate a weapon and when the function is called in the console "sometimes" i get the weapon installed and "sometimes" not (not joking!) :shock:
I'm still trying to figure out when the function works and why.
It's really strange, I start a new game and the function won't work, then after some time the function starts working.
The same function without modifications even caused a hard crash when called in the system after Eridani, but I was unable to get the crash a second time.

If I manage to make this work, I can make more if statements for sovereigns. For example Sung ships could have the weapons filtered for the Sung modifier in the weapons extended.

[EDIT] I just noticed that all the weapon installed when you call the function in the console are enhanced, what I'm doing wrong with the if function ? :cry:
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

You might try placing the weapon enhancement after the item is added to the ship, I would tinker with this script but I am very short on time right now.


edit- just saw your edit! Well, seems like you might want to double check the statement structure. Is choiceWeapon getting an item every time still?

umm-- it might be that first if at the top: "extended" perhaps?
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

yeah, the first if do a setq using the lambda variable, am I allowed to do that ?
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

ok, I cleaned up the code, now it uses 1 block that set all the variables in it

Code: Select all

(setq intSetWeaponConfig (lambda (levelChoice)
	(block (choiceWeapon levelChosen enhancedWeapon roll enhancement)
		
		;prepare the roll for later
		(setq roll (random 1 10))
		
		;prepare the list of enhancements
		(setq enhancement (random (list 0x0101 0x0102 0x0103 0x0104 0x0105 0x0f01 0x0f02 0x0f03 0x1002 0x8f01 0x8f02 0x8f03 0x8101 0x8102 0x8103 0x8104)))
		
		;if the lambda is "extended", generate the levelChosen from the system level
		(if (eq levelChoice extended)
		(setq levelChosen (cat (sysGetLevel) "a"))
		(setq levelChosen levelChoice)
		)
		
		(switch
			(eq levelChosen 1a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "cv--- ----- ----- -----"))
			(eq levelChosen 1b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "cu--- ----- ----- -----"))
			(eq levelChosen 2a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "vcv-- ----- ----- -----"))
			(eq levelChosen 2b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "vcuv- ----- ----- -----"))
			(eq levelChosen 3a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "-vcv- ----- ----- -----"))
			(eq levelChosen 3b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "-vcu- ----- ----- -----"))
			(eq levelChosen 4a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "--vcv ----- ----- -----"))
			(eq levelChosen 4b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "--vcu v---- ----- -----"))
			(eq levelChosen 5a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "---vc v---- ----- -----"))
			(eq levelChosen 5b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "---vc uv--- ----- -----"))
			(eq levelChosen 6a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----v cv--- ----- -----"))
			(eq levelChosen 6b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----v cuv-- ----- -----"))
			(eq levelChosen 7a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- vcv-- ----- -----"))	
			(eq levelChosen 7b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- vcuv- ----- -----"))		
			(eq levelChosen 8a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- -vcv- ----- -----"))		
			(eq levelChosen 8b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- -vcuv ----- -----"))		
			(eq levelChosen 9a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- --vcv ----- -----"))	
			(eq levelChosen 9b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- --vcu ----- -----"))
			(eq levelChosen 10a)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- ---vc ----- -----"))			
			(eq levelChosen 10b)
				(setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- ---uc ----- -----"))				
			)
			
		;enhance the weapon with 10% probability	
		(switch
			(eq roll 1)
				(setq enhancedWeapon (itmSetEnhanced choiceWeapon enhancement))
			(gr roll 1)
				(setq enhancedWeapon choiceWeapon)
		)
		
		;finally, install the weapon
		(objAddItem gSource enhancedWeapon)
		(shpInstallDevice gSource enhancedWeapon)
					
	)	
	)
)
If you launch the game, it creates ships with random weapons as expected, the ships with "extended" lambda variable get no weapon, and if you call the function in the console it doesn't work at all, and crashes the game in the system after Eridani. :cry:
What's happening ? :? :(
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

Be careful with your use of strings vs. identifiers.

A string is something inside quotes:

Code: Select all

(setq xyz "This is a string")
You can also use the single-quote prefix to turn a single word into a string:

Code: Select all

(setq xyz 'ThisIsAString)
Note that there is no closing single-quote. Also note that this has to be a single word (no spaces). If you need spaces in your string, use double-quotation marks (as in the first example).

Identifiers are not strings. Identifiers are variables that are used to hold some value. Identifiers are single words that start with a letter. Identifiers cannot start with a number.

Code: Select all

(setq thisIsAnIdentifier 27)
In your code, I think you need to put quotes around certain things that you are treating like a string:

Code: Select all

(eq levelChoice extended) <- incorrect

(eq levelChoice "extended") <- correct
OR
(eq levelChoice 'extended) <- correct

Code: Select all

(eq levelChosen 1a) <- incorrect

(eq levelChosen "1a") <- correct
OR
(eq levelChosen '1a) <- correct
I don't know if that's the whole problem, but you should fix those and see how they work.

Good luck!
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

It seems to be working like that. I think this also needs to be fixed:

Code: Select all

	<OnCreate>
		(block Nil
			(intSetWeaponConfig "2a")
			(intSetShieldConfig 33 "2a")
		)
	</OnCreate>
I put the "" around the string being passed in.

I wonder why I thought I could just pass the 1a like that.. and why it seemed to be working. :)
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

Thanks George, I just finished doing some debugging of the code with Betel (by filling it with a dbgOutput at each step) and we found that each *number**letter* is always dropped to *number*

so 1a always became 1

that's why original Periculi's version was working until I started tinkering on it. :)

I'm going to change all 1a to '1a and so on.
also I'm going to use 'extended string to get systemlevel dependent random weapons finally.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Code: Select all

<Globals>
(block Nil
(setq intSetWeaponConfig (lambda (levelChoice)
   (block (choiceWeapon levelChosen enhancedWeapon roll enhanceList enhancement enhanceCount)
      
      ;prepare the roll for later
      (setq roll (random 1 10))
      
      ;prepare the list of enhancements
      (setq enhanceList (list 0x0101 0x0102 0x0103 0x0104 0x0105 0x0f01 0x0f02 0x0f03 0x1002 0x8f01 0x8f02 0x8f03 0x8101 0x8102 0x8103 0x8104))
      (setq enhanceCount (count enhanceList))
	(setq enhancement (item enhanceList (random 0 enhanceCount))) 
      ;if the lambda is "extended", generate the levelChosen from the system level
      (if (eq levelChoice "extended")
      (setq levelChosen (cat (sysGetLevel) "a"))
      (setq levelChosen levelChoice)
      )
      
      (switch
         (eq levelChosen "1a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "cv--- ----- ----- -----"))
         (eq levelChosen "1b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "cu--- ----- ----- -----"))
         (eq levelChosen "2a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "vcv-- ----- ----- -----"))
         (eq levelChosen "2b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "vcuv- ----- ----- -----"))
         (eq levelChosen "3a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "-vcv- ----- ----- -----"))
         (eq levelChosen "3b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "-vcu- ----- ----- -----"))
         (eq levelChosen "4a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "--vcv ----- ----- -----"))
         (eq levelChosen "4b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "--vcu v---- ----- -----"))
         (eq levelChosen "5a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "---vc v---- ----- -----"))
         (eq levelChosen "5b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "---vc uv--- ----- -----"))
         (eq levelChosen "6a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----v cv--- ----- -----"))
         (eq levelChosen "6b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----v cuv-- ----- -----"))
         (eq levelChosen "7a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- vcv-- ----- -----"))   
         (eq levelChosen "7b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- vcuv- ----- -----"))      
         (eq levelChosen "8a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- -vcv- ----- -----"))      
         (eq levelChosen "8b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- -vcuv ----- -----"))      
         (eq levelChosen "9a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- --vcv ----- -----"))   
         (eq levelChosen "9b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- --vcu ----- -----"))
         (eq levelChosen "10a")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- ---vc ----- -----"))         
         (eq levelChosen "10b")
            (setq choiceWeapon (itmCreateRandom "w,-m -Launcher -Ammo;" "----- ---uc ----- -----"))            
         )
         
      ;enhance the weapon with 10% probability   
      (switch
         (eq roll 1)
            (setq enhancedWeapon (itmSetEnhanced choiceWeapon enhancement))
         (gr roll 1)
            (setq enhancedWeapon choiceWeapon)
      )
      
      ;finally, install the weapon
      (objAddItem gSource enhancedWeapon)
      (shpInstallDevice gSource enhancedWeapon)
               
   )   
   )
)

(setq intSetShieldConfig (lambda (percentShield levelChoice)
	(block (roll percent)
	(setq roll (random 1 100))
	(setq percent (subtract percentShield 100))
	(if (geq roll percent)
	(block (choiceShield)
		
		(switch
			(eq levelChoice "1a")
				(setq choiceShield (itmCreateRandom "s" "cv--- ----- ----- -----"))

			(eq levelChoice "1b")
				(setq choiceShield (itmCreateRandom "s" "cuv-- ----- ----- -----"))
			(eq levelChoice "2a")
				(setq choiceShield (itmCreateRandom "s" "vcv-- ----- ----- -----"))

			(eq levelChoice "2b")
				(setq choiceShield (itmCreateRandom "s" "vcuv- ----- ----- -----"))
			(eq levelChoice "3a")
				(setq choiceShield (itmCreateRandom "s" "-vcv- ----- ----- -----"))

			(eq levelChoice "3b")
				(setq choiceShield (itmCreateRandom "s" "-vcu- ----- ----- -----"))
			(eq levelChoice "4a")
				(setq choiceShield (itmCreateRandom "s" "--vcv ----- ----- -----"))

			(eq levelChoice "4b")
				(setq choiceShield (itmCreateRandom "s" "--vcu v---- ----- -----"))
			(eq levelChoice "5a")
				(setq choiceShield (itmCreateRandom "s" "---vc v---- ----- -----"))

			(eq levelChoice "5b")
				(setq choiceShield (itmCreateRandom "s" "---vc uv--- ----- -----"))
			(eq levelChoice "6a")
				(setq choiceShield (itmCreateRandom "s" "----v cv--- ----- -----"))

			(eq levelChoice "6b")
				(setq choiceShield (itmCreateRandom "s" "----v cuv-- ----- -----"))

			)
			
	
				(if choiceShield
				(block Nil
					(objAddItem gSource choiceShield)
					(shpInstallDevice gSource choiceShield)
							)
						)
		)
			
		)	
				
		)
	)
		
	)



		
)

</Globals>
	
Also note that each <OnCreate> needs the "1a" or "extended" instead of 1a and extended for each defined weapon set. I changed the enhancement code, I had it rigged to always do the enhancement and wasn't getting it from the way your (random (list was set up.

So... something like that should be working now.

Also- the first level ships seem to get the DMX missiles quite often, which makes them very easy to kill. Is it denoted with a +Launcher modifier?
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

using '1a it doesn't work, because '1a aways became 1 and not 1a.

So I changed everything again to "1a" and finally it works ! :D
yeah ! Now I'm ready to do the sovereign dependent random weapons I wanted to do.



'extended instead works fine, I don't know why '1a doesn't work.

[EDIT] Updated the zip to xelerus with the working version.
Now it's called Random Equip Mod 3
http://xelerus.de/index.php?s=mod&id=111
Same link at the first post.
Last edited by digdug on Sun Apr 06, 2008 8:02 pm, edited 1 time in total.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

Me neither, but I just went for "" as the preferred choice.

Did you notice the enhancement fix? I wasn't getting any enhanced weapons until I set up the extra code there.
User avatar
digdug
Fleet Admiral
Fleet Admiral
Posts: 2620
Joined: Mon Oct 29, 2007 9:23 pm
Location: Decoding hieroglyphics on Tan-Ru-Dorem

I saw your fix for the enhanced weapons, however I changed (eq roll 1) to (leq roll 9) and removed the (gr roll 1) line and nearly all the weapons were enhanced, so the code works.
BTW I copied that part of the code directly from the weapons dealer (George's code), so I didn't even bother to deply test it. :)


Betel told me that (gr roll 1) is not needed in the switch and it also prevent crashes by creating a default option for the switch itself.
I also added a default option for the choiceWeapon switch to prevent crashes.
User avatar
Periculi
Fleet Officer
Fleet Officer
Posts: 1282
Joined: Sat Oct 13, 2007 7:48 pm
Location: Necroposting in a forum near you

so your saying that (random (list ...)) works fine to select the enhancement?

It wasn't really working for me. I set roll to 1 without a random to test it (making every weapon get enhanced) and it wouldn't put anything on the weapons. But maybe the problem was in the if statement later on down the line.
george moromisato
Developer
Developer
Posts: 2998
Joined: Thu Jul 24, 2003 9:53 pm
Contact:

digdug wrote:using '1a it doesn't work, because '1a aways became 1 and not 1a.
Good point! I forgot about that. "1a" is better anyway.
Post Reply