[Discussion] Generic X3TC S&M questions III

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Post Reply
User avatar
JSDD
Posts: 1378
Joined: Fri, 21. Mar 14, 20:51
x3tc

Re: [Discussion] Generic X3TC S&M questions III

Post by JSDD » Thu, 22. Nov 18, 19:07

you want to figure out if the sector you´ve entered wasnt known before? then you´ve got to create a list of values beforehand, storing wheater it is known or not (is my first guess) ... when arriving, check the value stored in the list, and update it afterwards ... you want to figure out how to loop over a certain range of values?! => check out my example code pieces in my signature ;)
To err is human. To really foul things up you need a computer.
Irren ist menschlich. Aber wenn man richtig Fehler machen will, braucht man einen Computer.


Mission Director Beispiele

User avatar
creatoxx
Posts: 32
Joined: Wed, 17. Oct 18, 14:01
x3tc

Re: [Discussion] Generic X3TC S&M questions III

Post by creatoxx » Fri, 23. Nov 18, 12:25

JSDD wrote:
Thu, 22. Nov 18, 19:07
you want to figure out if the sector you´ve entered wasnt known before? then you´ve got to create a list of values beforehand, storing wheater it is known or not (is my first guess) ... when arriving, check the value stored in the list, and update it afterwards ... you want to figure out how to loop over a certain range of values?! => check out my example code pieces in my signature ;)
:? :gruebel: ...

Code: Select all

	<cues>
	
		<cue name="initCue">
			<timing>
				<time min="1s"/>
			</timing>
			<action>
				<do_all>
					<set_value name="earthKnown" exact="1"/><!-- this list is going to be endless! -->
					<set_value name="moonKnown" exact="0"/>
					<set_value name="venusKnown" exact="0"/>
				</do_all>				
			</action>
		</cue>
		
		<cue name="cue01">
			<condition>
				<check_all>
					<cue_is_complete cue="initCue"/>
					<object_changed_sector/>
				</check_all>
			</condition>
			<timing>
				<time min="1s"/>
			</timing>			
			<action>
				<do_all>
					<do_if value="{sector.known@sector.earth}" exact="1"><!-- this list is also going to be endless! -->
						<set_value name="initCue.earthKnown" exact="1"/><!-- value@initCue.earthKnown? -->
					</do_if>			
					<do_if value="{sector.known@sector.moon}" exact="1">
						<set_value name="initCue.moonKnown" exact="1"/>
					</do_if>
					<do_if value="{sector.known@sector.venus}" exact="1">
						<set_value name="initCue.venusKnown" exact="1"/>
					</do_if>					
				</do_all>	
			</action>
			<cues>
				<cue>
					<condition>
						<cue_is_complete cue="cue01"/>
					</condition>
					<action>
						<do_all>
							<do_if value="initCue.earthKnown" exact="1"><!-- value@initCue.earthKnown? -->
								<reward_player>
									<money exact="1000"/>
								</reward_player>
								<remove_value value="initCue.earthKnown"/><!-- what happens if I remove a value, that's going to be checked in a loop...paradoxon of evil crash? -->																	
							</do_if>			
							<do_if value="initCue.moonKnown" exact="1">
								<reward_player>
									<money exact="1000"/>
								</reward_player>
								<remove_value value="initCue.moonKnown"/><!-- remove needs to be done, so that the check doesn't happen all over again? -->
							</do_if>
							<do_if value="initCue.venusKnown" exact="1">
								<reward_player>
									<money exact="1000"/>
								</reward_player>
								<remove_value value="initCue.venusKnown"/><!-- because I want to get to know an unknown sector only once, to give reward for exploring -->
							</do_if>									  <!-- otherwise that would only benefit the player, for doing mass jumps^^ -->
							<reset_cue cue="cue01"/>						
						</do_all>
					</action>
				</cue>
			</cues>
		</cue>
	</cues>
Edit:

Btw. if I'd just import a list like that upside, I could just as well do it like that, probably using less code, not using any resets...

