Wing retreat

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
|K.O.S.H.
Posts: 3235
Joined: Fri, 19. Dec 03, 11:36
x3tc

Wing retreat

Post by |K.O.S.H. » Mon, 4. Nov 19, 12:30

Hi all,

i'm searching for a script, that enables the retreat command (don't react, when beeing attacked) for all ships a of a wing.
Its supposed for hit andf run tactics, i want my ships to return to their carrier, after destroying a target or when the enemy is stronger, than expected. (maybe somebody has a better idea)
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

User avatar
Hector0x
Posts: 548
Joined: Mon, 18. Nov 13, 19:03
x3tc

Re: Wing retreat

Post by Hector0x » Mon, 4. Nov 19, 16:53

There is a Wingmen go home hotkey script in Mayhem's addon scripts folder. Maybe you could utilize that file.

User avatar
Joubarbe
Posts: 4162
Joined: Tue, 31. Oct 06, 13:11
xr

Re: Wing retreat

Post by Joubarbe » Mon, 4. Nov 19, 18:44

Having your wings auto-evaluate their enemies and retreat automatically would take some work though. And automatic retreat can have some very frustrating consequences (plus you would probably have to edit some vanilla scripts to cancel auto retreat when a manual command is given).

The script in question:

Code: Select all


$wingmen = [NULL]-> call script 'Mayhem.GetWingmen' :
$count = 0
for each $ship in array $wingmen
$homebase = $ship-> get homebase
skip if $homebase-> exists
continue

