Some help with scripting

Freeform discussion about anything related to modding Transcendence.
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

I wanted to make a mod where the sovereigns every few minutes have a small chance of switching their disposition with another sovereign. I need help with the random parts, because I am mostly limited to timers, and basic functions to use. I need to have:


Random chance for everything
If it goes, then pick a random sovereign
Pick a different sovereign
If it isn't this (meaning certain sovereigns can't be enemies/allies with oters, I.E Commonwealth can't be allies with Ares.
Then get their disposition
If it's ally, choose either enemy or neutral
If it's enemy, choose either ally or neutral
If it's neutral, choose either enemy or ally


I can get the timer and the actual changing of the sovereigns, but I really have no prior experience in the rest of it.
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

Moved to shipyard.

I'm doing something vaguely similar but much more complex (a strategic AI that can change alignments between factions.) However I'm starting with everything hardcoded into static data.
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

It is a bit hard to tell what you actually need help with. Do you need to find out how to pick the sovereign? Where to run the timers?

If you come with specific questions, along with some of the supporting code you have, then I am sure a solution can be found.

You can also have a look at Prophets Dynamic Sovereign mod on xelerus: http://xelerus.de/index.php?s=mod&id=816
It might provide something you can use.
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

:shock: Never seen that one before.
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

Essentially, I have no idea how to do get the game to pick a random number and use that number to pick something. I really have no knowledge of how to do the scripting.
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
User avatar
Aury
Fleet Admiral
Fleet Admiral
Posts: 5421
Joined: Tue Feb 05, 2008 1:10 am
Location: Somewhere in the Frontier on a Hycrotan station, working on new ships.

ah, I see