Code: Select all

	<cues>
	
		<cue name="moonCue">
			<condition>
				<object_changed_sector/>
			</condition>
			<timing>
				<time min="1s"/>
			</timing>
			<action>
				<do_all>
					<do_if value="{sector.known@sector.moon}" exact="1">
						<reward_player>
							<money exact="1000"/>
						</reward_player>					
					</do_if>
				</do_all>
			</action>
		</cue>
		
		<cue name="moonCue">
			<condition>
				<object_changed_sector/>
			</condition>
			<timing>
				<time min="1s"/>
			</timing>
			<action>
				<do_all>
					<do_if value="{sector.known@sector.venus}" exact="1">
						<reward_player>
							<money exact="1000"/>
						</reward_player>					
					</do_if>
				</do_all>
			</action>
		</cue>		
		
	</cues>
It doesn't necessarily matter if I set up a list, as long as MD can't handle lists, groups, whatever, dynamically. That is the simple solution that MD is supposed to deliver, as it is a simple one liner...

Code: Select all

<do_if value="{sector.known@player.sector}" exact="1" & value="initCue.unknownMoon" exact="0">
		...bla bla bla give reward
		...bla bla bla set initCue.unknownMoon exact="1"
		</do_if>
The whole reason why MD is so complicated, is because it can't handle processing two value comparisons. It can't even handle a <do_if> after a <do_if>.

Btw. you bet I already figured how to make endless lists as long as 14 days back. Figuring how endless those lists would be, I tried to figure how to make this dynaically. But obviously MD isn't a script engine.

User avatar
JSDD
Posts: 1378
Joined: Fri, 21. Mar 14, 20:51
x3tc

Re: [Discussion] Generic X3TC S&M questions III

Post by JSDD » Fri, 23. Nov 18, 15:25

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet href="director.xsl" type="text/xsl" ?>
<director name="test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="director.xsd">

  <cues>
    
    <cue name="you_name_it">
      <action>
        <do_all>
          <!-- loop over universe grid -->
          <do_all exact="24" counter="cx">
            <do_all exact="20" counter="cy">
              <set_value name="you_name_it.sector_was_known_{counter@cx}_{counter@cy}" exact="0"/>
            </do_all>
          </do_all>
        </do_all>
      </action>
    
      <cues>
        
        <cue name="you_name_that_one_too" instantiate="static">
          <condition>
            <check_all>
              <object_changed_sector object="{player.ship}"/>
            </check_all>
          </condition>
          <action>
            <do_all>
              <!-- read list value, update list value -->
              <set_value name="this.sector_was_known" exact="{value@you_name_it.sector_was_known_{player.sector.x}_{player.sector.y}}"/>
              <set_value name="you_name_it.sector_was_known_{player.sector.x}_{player.sector.y}" exact="1"/>
              <!-- here your code, use this.sector_was_known as you wish ... -->
            </do_all>
          </action>
        </cue>
      
      </cues>
    
    </cue>
  
  </cues>
  
</director>
To err is human. To really foul things up you need a computer.
Irren ist menschlich. Aber wenn man richtig Fehler machen will, braucht man einen Computer.


Mission Director Beispiele

bit.hauler
Posts: 36
Joined: Sun, 21. Feb 10, 23:38
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by bit.hauler » Wed, 5. Dec 18, 03:58

I apologise if I'm posting in the wrong place. I did some searches but the key words were so frequenti couldn't narrow down to what I need.

Is there a mod that removes the buying and selling price minimum and maximum? My buddy won't play X3 because the economy is broken if there's limitations like this. I think the game has the economics really well figured out but he would enjoy if the limits weren't there.

Thanks!

Lyth
Posts: 2355
Joined: Mon, 21. Jan 08, 03:48
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by Lyth » Wed, 5. Dec 18, 09:08

bit.hauler wrote:
Wed, 5. Dec 18, 03:58
I apologise if I'm posting in the wrong place. I did some searches but the key words were so frequenti couldn't narrow down to what I need.

Is there a mod that removes the buying and selling price minimum and maximum? My buddy won't play X3 because the economy is broken if there's limitations like this. I think the game has the economics really well figured out but he would enjoy if the limits weren't there.

Thanks!
In short, no.
You could tell him that if he docks at stations he can directly barter with traders or accept trade missions as ways to greatly improve the value of the goods or you could install mods that alter the price of good but the min/max would still be a % of that price based on supply.

