death_actions and 1.71.2

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

User avatar
Ramirez
---- E L I T E ----
---- E L I T E ----
Posts: 628
Joined: Mon Nov 07, 2005 9:52 am
Location: London, UK

death_actions and 1.71.2

Post by Ramirez »

I'm trying to do some OXP updates and wondered whether the death_actions shipdata function is no longer working in 1.71.2? I can't find any mention anywhere that this has been removed in favour of javascript methods. Half of the weapons in Missiles and Bombs don't work anymore so I'd like to know if I need to re-engineer the solutions or whether I'm just missing something obvious.
Download Resistance Commander plus many other exciting OXPs HERE
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: death_actions and 1.71.2

Post by Eric Walch »

Ramirez wrote:
I'm trying to do some OXP updates and wondered whether the death_actions shipdata function is no longer working in 1.71.2? I can't find any mention anywhere that this has been removed in favour of javascript methods. Half of the weapons in Missiles and Bombs don't work anymore so I'd like to know if I need to re-engineer the solutions or whether I'm just missing something obvious.
They definitely work in 1.71.2. I use one in buoyRepair.oxp and it is working very well. There must be something else not working.
User avatar
Ramirez
---- E L I T E ----
---- E L I T E ----
Posts: 628
Joined: Mon Nov 07, 2005 9:52 am
Location: London, UK

Post by Ramirez »

This is the death_action used in the chaff launcher; similar methods are used for various other equipment:

Code: Select all

<key>death_actions</key>
<array>
<string>decrement: mission_chaff_count</string>
<string>spawn: chaff 20</string>
<string>set: mission_chaff_loaded NO</string>
</array>
Is the spawn function still supported or has that been replaced by something else?
Download Resistance Commander plus many other exciting OXPs HERE
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Ramirez wrote:
This is the death_action used in the chaff launcher; similar methods are used for various other equipment:
I also noticed that the variables do not change. It looks like the whole death_actions are indeed not executed. They still do when you kill a ship, but your ships destroy themselves with an AI command, maybe that changed. Change the AI in a way it does not destroys itself end kill it with your lasers. Than you know for sure.

Looking at it I noticed two bugs (with no consequences) in version 0.50
1) Look at the pause in the AI of the launcher. It has a typo.
2) in the script you write "set: mission_chaff_loaded equal YES". You must drop the "equal" in there. Now the contents of the variable becomes "equal YES". It has no consequences as you only check for the NO condition and that one is set well.
User avatar
Ramirez
---- E L I T E ----
---- E L I T E ----
Posts: 628
Joined: Mon Nov 07, 2005 9:52 am
Location: London, UK

Post by Ramirez »

That seems to be it - I added the same death actions to a ship and shot it down, and the spawning etc worked as normal. So it seems that if a ship is destroyed by an AI function rather than a laser hit or collision, it won't trigger the death action.

It looks like I can fix this by putting all the spawning and mission variable stuff within the AI itself, selecting a reliable target (probably the player) and using either safeScriptActionOnTarget to implement the necessary functions, or possibly doing a sendScriptMessage and going down the javascript route. On reflection, putting everything in the AI is probably more intuitive than relying on death actions, it's just that I happened upon that particular solution and stuck with it. One advantage of this is that the weapons in Missiles and Bombs will detonate when when they're supposed to, rather than when someone happens to run into them. I'll pretend that I've merely upgraded them to include Permissive Action Links!

Thanks for pointer on the typos.
Download Resistance Commander plus many other exciting OXPs HERE
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

When you feel save to do so, choose the way with a "sendScriptMessage:". It will probably add new possibilities to your (future) weapons. And it gives easier solutions to correct strange things.

Last week I replaced the death_actions of the GRS buoy by a JS-script because I wanted to do more with the script. The buoy did its death_actions as entity but also when towed as subentity. I just tested it with a script. Even the JS script got its shipDied events when it is a subentity. But I had one launch command that only could be done by the AI script. And a subentity has no working AI script (never has had).
So I thought: let the death script of the towing ship handle that part. Send a message to its own AI on death. It didn't work. I traced it down to the pilot I gave the ship. (Not something you start thinking of). When a ship has a pilot that bails ship, the ship becomes a hulk and the AI automatically switches to nullAI.plist. (By itself logical with no controlling pilot). So my script messages to the AI never reached the intended custom AI on death. #$$#@ But problem is solved by now. JS let you easy switch back the AI to what it was.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Wouldn't it be best to do it in a ship-script of the missile?
User avatar
nijineko
---- E L I T E ----
---- E L I T E ----
Posts: 353
Joined: Wed Jul 04, 2007 3:37 pm
Location: two strange quarks short of a graviton....
Contact:

Post by nijineko »

this sounds like you could make some impressive effects using... oh, say, small ships as kamikaze, quite appropriate for feudal systems.... perhaps have special charges linked to cascade bombs that causes them to detonate when within a certain proximity to any ship listed as an enemy. no lasers, no missles, just lots of legs. superfast single pilot kamikaze police. that'll put the fear of feudal law into offenders and fugitives.... ;D i could even come up with japanese translations for any messages given. perhaps some drawing or even modelling for anyone who'd be willing to script it.
arukibito ga michi wo erabu no ka, michi ga arukibito wo erabu no deshou ka?

Image
Play games. Win Amazon gift cards! Brag. Repeat.
User avatar
Ramirez
---- E L I T E ----
---- E L I T E ----
Posts: 628
Joined: Mon Nov 07, 2005 9:52 am
Location: London, UK

Post by Ramirez »

