Need help optimizing a get attacker check.

The place to discuss scripting and game modifications for X²: The Threat.

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

markmid
Posts: 149
Joined: Tue, 10. Feb 04, 21:03
x2

Need help optimizing a get attacker check.

Post by markmid »

I know there's a way to get an enemy of a particular station or object if its attacked, what i'm looking to do is optimize how I check this.

Can anyone think of a better way than I have here to get an enemy of a particular race if any of its stations or ships are attacked? What I'm trying to do is modify the standing of a race (or the player) if someone attacks or destroy's something of a particular race (race 4).

My idea currently is a loop containing an array of stations / ships max shield values. Putting all the value's into a temporary variable and checking it. If one value in the array is less than the max shield value call a get attacker statement and modify the races relations accordingly.

This will tie up some unnecessary processor time if its continually running every minute, so can anyone think of a better way?

Thx in advance :)
User avatar
Kailric
Posts: 985
Joined: Sun, 7. Dec 03, 05:15
x3

Post by Kailric »

I know what you are going to have to do. Your wanting to see if a ship in a paticular races is under attack, and who his attacker is correct?


Well sence there is not ->get attacker command you have to do it the long way around.

-First you have to unpack these two scripts !ship.signal.attacked and !ship.signal.attacked.ts
-then you have to edit these in notepad and remove the ! from the start of their name, in this file there will be two places you do this, at the start then at the codearray part, then save....but don't "save as"
-then you have to rename them with out the ! by just right clicking on there name if you have windows
-now put these two files in your /scripts folder
-if you have done this correct your game will load, if not it will freeze...but nothing will be hurt you just have to remove those two files from the /scripts folder
-once you do it right..create you a new script in editor and make it like so:

Code: Select all

042 $race=null
043 global ship map: remove: key=SIGNAL_ATTACKED, class=Ship, race=$race
044   global ship map: set: key=SIGNAL_ATTACKED, class=Ship, race=$race, script='ship.signal.attacked', prio=100
045   global ship map: remove: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Argon
046   global ship map: set: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Argon, script='ship.signal.attacked.ts', prio=100
047   global ship map: remove: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Boron
048   global ship map: set: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Boron, script='ship.signal.attacked.ts', prio=100
049   global ship map: remove: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Split
050   global ship map: set: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Split, script='ship.signal.attacked.ts', prio=100
051   global ship map: remove: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Paranid
052   global ship map: set: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Paranid, script='ship.signal.attacked.ts', prio=100
053   global ship map: remove: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Teladi
054   global ship map: set: key=SIGNAL_ATTACKED, class=Small Transport TS, race=Teladi, script='ship.signal.attacked.ts', prio=100
055   
056   global ship map: remove: key=SIGNAL_KILLED, class=Ship, race=$race
057   global ship map: set: key=SIGNAL_KILLED, class=Ship, race=$race, script='ship.signal.killed', prio=10000
-name this to what ever you want but start it with init. when your ready for this to be loaded into the game wen you reload or reinit scripts

Now what you have is the ability to edit the signal attack scripts...these scripts will run every single time a ship is attacked. And what does that mean? That means you have power. And with this power you can get the attacker of anyship for in those scripts there is a varable named $attacker...it is him who you seek.

You can use this script to call another script that will do all the checking for you..just use Start at the beging of the script call.

Anything else just holla :)
"Try not. Do or do not, there is no try."-Yoda

"[Its] time for the human race to enter the solar system"-Dan Quayle
markmid
Posts: 149
Joined: Tue, 10. Feb 04, 21:03
x2

Post by markmid »

Quite simply you rule :D


I take it:
'SIGNAL_ATTACKED, class=Small Transport TS', needs to be done for each class and race i want checked.

Aside from my current project, you could have relations for 'all' races update on a dynamic game driven system like this. Thats something for somebody in the future.

Thanks a bunch, i have learned a great deal over the last few days.
User avatar
Kailric
Posts: 985
Joined: Sun, 7. Dec 03, 05:15
x3

Post by Kailric »

Just be sure to set the priority to at least 100 or more on all scripts that "interput", the signal attack works for all races automaticly but the signal attack only works for the "good" races, but I haven't figured everthing out yet. Any questions just holla, if I don't know maybe somebody will.
"Try not. Do or do not, there is no try."-Yoda

"[Its] time for the human race to enter the solar system"-Dan Quayle

Return to “X²: The Threat - Scripts and Modding”