$wing = $ship-> get flight wing
if $wing
do if $ship-> is task 0 in use
START $wing-> wing command [COMMAND_WING_NONE] : arg1=null, arg2=null, arg3=null, arg4=null
* Formation move doesn`t work great... Individual run is acceptable.
* START $ship -> call script `!wing.cmd.movestation.std`: wing=$wing object=$homebase
* START $ship -> call script `!wing.move.movetostation`: wing=$wing object=$homebase
START $ship-> call script '!ship.cmd.returnhome.std' :
else
START $ship-> call script '!ship.cmd.returnhome.std' :
end
inc $count
end

$t = 'Wingmen: go home ('

if $count > 1
$t = $t + $count + ' ships sent to homebase)'
else
$t = $t + $count + ' ship sent to homebase)'
end
do if $count > 0
START speak text: page=13 id=131 priority=80

START [NULL]-> call script 'Joubarbe.Lib.Infobox' : text=$t icon=10 timeout=5000 fadeout=1000

return null
(sorry, no indentation)

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

Re: Wing retreat

Post by JSDD » Thu, 7. Nov 19, 00:24

hi kosh,

codea has such an option, where you can say "do not attack bigships", which means when all the enemy fighters are done, your fighters will return home even while under attack (for example by a bigship).

however. the problem here isnt giving several ships in a wing a certain command (simple for loop will suffice for that), you have to "hook" the signal_attacked for each ship in the wing (on setup, for example when giving a special "hit & run attack" cmd), redirecting signal_attacked to "your" modified script version, in which you adjust the logic so that there wont be a "interrupter script" called if attacked ... usually the "interrupter script" is just fight.attack.object.xml

Code: Select all

Script !ship.signal.attacked
Version: 4
for Script Engine Version: 40

Description
Asynchron signal. attacked 
Arguments
•1: attacker , Var/Ship/Station , 'the attacker' 
•2: action , Var/Number , 'action' 

Source Text


001   * try a defensive move
002   if [THIS] -> is in active sector
003   |$littleship = [THIS] -> is of class Little Ship
004   |skip if not [THIS] -> is of class M6
005   ||$littleship = [TRUE]
006   |skip if not [THIS] -> is of class M7
007   ||$littleship = [TRUE]
008   |if $littleship AND $action != [ACTION_LAND_IN_STATION] AND $action != [ACTION_ENTER_GATE] AND $attacker
009   ||$shieldrandom =  = random value from 3000 to 6000 - 1
010   ||$hullrandom =  = random value from 50 to 80 - 1
011   ||$hull = [THIS] -> get hull percent
012   ||$shield = [THIS] -> get current shield strength
013   ||if $shield < $shieldrandom OR $hull < $hullrandom
014   |||$intensity =  = random value from 80 to 100 - 1
015   |||$timeout =  = random value from 5000 to 15000 - 1
016 @ |||= [THIS] -> defensive move: type=null, intensity=$intensity, timeout=$timeoutms, avoid object=$attacker
017   ||end
018   |end
019   end
020   
021   * check if already a attack is executed
022   skip if not is script with prio 99 on stack
023   |return [TRUE]
024   * already attacking the attacker...
025   $attacktarget = [THIS] -> get attack target
026   skip if $attacker != $attacktarget
027   |return null
028   skip if [THIS] != [PLAYERSHIP]
029   |return null
030   skip if $attacker
031   |return null
032   skip if $attacker -> exists
033   |return null
034   skip if [THIS] -> is $attacker a enemy
035   |return null
036   
037   $has.laser = [THIS] -> get maximum laser strength
038   if [OWNER] == Player
039   * fight software must beinstalled
040   |if not [THIS] -> get amount of ware Fight Command Software MK1 in cargo bay
041   ||if not [THIS] -> get amount of ware Fight Command Software MK2 in cargo bay
042   |||$has.laser = null
043   ||end
044   |end
045   end
046   
047   if $has.laser
048   |$followmode = [THIS] -> get follow mode
049   |[THIS] -> set follow mode [FALSE]
050   |
051   |set script priority to 99
052 @ |= [THIS] -> call script '!fight.attack.object' :  the victim=$attacker  follow in new sector=null
053   |
054   |[THIS] -> set follow mode $followmode
055   |return [TRUE]
056   else if not is script with prio 50 on stack
057   |[THIS] -> set relation against $attacker to Foe
058   |$flags = [Find.Nearest] | [Find.DockingAllowed]
059   |$station =  find station: sector=[SECTOR] class or type=Station race=null flags=$flags refobj=[THIS] maxdist=6000 maxnum=1 refpos=null
060   |if $station -> exists
061   ||$followmode = [THIS] -> get follow mode
062   ||[THIS] -> set follow mode [FALSE]
063   ||set script priority to 50
064 @ ||= [THIS] -> call script '!ship.sh.attack.ts.flee' :  the attacker=$attacker  station to dock at=$station
065   ||[THIS] -> set follow mode $followmode
066   ||return [TRUE]
067   |end
068   end
069   return null
070   * Changelog:
071   * v3: script does not trigger response if response is already running (on task 50)
072   * v4: ships without fight software flee, do not ignore attack
check line 52
line 28 for example prohibits a reaction from playership (you) when attacked
the whole IF-block from line 47 until 69 is what causes a ship to respond when attacked


if an enemy seems to be very strong, how can you detect it?
either you (by hitting a hotkey) set a flag that says "wing yxz: return to me" or (the automatic or "semi"-intelligent version) when the damage done by your wing is (far) less than the damage done to your wing, set the same "wing xyz: return to me" flag.
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

|K.O.S.H.
Posts: 3235
Joined: Fri, 19. Dec 03, 11:36
x3tc

Re: Wing retreat

Post by |K.O.S.H. » Wed, 13. Nov 19, 10:33

Hi all. Thx for the answers.

At first: i dont use LC, because i'm modding my very own game constantly for over ten years (dozents of new ships, weapons, scripts, effects -> everything).


I once found a script for two new wing commands: "attack fighters" and "attack bigships".
I then (some years ago) tried to modify it to have a "wing retreat" script. (viewtopic.php?t=292729)

There is a retreat scrip for single ships, which can be called via command (and per hotkey by my own modded script). If this script is called on a wIng ist fails, but i'm, not sure if i did it properly.

Well, i fact i only want this standard script to be called on every ship on a wing, like its done with the above mentioned scripts (attack fighters, attack bigships).
So e.d. my bombers should return home, when they are attacked by anything.

The problem is, you can order them, to return home, but if they are attacked, they will abort and fight back.
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

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

Re: Wing retreat

Post by JSDD » Sat, 16. Nov 19, 01:13

|K.O.S.H. wrote:
Wed, 13. Nov 19, 10:33
The problem is, you can order them, to return home, but if they are attacked, they will abort and fight back.
as i said, thats the default behavior for armed ships ... if you want to change that, you have to change the corresponding signal_attacked script.

there is 1 global "script map" defining the response script for any kind of signal (attacked, killed, docked, etc)
you can override that for any specific ship (your wing maybe) you want ... by calling:

Code: Select all

<the.ship> connect ship command/signal <the.signal> to script <the.script> with prio <the.prio>
when you think your ships are done with the task you wanted them to do, you should reset the signal response script by calling:

Code: Select all

<the.ship> set ship command/signal <the.signal> to global default behavior
--------------------------------------

maybe you want your wing to ignore enemies even when under attack, so copy the default signal-attacked-script (i´ve showed above), and modify it a bit like:

IF THIS -> is in active sector // meaning "In Sector"

IF ... attacker is faster than me ...
--> evade attacker, do manouvers, change ship speed abruptly and so on (another special script)
else IF ... attacker is slower but is standing in my way (just check the distances to THIS and homebase [you])
--> move around the attacker or do another fancy trick move
else
--> just move home ...
end

else

... what to do if OOS ?

end

--------------------------------------


implememtation ?!

--> have a wing command script you want your wing to execute
--> at the beginning, change the signal_attacked response as shown above
--> start a "watcher script" on task xyz thats only job is to wait until your wing command script isnt running anymore on task 0 (main ship task)
----> watcher script resets response script to default when wing command script isnt running anymore (as a clean_up)
--> just call fight.attack.object or so ...
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

|K.O.S.H.
Posts: 3235
Joined: Fri, 19. Dec 03, 11:36
x3tc

Re: Wing retreat

Post by |K.O.S.H. » Tue, 19. Nov 19, 14:37

ok, i got everything (i think)

Modifieing the !ship.signal.attacked scriopt seems the best way, also for other situations.

Thx a lot.

But i still don't get, that I seem to be the only person, who needs that?
Wing Commander Mod - German Topic
06.07.11 - v1.1 RELEASED!

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

Re: Wing retreat

Post by JSDD » Tue, 19. Nov 19, 23:46

... i´m quite a bit lazy when it comes to scripting, because i know once i start modifying, i cant stop :D (hab auch z.Z. relativ wenig zeit zum zocken)

so my solution is to use codea and tell the carrier how it should handle the fighters ^^
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

Post Reply

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