[LIB] Tertiary Signals (v3)

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

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

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

[LIB] Tertiary Signals (v3)

Post by Gazz » Sun, 31. May 09, 17:49

.
According to Cycrow, "Secondary signal attacked was fixed in 2.5"

I have not tested this, yet, but most likely this library is no longer needed.





Secondary SIGNALS do not work. (at least not for SIGNAL_ATTACKED)
I tried and tried for about 12 hours but eventually gave up.
A seconday SIGNAL_ATTACKED fires... sometimes. Or rather once in a blue moon. On some ships.
According to Cycrow they fire before primary signals (which work perfectly fine) so since they not always fire before, they are apparently broken.


No point in crying about it so... here's a library for I guess...
Tertiary Signals


ImageDownload: ZIP



Currently only 4 events are checked:

!ship.signal.attacked
!ship.signal.attacked.ts
!ship.signal.attacked.bigship
!ship.signal.attacked.khaakth

Two lines have to be added to the corresponding Egosoft scripts. (see next post)
Only necessary if you want to support additional signals.


Usage:

Code: Select all

@ = [THIS] -> call script 'lib.gz.tertiary.signal.handler' :  attacker / call script name=$attacker  action=$action  !ship.signal script name=$Script.Name
$Script.Name is simply the name of the !signal script you wish to attach your script to. It is also the global variable name of where the values are stored.

You configure things by directly calling the library.

Action can have 3 string values.
  • "add"
    The script name supplied as "attacker" is added to the list.
    It will be executed everytime the parent script runs.

    Example:

    Code: Select all

    @ = [THIS] -> call script 'lib.gz.tertiary.signal.handler' :  attacker / call script name='plugin.case.of.beer.attacked'  action='add'  !ship.signal script name='!ship.signal.attacked'
    Now 'plugin.case.of.beer.attacked' is always called before the actual !ship.signal.attacked is fully executed.
  • "remove"
    The script name supplied as "attacker" is removed from the list.

    Example:

    Code: Select all

    @ = [THIS] -> call script 'lib.gz.tertiary.signal.handler' :  attacker / call script name='plugin.case.of.beer.attacked'  action='remove'  !ship.signal script name='!ship.signal.attacked'
    'plugin.case.of.beer.attacked' is detached from this signal script.
  • "print"
    All scripts attached to this "name" (like 'SIGNAL.ATTACKED.ALL') are printed to a logfile.
The global variable "SIGNAL.ATTACKED.DEBUG" can be null (=off) or integer.
This is the number of the logfile that the library will print to.

All relevant actions can be logged so if you "lose" a tertiary signal, it will show in the logs as being executed.


All rules for normal signals apply.
If your custom signal script has a duration (any kind of wait...) then all further signals to this ship are blocked.
Avoid this unless you are absolutely sure that this is what you want to achieve.
Last edited by Gazz on Fri, 16. Oct 09, 13:18, edited 11 times in total.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Sun, 31. May 09, 17:49

Currently 4 events are supported:

!ship.signal.attacked
!ship.signal.attacked.ts
!ship.signal.attacked.bigship
!ship.signal.attacked.khaakth

Two lines (001-002) have to be added to the corresponding Egosoft scripts.



Looks like this:

Code: Select all

Script !ship.signal.attacked


001   $Script.Name = get script name
002 @ = [THIS] -> call script 'lib.gz.tertiary.signal.handler' :  attacker / call script name=$attacker  action=$action  !ship.signal script name=$Script.Name
003   
004   * try a defensive move
005   if [THIS] -> is in active sector
006   |$littleship = [THIS] -> is of class Little Ship
007   |do if [THIS] -> is of class M6
*snip*
Last edited by Gazz on Tue, 2. Jun 09, 19:37, edited 2 times in total.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Sun, 31. May 09, 17:49

** reserved **
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

User avatar
LV
Sith Lord
Posts: 6358
Joined: Wed, 6. Nov 02, 21:31
x3tc

Post by LV » Mon, 1. Jun 09, 10:15

spooky i worked this out myself as well yesterday testing S.Sigs on medusa but it wasn't 100% that they were forked (99.9)




i'll take a look at this later
LV's TC Scripts
Readme's For All My Scripts


I felt a great disturbance in the forum, Like millions of voices cried out in terror, then were silenced

si tacuisses, philosophus mansisses

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Mon, 1. Jun 09, 10:26

If "the proper way" doesn't work out (and I have tried for several days, all in all) you can still use this one.
Worst case you have to hack a few more stock !signal scripts but once they are updated, everyone can access them.

That was the main problem in Reunion. Once someone messed with the !signal script, noone else could.
I could have written this for Reunion if I had needed it back then. Without all the debug code it's what... 50 lines for the whole thing?