I have to be honest though, if he thinks that is broken then he doesn't understand the mechanic or the principles of maximum trade prices and he probably should not play the game. Will save him and you alot of stress in the future or just stick to the combat side of things, plenty of other economic games out there if that is his thing. I am not unsympathetic btw, I do get it but it is not broken.
Take it easy, If you can't - Take it by force.

bit.hauler
Posts: 36
Joined: Sun, 21. Feb 10, 23:38
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by bit.hauler » Fri, 7. Dec 18, 18:13

Well, by "broken" he means he's not free to charge whatever price he wants for a product. For example, if I destroy all power plants within 20 sectors and leave mine in the middle, I can't charge 1000cr/ecell if I wanted to. I have to cap it at 19cr. It's based on supply and demand sure but not entirely a free/open economy. Would you agree?

User avatar
nponoBegHuk
Posts: 474
Joined: Thu, 6. Mar 08, 19:55
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by nponoBegHuk » Fri, 8. Feb 19, 16:26

Hi. Is it possible to set fight rank to an arbitrary value via script? I know we have Get fight rank to check the fight rank, but what about setting it?

Also, what is the formula for Trade/Fight/Race rank translation from an integer value to [Standing name] - [%] you get to see on your character stats screen? something like Rank%=Log(bottom/top) current/bottom (bottom = current rank 0% value, top = next rank 0% value, current = current value) seems to come pretty close, but there's definitely something more going on, especially with rounding. The actual percentage is always slightly less than this formula would give, and actually never reaches 99%, it always goes from 98% current rank straight to 0% next rank.

EDIT: rounddown((Log(bottom/top) current/bottom)*99) was found out to match the model exactly for all values of race rank from 10 to 33333, but I'd still like a confirmation on that.
Fast sector selection on the Universe Map | Rock locations for Mobile/OOS mining | Botting for max speed Hyperion | Complete list of ship sources | Capturing smaller ships

My current ship collection:
11 out of 11 *retired* ships found
17 out of 17 *unique* ships found
9 out of 9 *limited* ships found
16 out of 16 *rare* ships found

terodil
Posts: 149
Joined: Sat, 12. Aug 17, 22:13
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by terodil » Tue, 30. Apr 19, 21:36

Hi,

I've run into a really weird problem and hope that somebody might give me a hint. Please?

The issue is the following: I have an array of objects that can consist entirely of ships or entirely of marines on board (not in space) -- ships get repaired, marines get trained. At a few points, I need to distinguish what type of object I'm looking at. A code snippet from my debug script:

Code: Select all

$SFXTargetType = datatype[$SFXTarget]
if $SFXTargetType == [DATATYPE_SHIP]
|$SFXTargetText = $SFXTarget-> get ID code
else if $SFXTargetType == [DATATYPE_PASSENGER]
|$SFXTargetText = $SFXTarget-> get name
else
|$SFXTargetText = '##ERROR: neither ship nor passenger'
end
Ships pass the test and pick the right branch. Marines, however, fall through into the else catch-all. Now the best thing about this is, if I print $SFXTargetType for marines it will actually tell me DATATYPE_PASSENGER, but somehow my if statement still fails to catch them.

What am I not seeing?

I'd be grateful for any help.
My X3 mods: Ship Autoclaimer - Ship Services - Friendlier War Sectors - in development: Logistics Centre

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by SirNukes » Tue, 30. Apr 19, 22:38

Perhaps the "is datatype[x] == y" command would work better, since presumably it exists for a reason.

terodil
Posts: 149
Joined: Sat, 12. Aug 17, 22:13
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by terodil » Tue, 30. Apr 19, 23:16

Hey SirNukes,

thanks so much for replying. Unfortunately, it still won't work:
Spoiler
Show

Code: Select all

if is datatype[$SFXTarget] == [DATATYPE_SHIP]
| $SFXTargetText = $SFXTarget-> get ID code
else if is datatype[$SFXTarget] == [DATATYPE_PASSENGER]
| $SFXTargetText = $SFXTarget-> get name
else
| $SFXTargetText = '= ##ERROR: neither ship nor passenger'
end
still falls through for marines, but not for ships. Exactly like the previous bit of code.