I think its (rand A B) or (random A B) (I don't remember which) where A and B are the limits of the range of numbers you would like to randomly select from. It will return a number from A to B inclusive.
Then you would use a switch to decide on the alignment. Your conditions would look something like this:
(leq aRandomNumber 25) where earlier aRandomNumber was set to be (random 1 100) or something like that. Someone who scripts more often than I do should tell you XD (I often have to look stuff up from previous code I've written to refresh myself)
(shpOrder gPlayership 'barrelRoll)
(plySetGenome gPlayer (list 'Varalyn 'nonBinary))
Homelab Servers: Xeon Silver 4110, 16GB | Via Quadcore C4650, 16GB | Athlon 200GE, 8GB | i7 7800X, 32GB | Threadripper 1950X, 32GB | Atom x5 8350, 4GB | Opteron 8174, 16GB | Xeon E5 2620 v3, 8GB | 2x Xeon Silver 4116, 96GB, 2x 1080ti | i7 8700, 32GB, 6500XT
Workstations & Render machines: Threadripper 3990X, 128GB, 6900XT | Threadripper 2990WX, 32GB, 1080ti | Xeon Platinum 8173M, 48GB, 1070ti | R9 3900X, 16GB, Vega64 | 2x E5 2430L v2, 24GB, 970 | R7 3700X, 32GB, A6000
Gaming Systems: R9 5950X, 32GB, 6700XT
Office Systems: Xeon 5318Y, 256GB, A4000
Misc Systems: R5 3500U, 20GB | R5 2400G, 16GB | i5 7640X, 16GB, Vega56 | E5 2620, 8GB, R5 260 | P4 1.8ghz, 0.75GB, Voodoo 5 5500 | Athlon 64 x2 4400+, 1.5GB, FX 5800 Ultra | Pentium D 3.2ghz, 4GB, 7600gt | Celeron g460, 8GB, 730gt | 2x Athlon FX 74, 8GB, 8800gts 512 | FX 9590, 16GB, R9 295x2 | E350, 8GB | Phenom X4 2.6ghz, 16GB, 8800gt | random core2 duo/atom/i5/i7 laptops
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Drako Slyith wrote:Essentially, I have no idea how to do get the game to pick a random number and use that number to pick something. I really have no knowledge of how to do the scripting.
If you have a list of items (sovereigns for example), and you want to pick a random one, here is the easiest way

Code: Select all

(setq sovlist (list &svOne; &svTwo; &svThree;))

;; pick a random one
(setq myRandomSov (random sovlist))
You can generate a list of sovereigns in game by using typFind
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

Ok thanks. I think i can do a lot of it now.
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

Ok so I wrote out some code here:

Code: Select all

<OnCreate>
	(sysAddObjRecurringTimerEvent 20000 gPlayership "AllianceChange")
</OnCreate>

<AllianceChange>
(setq sovlist (list &svCommonwealth; &svPirates;))

(setq randomSov1 (random sovlist))
(setq sovlist2 (list &svCentauriWarlords; &svCorporate;))

(setq randomSov2 (random sovlist2))
(setq disList	(list 'friend 'neutral 'enemy)
(setq randomDis (random disList))

								
								
								
								
								
								(sovSetDisposition (randomSov1) (randomSov2) (randomDis))
								(sovSetDisposition (randomSov2) (randomSov1) (randomDis))
	
		
</AllianceChange>


Will all this work? Also, any ideas where I could put it? I was thinking I could overwrite playerships, but I would rather not overwrite anything. Also, it would be best if this worked with mod ships. Maybe I could ride this code in the star in Eridani? I put the timer to run from the player, so I think it should keep running, but I'm not sure.
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Drako Slyith wrote:Ok so I wrote out some code here:

Code: Select all

<OnCreate>
  (sysAddObjRecurringTimerEvent 20000 gPlayership "AllianceChange")
</OnCreate>

<AllianceChange>
  (setq sovlist (list &svCommonwealth; &svPirates;))
  (setq randomSov1 (random sovlist))

  (setq sovlist2 (list &svCentauriWarlords; &svCorporate;))
  (setq randomSov2 (random sovlist2))

  (setq disList (list 'friend 'neutral 'enemy)
  (setq randomDis (random disList))
													
  (sovSetDisposition randomSov1 randomSov2 randomDis)
  (sovSetDisposition randomSov2 randomSov1 randomDis)
</AllianceChange>
Something like that might work (notice I removed the parentheses from around randomSov1,2 and randomDis inside the sovSetDisposition function call)

It should work, but there might be some things to clear out.
Also, any ideas where I could put it?
There are many possibilities. The answer mostly depends upon what type of mod you are making and how much control you have over the environment. Personally I favor using one virtual station that uses the <OnGlobalPlayerEnteredSystem> event to place a single station that then runs the events... this last station must be present in every system. However, thre are other methods.

Also, If you have more control over environment there are better solutions. So, what mod are you making this for?

Also, you should really take a look at Prophets mod that I linked above. I am sure it contains something you can use!

If you need to discuss this in more detail you are also welcome to pop on irc and we can go over it with some pastes.
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

Ok thanks. I was planning to use this as just a POC mostly. What I was thinking is I could rewrite all stars so that they have the code. Thanks for the help :D

EDIT I just did a quick test to see if it worked. I made an item with the code in the invoke section. I set the first list to only use the player, so I could see the changes on my map. I used the item several times, but nothing happened. Any ideas why?
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Drako Slyith wrote:I made an item with the code in the invoke section.
What code?
Drako Slyith wrote:I set the first list to only use the player,
What list? Use the player?
Drako Slyith wrote:so I could see the changes on my map.
On your map?

As you might guess you lost me as to what you did :P

Make a paste of what you have done and I will have a look.
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

Here you go:

Code: Select all

	<ItemType UNID="&itTesterSov;"
			name=				"Sovereign Shifter"
			level=				"1"
			value=				"50000000000"
			mass=				"100"
			frequency=			"notRandom"

			modifiers=			"MajorItem; Military"

			description=		"Testing my sovereign shift system"
			>

		<Image imageID="&rsItems1;" imageX="0" imageY="192" imageWidth="96" imageHeight="96"/>

		
			

		<MiscellaneousDevice
				powerUse=			"100"

				/>

		<Invoke key="H" installedOnly="true">

								(setq sovlist (list &svPlayer;))

(setq randomSov1 (random sovlist))
(setq sovlist2 (list &svCentauriWarlords; &svCommonwealth;))

(setq randomSov2 (random sovlist2))
(setq disList	(list 'friend 'neutral 'enemy)
(setq randomDis (random disList))

								
								
								
								
								
								(sovSetDisposition (randomSov1) (randomSov2) 

(randomDis))
								(sovSetDisposition (randomSov2) (randomSov1) 

(randomDis))
		</Invoke>
	</ItemType>
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

OK, as the first thing, you need to wrap all the code inside the <Invoke> tag in a block. See the description of block on xelerus.
Otherwise the only expression being evaluated is the first one.

Secondly, like I wrote in one of my posts above you need to remove the () from the values.
Basically, in tscript, when you wrap something in () you are trying to evaluate it as a function. So in the part of your code that reads:

Code: Select all

(sovSetDisposition (randomSov1) (randomSov2) (randomDis))
(sovSetDisposition (randomSov2) (randomSov1) (randomDis))
you are trying to evaluate randomSov1, randomSov2, randomDis as if they were functions. Which they are not. They are just values. Try to remove the () from around each and you should be getting some results.

Let me know how it goes ;)
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

I removed the parentheses, but even when I tried it around a dozen times I got nothing.
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
Post Reply