Alas, there is no object class and race filter, like with real secondary signals.
While I could have done that, too, I opted to keep it simple and solid instead.
Put the filtering at the start of the called signal script and call it good.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

Logain Abler
Posts: 2254
Joined: Mon, 31. Oct 05, 09:44
x4

Re: [LIB] Tertiary Signals

Post by Logain Abler » Tue, 2. Jun 09, 12:37

Gazz wrote:Secondary SIGNALS do not work.
Hi All,

I’m using the Killed & Change Sector signals in my SSDN.

The Killed is used to keep track of kills & loses and the Change Sector is used as part of enemy tracking.

Everything looks to work fine :!: is this just relating to the Attacked signal or should I be worried:?:

Cheers.

LA

As always great work Gazz

Xenon_Slayer
EGOSOFT
EGOSOFT
Posts: 11158
Joined: Sat, 9. Nov 02, 12:45
x4

Post by Xenon_Slayer » Tue, 2. Jun 09, 12:53

Can someone post an example of what is not working properly please.
Forum server status: Smooth: <3% on fire
Skype 8 status: Still sucks

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 20585
Joined: Mon, 15. Nov 04, 00:26
x4

Post by Cycrow » Tue, 2. Jun 09, 13:32

secondary signals work fine, its just a problem with SIGNAL_ATTACK

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Tue, 2. Jun 09, 16:44

Xenon_Slayer wrote:Can someone post an example of what is not working properly please.

Code: Select all

$Ship -> add secondary signal: signal=SIGNAL_ATTACKED, script='test.1', prio=0, name='sig.attack.1'

global secondary signal map: add signal=SIGNAL_ATTACKED race=null class=Ship script='test.1' prio=0 name='sig.attack.2'
Both of these show the same behaviour with SIGNAL_ATTACKED.

The primary SIGNAL_ATTACKED always fires when it's supposed to.
The secondary should fire right before but instead it fires rarely while the primary works.

On (object class) freighters it fires often, on fighters sometimes, on big ship never (never saw it happen).


This whole issue is practically irrelevant for vanilla games.
Only a few corporation freighters are using a personal secondary SIGNAL_ATTACKED but since it (for some reason) works okay for freighters, there is no discernible "bug".


So as a workaround, this library allows me to add/remove script calls into the primary signal scripts without hacking the !signal scripts (again).
It's not pretty but it works beautifully. =)

Come to think of it, the "name" argument of the library should not be some arbitrary string. It should just be the script name of the !signal script.
(Why didn't anyone tell me that this was a stupid idea!? =)
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

Logain Abler
Posts: 2254
Joined: Mon, 31. Oct 05, 09:44
x4

Post by Logain Abler » Tue, 2. Jun 09, 18:46

Cycrow wrote:secondary signals work fine, its just a problem with SIGNAL_ATTACK
Cool, I can now relax a little, cheers for clearing that up :)

LA

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Tue, 2. Jun 09, 19:39

v3 released.

Cleaned up debug functions.

"name" is now the name of the !ship.signal script the user signal is attached to.
This way is far easier to keep track of.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

7ate9tin11s
Posts: 810
Joined: Sat, 12. Nov 05, 00:18
x4

Post by 7ate9tin11s » Wed, 12. Aug 09, 04:21

<necromancy> :skull: :arrow: :goner: :arrow: 8) </necromancy>

My apologies for raising the dead, but I had a thought/idea that seems to fit in with this script over writing my own signal handler. I have found the need for a SIGNAL_SPAWNED hook which would be basically the type of hook as this, but on the !job files (and include a local variable flag so it is only ever called once). So I was wondering if you would like to add it to this, or prefer me to write and release it on my own?

Either way is fine by me :D

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Wed, 12. Aug 09, 08:11

Does a SIGNAL_SPAWNED exist? I can't remember seeing it before.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

7ate9tin11s
Posts: 810
Joined: Sat, 12. Nov 05, 00:18
x4

Post by 7ate9tin11s » Wed, 12. Aug 09, 08:25

No it does not for some reason. So I guess it would be a new pseudo signal to be more accurate.

User avatar
Gazz
Posts: 12430
Joined: Fri, 13. Jan 06, 17:39
x3tc

Post by Gazz » Wed, 12. Aug 09, 09:30

But that still requires hooking it into... what?

"Tertiary signals" are simply branched off the main signals specifically because secondary SIGNAL_ATTACKED does not work.

SIGNAL_CHANGESECTOR doesn't "work", either.
Well, technically it does but only 30-90 sec after a ship has changed sector. (except for the playership)
That's not particularly useful for doing anything about jumpgate crashes for instance.
My complete script download page. . . . . . I AM THE LAW!
There is no sense crying over every mistake. You just keep on trying till you run out of cake.

Post Reply

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