Just for funsies, I made an extremely simple script to test this (I feed it with the parameter $ship, which is a ship that has >10 marines on board).

Code: Select all

$subjects = $ship -> get marines array
$subject = $subjects[0]
$subjectID = $subject-> get id code
$subjectName = $subject-> get name
$subjectType = datatype[$subject]

write to player logbook: printf: fmt='Selected: %s %s (%s)', $subjectID, $subjectName, $subjectType, null, null

if is datatype[$subject] == [DATATYPE_PASSENGER]
| write to player logbook '... is of datatype passenger'
else
| write to player logbook '... is NOT of datatype passenger'
end

return null
Guess what the result is? The player logbook reads:

Code: Select all

... is NOT of datatype passenger
Selected: PGOJA-12 Hatibmanckolanks (DATATYPE_PASSENGER)
This is driving me nuts. :evil:

Thanks again for your time!
Edit: Oh. My. Freakin. Goodness.

There seems to be a bug in the external script editor with this datatype. An obscure russian website lists it along with DATATYPE_SECTOR as malfunctioning (not linking because I'm not sure how malware-free that site is, but it's elite -games.ru... google for "DATATYPE_PASSENGER").

Update: I just tested this and the website is correct, it's a bug in X-Studio. For anybody else wondering, this throws a major wrench into the spanner. Opening the faulty script in the internal editor and saving doesn't fix the bug, but opening and saving the working script in the external editor breaks it again. So the only way to fix this is to edit every occurrence of this piece of code by hand, and then to never let X-Studio take another glance at it.

Does Egosoft use their own editor? Maybe it's just my lack of practice but it really makes me want to stab my own eyes out. Are there any alternatives out there? (Edit: Made a new thread for this so as not to derail this one.)
My X3 mods: Ship Autoclaimer - Ship Services - Friendlier War Sectors - in development: Logistics Centre

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by SirNukes » Wed, 1. May 19, 00:33

terodil wrote:
Tue, 30. Apr 19, 23:16
Update: I just tested this and the website is correct, it's a bug in X-Studio. For anybody else wondering, this throws a major wrench into the spanner. Opening the faulty script in the internal editor and saving doesn't fix the bug, but opening and saving the working script in the external editor breaks it again. So the only way to fix this is to edit every occurrence of this piece of code by hand, and then to never let X-Studio take another glance at it.
It looks like someone reported the bug a year ago over in the X-Studio thread.

I just took a look at the script being saved in-game, through X-studio 1.08, and through Exscriptor 1.2.43. The proper id code for Datatype_Passenger is 0x1001A (65562), but X-studio saves it as 0x0001A (26), apparently having falsely truncated to 16-bits. Anyway, Exscriptor saves it correctly.

Alternatively, you could write a short script on python or similar which will find and repair the busted commands in saved scripts. That sounds like the easiest approach overall. Maybe I will take a stab at that for fun, to brush the rust off my xml knowledge.

terodil
Posts: 149
Joined: Sat, 12. Aug 17, 22:13
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by terodil » Wed, 1. May 19, 00:47

SirNukes wrote:
Wed, 1. May 19, 00:33
It looks like someone reported the bug a year ago over in the X-Studio thread.
Ah, apologies. I truly tried to do my best to find anything related to the issue before I posted here. But then I was probably looking in the wrong place, believing it was about datatype-related script syntax, not about an editor bug.
I just took a look at the script being saved in-game, through X-studio 1.08, and through Exscriptor 1.2.43. The proper id code for Datatype_Passenger is 0x1001A (65562), but X-studio saves it as 0x0001A (26), apparently having falsely truncated to 16-bits. Anyway, Exscriptor saves it correctly.

Alternatively, you could write a short script on python or similar which will find and repair the busted commands in saved scripts. That sounds like the easiest approach overall. Maybe I will take a stab at that for fun, to brush the rust off my xml knowledge.
Ah, right, that's a good idea! I haven't looked into the 'compiled' script section much yet, but you are right -- it's still text, and it should be easy enough to just search + replace once I can nail down the pattern, much better than correcting each instance by hand. Thank you again, SirNukes!
My X3 mods: Ship Autoclaimer - Ship Services - Friendlier War Sectors - in development: Logistics Centre