Sounds like an interesting idea, nijineko. No-one's done anything with the Feudal systems as yet and having a distinct enemy with a special attack would be fun. Maybe have a set of fairly similar ships, nothing too fancy, but give each of them appropriate faction markings. Making use of some Japanese text in the textures would look pretty cool.

I've fixed the issues with Missiles and Bombs and have uploaded v1.0 onto my site. I've also done a quick update to Dictators to fix the station behaviour problem as well as tidying up some of the models and textures. I'll aim to do a larger update soon, when I hope to finally add the AstroFarms that I had always planned for the OXP.
Download Resistance Commander plus many other exciting OXPs HERE
User avatar
Ramirez
---- E L I T E ----
---- E L I T E ----
Posts: 628
Joined: Mon Nov 07, 2005 9:52 am
Location: London, UK

Post by Ramirez »

I've now replaced most of the non-functioning death actions with AI commands, but there's one more bit where I think I'll need to use a JS ship script. I've read through some of the ones used in Random Hits and UPS and while I understand what they trying to do, it's not obvious to me how you come up with all the various functions from scratch.

The bit I need to get working involves the Disruptor missile in the Trident Down OXP. This missile forces a target to perform a hyperspace exit, and I want this to set a mission variable. However, I only want the mission variable to be set when the correct ship is targeted; if the missile is fired at another ship, I want the hyperspace exit to occur but the mission variable to remain as it is.

At the moment I've done this rather crudely by giving the missile a script in its death action that checks for the presence of the target ship (delaney-ship) at the point at which it is detonated (it also checks that the mission status and planet number are as expected). Can I do something similar in the ship script or is there a more appropriate way to get the result I need?
Download Resistance Commander plus many other exciting OXPs HERE
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

I think you need something like this.

Code: Select all

this.shipSpawned = function()
{
   this.target = this.ship.target.ID
}


this.shipDied = function()
{
  if(this.target == this.ship.target.ID)
  }
    missionVariable.My_Variable1 = "YES"
  }
  else 
  {
    missionVariable.My_Variable1 = "NO"
  }
}
On creation of the missile it stores the target and on destruction it checks if the target has still the same ID

But maybe it is saver when you use:

Code: Select all

this.shipSpawned = function()
{
   this.target = this.ship.target.ID
}


this.checkTarget = function()
{
  if(this.target == this.ship.target.ID)
  }
    missionVariable.My_Variable1 = "YES"
  }
  else 
  {
    missionVariable.My_Variable1 = "NO"
  }
}
And use "sendScriptMassage: checkTarget" in your AI just before you send the target away. In the "checkTarget" you can also give the target fuel so it will be able to jump. (Unless it is masslocked)

You can also let the JS send a "reactToMessage()" back to the AI. The next UPS release will have several examples of this. The latest buoyRepair also has similar examples. look e.g. at the buoy scripts (AI + JS) in there.
User avatar
Ramirez
---- E L I T E ----
---- E L I T E ----
Posts: 628
Joined: Mon Nov 07, 2005 9:52 am
Location: London, UK

Post by Ramirez »

It looks like the second option would be better as this would ensure the mission variable is not set if the missile happens to be destroyed by other means. However this is just checking that at the point of detonation, the missile's target is the same as the one it had when it launched. Can I insert a check to see that that this.ship.target.ID = delaney-ship? I'm not sure what the syntax is to do this.
Download Resistance Commander plus many other exciting OXPs HERE
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Ramirez wrote:
Can I insert a check to see that that this.ship.target.ID = delaney-ship? I'm not sure what the syntax is to do this.
When you want to test for a special ship it's probably easier to check for the name.
if(this.ship.target.shipDescription == "shipname") or if(this.ship.target.shipDisplayName == "shipname")

"shipDescription" is the ships name as defined in shipdata and "shipDisplayName" is a copy of that name that you see when in game. This double name was added for localised versions. It adds the possibility to have several display names for the ship while you still have one underlying unique name. Therefor the first check is better.

And when you read this sentence you probably already have thought "@#@ of cause, why didn't I think at this".
User avatar
Ramirez
---- E L I T E ----
---- E L I T E ----
Posts: 628
Joined: Mon Nov 07, 2005 9:52 am
Location: London, UK

Post by Ramirez »

I've given it a go but I'm not sure it's working properly. I tried the following as a test:

Code: Select all

this.checkTarget = function() 
{ 
  if(this.ship.target.shipDescription == "Timon Delaney");
	
{
    missionVariables.mission_trident_down = "DELANEYMISJUMP";
    player.commsMessage("setting variables!", 5);
}
}
but the message comes up whatever the target. Maybe I need to put in an 'else' clause, but I thought this wasn't essential? When I do try to put one in, no matter how I order the brackets I keep getting syntax errors. This doesn't seem to work:

Code: Select all

this.checkTarget = function() 
{ 
  if(this.ship.target.shipDescription == "Timon Delaney");
	
}
    missionVariables.mission_trident_down = "DELANEYMISJUMP";
    player.commsMessage("setting variables!", 5);
}
else
{
player.commsMessage("do nothing", 5);
}
}
Download Resistance Commander plus many other exciting OXPs HERE
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post by Eric Walch »

Ramirez wrote:
I've given it a go but I'm not sure it's working properly. I tried the following as a test:

Code: Select all

 if(this.ship.target.shipDescription == "Timon Delaney");
I don't see a bug but I am not a JS expert. My guess would be that you must remove the semicolon ;. It ends a statement, but the part after the semicolon is still part of the if statement. Now it is probably sees it as a new piece of code.
The other 2 semicolons are placed right.
Post Reply