[Discussion] Generic X3TC S&M questions II

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

User avatar
s9ilent
Posts: 2033
Joined: Wed, 29. Jun 05, 01:45
x4

Post by s9ilent »

Out of curiosity, how many powers did you take it to?
What was your last x^n term?
User avatar
Litcube
Posts: 4254
Joined: Fri, 20. Oct 06, 19:02
xr

Post by Litcube »

s9ilent wrote:Out of curiosity, how many powers did you take it to?
What was your last x^n term?
The last was -9, as I'm pretty sure all variables were right up until I converted them to X3's 0 - 65,536 angles.
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Ok, I've got several arrays of sectors here, what's the best way of displaying them in a menu?

I want:

Title1:
Sector 1 from array 1.
Sector 2 fro...
etc.

Title2:
Sector 1 from array 1.
S...

Etc. etc.


Not sure of the best way to put text arrays into menus.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Ok, I've got several arrays of sectors here, what's the best way of displaying them in a menu?
It's pretty straight-forward: Go through your arrays one by one and add a menu entry for each sector.

There are no shortcuts, but you should be done with some loops.

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Any way of them looking reasonably nice...? :P
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Because of these pictures I thought that you knew your way around menus, don't you? Or is there a special problem with arrays I don't understand?

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Menus were Mark's domain. :P


I know my way around menus reasonably, I just have trouble making them look half decent. What I've got so far will do:

http://i758.photobucket.com/albums/xx22 ... 1290707861
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Menus were Mark's domain.
Ah, okay. :D
What I've got so far will do
There's not much more you can do. I think not using an info menu, but a normal menu instead would help, since the menu now is too broad. I don't think colors would help much.

As a general idea: Can these intrusion altert levels be set by the user? If so, you could also use value selections for each sector. Maybe sorting the sectors by name or alphabet to make it more clearly arranged. Just an idea.

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Hmm, user set levels might be good. They don't actually have an ingame effect, the alerts, they're just for the player's benefit. Colour will come later. As for Alphabetising it, I was going to but I'm not sure how.

At all.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
mark_a_condren
Posts: 1468
Joined: Wed, 3. Aug 05, 05:05
x3tc

Post by mark_a_condren »

EJon

How about setting up the menu something like this. With the code the way you have it, it will work out like this quite easily.


[ external image ]


MarCon
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Because it only has data for 1 race on purpose. :P

Any knowledge on alphabetising?
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Hmm, any idea on why this is all of a sudden choosing completely random ships to hit, way out of range, and very occasionally everyone?

Line52 would have a Kill Object on it, I removed it for Debug purposes.

Code: Select all

001   $Checking = [THIS] -> get local variable: name='ej.military.bigship.blast'
002   $BlastPlaceholder = [THIS] -> get local variable: name='ej.wreck.explo'
003   if $Checking != [TRUE] AND $BlastPlaceholder == [FALSE]
004   |[THIS] -> set local variable: name='ej.military.bigship.blast' value=[TRUE]
005   |
006   |$Sector = [THIS] -> get sector
007   |$Att = [THIS] -> get attacker
008   |$DeadShip = [THIS] -> get position as array
009   |
010   |$ShipA = $Sector -> get ship array from sector/ship/station
011   |$StaA = $Sector -> get station array from sector
012   |
013   |$Count1 =  size of array $ShipA
014   |while $Count1
015   ||dec $Count1 = 
016   ||$Ship = $ShipA[$Count1]
017   ||skip if not $Ship -> is invincible
018   |||gosub End
019   ||skip if not $Ship == [THIS]
020   |||gosub End
021   ||$Ins = $Ship -> get maximum shield strength
022   ||$Range = get distance between $Ship and $DeadShip
023   ||if $Range >= 0 AND $Range < 500
024   |||$Rand1 =  = random value from 200000 to 1250000 - 1
025   |||$Damage = $Rand1
026   ||else if $Range >= 500 AND $Range < 1000
027   |||$Rand2 =  = random value from 50000 to 200000 - 1
028   |||$Damage = $Rand2
029   ||else if $Range >= 1000 AND $Range < 1500
030   |||$Rand3 =  = random value from 5000 to 50000 - 1
031   |||$Damage = $Rand3
032   ||else if $Range >= 1500 AND $Range < 2000
033   |||$Rand4 =  = random value from 1000 to 5000 - 1
034   |||$Damage = $Rand4
035   ||else if $Range >= 2000 AND $Range < 5000
036   |||$Damage = 1000
037   ||else if $Range > 5000
038   |||$Damage = 0
039   ||end
040   ||$Shield = $Ship -> get current shield strength
041   ||$ShieldAfter = $Shield - $Damage
042   ||$Ship -> set current shield strength to $ShieldAfter
043   ||display subtitle text: text='Damaged' duration=121 ms
044   ||$HitClass = $Ship -> get object class
045   ||
046   ||if $ShieldAfter <= 0 OR $Ins <= 0
047   |||$Debt = $Damage - $Shield
048   |||$HullAfter = $Hull - $Debt
049   |||$Ship -> set hull to $HullAfter
050   |||$FinalHull = $Ship -> get hull
051   |||if $FinalHull <= 0
052   ||||
053   ||||write to player logbook $DeadShip
054   ||||write to player logbook $Ship
055   ||||write to player logbook $Range
056   |||end
057   ||end
058   |end
059   |
060   |$Count2 =  size of array $StaA
061   |while $Count2
062   ||dec $Count2 = 
063   ||$Sta = $StaA[$Count2]
064   ||skip if not $Sta -> is invincible
065   |||gosub End
066   ||skip if not $Sta == [THIS]
067   |||gosub End
068   ||$Ins = $Sta -> get maximum shield strength
069   ||$Range = get distance between $Sta and $DeadShip
070   ||if $Range >= 0 AND $Range < 500
071   |||$Rand1 =  = random value from 200000 to 1250000 - 1
072   |||$Damage = $Rand1
073   ||else if $Range >= 500 AND $Range < 1000
074   |||$Rand2 =  = random value from 50000 to 200000 - 1
075   |||$Damage = $Rand2
076   ||else if $Range >= 1000 AND $Range < 1500
077   |||$Rand3 =  = random value from 5000 to 50000 - 1
078   |||$Damage = $Rand3
079   ||else if $Range >= 1500 AND $Range < 2000
080   |||$Rand4 =  = random value from 1000 to 5000 - 1
081   |||$Damage = $Rand4
082   ||else if $Range >= 2000 AND $Range < 5000
083   |||$Damage = 1000
084   ||else if $Range > 5000
085   |||$Damage = 0
086   ||end
087   ||$Shield = $Sta -> get current shield strength
088   ||$ShieldAfter = $Shield - $Damage
089   ||$Sta -> set current shield strength to $ShieldAfter
090   ||if $ShieldAfter <= 0 OR $Ins <= 0
091   |||$Debt = $Damage - $Shield
092   |||$HullAfter = $Hull - $Debt
093   |||$Sta -> set hull to $HullAfter
094   |||$FinalHull = $Sta -> get hull
095   |||if $FinalHull <= 0
096   ||||$Sta -> destroy object: killer=$Att, show no explosion=[FALSE]
097   |||end
098   ||end
099   |end
100   |
101   End:
102   end
103   return null
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Mh, the only thing that seems wrong to me, are the following lines:

Code: Select all

013   |$Count1 =  size of array $ShipA
014   |while $Count1
015   ||dec $Count1 =
016   ||$Ship = $ShipA[$Count1]
017   ||skip if not $Ship -> is invincible
018   |||gosub End
019   ||skip if not $Ship == [THIS]
020   |||gosub End 
You are traversing the array, but if one of the ships of the arrays is [THIS] (which it always is), you directly end the complete script. I think, you intended to do the following:

Code: Select all

013   |$Count1 =  size of array $ShipA
014   |while $Count1
015   ||dec $Count1 =
016   ||$Ship = $ShipA[$Count1]
017   ||skip if not $Ship -> is invincible
018   |||continue
019   ||skip if not $Ship == [THIS]
020   |||continue 
"gosub End" doesn't make much sense anyway, if "End" is just "return null".


There are still some other thing, that I'd like to point out:

Code: Select all

101   End:
102   end
103   return null
I actually don't know what the SE does, when it finds an "end", without a corresponding opening statement (like "while", "if", etc.). I think it's safer not to rely on any kind of behaviour and just switch these lines.

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Hmm, good point, didn't think about that.

Removed the gosub.


EDIT:
Hmm, at the moment it seems to think the distance between the blowing up ship and the hit ship is either 0, or some big minus number. :S
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Ah, okay. Look at the signatures of the commands again and you'll see why:

<RetVar> = get distance between <Var/Ship/Station> and <Var/Ship/Station>
<RetVar> = get distance: position array1=<Var/Array> array2=<Var/Array>


You use the first command, which directly uses ingame objects, but you give it position arrays. Thus you should either use the second command or use the objects directly (which is imo the better choice).

Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Yeah, noticed that and I'm now using objects... seems to be getting the range correctly but damage calc is still way out and I can't seem to figure out where it's going wrong...
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

Where do you define $Hull for the following line?

Code: Select all

$HullAfter = $Hull - $Debt 
Greetings,
ScRaT
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Can't believe I didn't notice that. I'd just noticed that if you've got more shielding than damage taken you end up with -debt, which is then -... so if you took a bit of shield damage with a ship with hull damage you'd get hull back. :roll: :lol: Can't believe I didn't notice I slightly more glaringly obvious point.


Yup, fixed.

Dumped some Falcon S. next to an Akuma, one directly inside it, one 500m away from the center (in one wall), then 1km, 2km, 4km, and 6km.

1 and 2 eliminated, 3 17% shield, 4 99% shield, 5 & 6 completely untouched.


Will try again with a less shielded fighter for trials.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
EmperorJon
Posts: 9378
Joined: Mon, 29. Dec 08, 20:58
x3tc

Post by EmperorJon »

Any better maths I could use for the damage?

If Range = 0
Damage = 1500000
Else
Damage = 1500000 / Range
Top = Damage + ((Damage / 100) * 20)
Bottom = Damage - ((Damage / 100) * 20)
DamageRand = Random number between Top and Bottom -1.

If Range > 5000

?

Top damage would be 1,500,000
Bottom would be 300 at 5 Km.

(not taking into account the randomiser)

Does that sound feasible?

What I don't like is ending on 300 damage, which for small crafts is quite significant. 1m could seperate you from serious damage to no damage if you're in an M5.



EDIT: Most of that was complete nonsense.
______
I'm Jon. I'm mostly not around any more. If you want to talk, please message me! It's cool.
______
User avatar
ScRaT_GER
Posts: 1962
Joined: Tue, 8. Jan 08, 18:19
x3tc

Post by ScRaT_GER »

How about some pyhsics? The intensity of a spherical wave is proportional to the square of the distance. In other words:
I ~ 1/r²

So in your case this would be:

$Damage = $Damage / ($Range * $Range)

If $Range is small, the resulting damage will be big, if it is big, the resulting damage will be small.

You should take some care when calculating in X like this of course, since it only uses integers. Additionally you have to take into account overflows (could be the result of $Range * $Range) and dividing by zero (although that should never happen since two objects will almost (?) never have the same position).

Greetings,
ScRaT

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