SirNukes
Posts: 546
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by SirNukes » Wed, 1. May 19, 01:42

terodil wrote:
Wed, 1. May 19, 00:47
Ah, right, that's a good idea! I haven't looked into the 'compiled' script section much yet, but you are right -- it's still text, and it should be easy enough to just search + replace once I can nail down the pattern, much better than correcting each instance by hand.
I posted some python code over in the X-Studio thread: viewtopic.php?f=94&t=301433&p=4866411#p4866411. Feel free to use/edit as desired.

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22197
Joined: Sun, 14. Nov 04, 23:26
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by Cycrow » Wed, 1. May 19, 11:53

terodil wrote:
Tue, 30. Apr 19, 23:16
Does Egosoft use their own editor? Maybe it's just my lack of practice but it really makes me want to stab my own eyes out. Are there any alternatives out there? (Edit: Made a new thread for this so as not to derail this one.)
The internal script editor is the one Egosoft mainly uses. There isn't any official external one

Another way around the bug could be to use the number directly. the DATATYPE's are just constants, it will work equally as well using the number directly, although less readable

terodil
Posts: 149
Joined: Sat, 12. Aug 17, 22:13
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by terodil » Wed, 1. May 19, 12:20

Cycrow: Thank you, too, for your input! I'm having trouble putting it into practice, though. I tried using numbers directly, but the if statements never evaluated to true, I suspect because the datatypes from [is] datatype[$x] (datatype) and the int won't match. W/Could I cast the int as a datatype? Sorry for being so slow, I feel like I'm missing something blindingly obvious here.

SirNukes: Your python script works perfectly. Thank you. You saved me a lot of headaches.

Also, my respect for Egosoft just skyrocketed even more. It has to be a matter of practice, but seriously, writing a number of logically connected scripts just with the internal editor is a feat, no sarcasm and no joke. At the moment, whenever I use the internal editor, I feel like trying to pen a pretty hand-written letter with my weak hand: exasperated.
My X3 mods: Ship Autoclaimer - Ship Services - Friendlier War Sectors - in development: Logistics Centre

Clanf
Posts: 2
Joined: Thu, 11. Jul 19, 16:04
x3ap

Re: [Discussion] Generic X3TC S&M questions III

Post by Clanf » Sat, 13. Jul 19, 18:02

question about director\start.xml - when setting relations, what does mutual="1" exactly do? isn't relations are mutual already or is it something different? i just don't get it and it really hunting me

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22197
Joined: Sun, 14. Nov 04, 23:26
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by Cycrow » Sat, 13. Jul 19, 19:33

Every race has a relation with every other race. The player race you see is how the other races see the player. You can also set how you see the other races in the global command console. Mutual will set the relation both ways. So without mutual, you change the argon and boron relations, it'll change how argon see the boron, but not how the boron will see the argon.

Clanf
Posts: 2
Joined: Thu, 11. Jul 19, 16:04
x3ap

Re: [Discussion] Generic X3TC S&M questions III

Post by Clanf » Sun, 14. Jul 19, 00:03

hm, i think i got it now, its just having separate relations for two races to each other threw me off, you would think "mutual" should be on by default, otherwise there is kinda no point in setting it half way

User avatar
Hairless-Ape
Posts: 313
Joined: Wed, 6. Nov 02, 20:31
xr

Script Reloading

Post by Hairless-Ape » Sat, 10. Aug 19, 03:53

Noob here,


So I modified a script in the /addon/Scripts folder.. new version, and some simple text changes, nothing affecting the logic..
When I load my saved game, and then go into the Script Editor and look at the list of Scripts and their versions, it's showing me the OLD script.
I tried clearing script caches and a few other things, but it seems stuck on V1 of that script no matter how I change it.

How do you force the game to use a new version of a script ?

Thank you,

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24949
Joined: Sun, 2. Apr 06, 16:38
x4

Re: [Discussion] Generic X3TC S&M questions III

Post by X2-Illuminatus » Sat, 10. Aug 19, 17:41

Is the old script file still present in the "addon\scripts" folder but in a .pck format? If so, the game gives precedence to it. If you edit a .pck script file using the script editor, it does not change the .pck-file but rather creates an .xml copy of it.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”