Page 1 of 1

Problem with roles

Posted: Sun Nov 06, 2011 8:31 am
by Ironfist
Guys,

Having problems with roles. A bit of background trying to script some actions for a ship building station and would like to recognise player ships that correspond to the ship types that are built at the station, so that differing actions can be provided. Whilst I can do this by using constructs like "if (player.ship.name === "xxx" !! player.ship.name === "yyy") I thought it would be easier on maintenance if I could assign a special role and use " if (player.ship.hasrole("rrr") ". However when I try this it fails, It would appear that the only role a player ship has is 'player', is this correct? NPC ships have the full list of roles when I list them in the console, but the player only ever shows 1 role, 'player'. The Wiki does not say anything about this restriction for the player ship, well in those pages I have read anyway.

Ironfist

Re: Problem with roles

Posted: Tue Nov 29, 2011 1:20 pm
by Kaks
Unfortunately it's done on purpose. The reason behind it is that NPCs tend to develop erratic behaviours if we add secondary roles to the player (specifically police & thargoid, but maybe pirate as well).


However, there is one thing you could do. Each player ship can be assigned a unique script in shipdata.plist, so you can create a ship.script containing at least the following

Code: Select all

this.name = 'testing';
this.author = 'Ironfist';
   ....
this.ironfistBuildStation = 'YAY';
you can then always check for

Code: Select all

if(player.ship.script.ironfistBuildStation == 'YAY'){
     ...
}
'Course, since it's not a standard property, it's always best to give it a fairly unique name, so no other oxps are likely to use the same property by accident...

Re: Problem with roles

Posted: Tue Nov 29, 2011 3:48 pm
by Ironfist
Kaks,

Thanks for the suggestion I will give it a go and see whether if it offers any advantages over what I am currently doing, which is to have a piece of equipment called "Manufacturers Tag" which is standard equipment for ships produced by Oodulldoff Inc. Testing this allows the station scripts to react differently for differing ships and currently does not require writing a ship script for each type of ship. But your option may be better since I assume the equipment approach could fail if it was destroyed in combat.

Ironfist