people.count and people.free seem to be wrong

The place to discuss scripting and game modifications for X4: Foundations.

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

user1679
Posts: 1088
Joined: Fri, 20. Jul 18, 23:20

people.count and people.free seem to be wrong

Post by user1679 »

When trying to get information on the amount of free crew slots, the different properties available seem to be different than what Ship Information (crew capacity) says.

According to scriptproperties.xml:
<property name="people.count" result="Number of people on board the object as NPC templates (not actual NPCs)" type="integer"/>
<property name="people.free" result="Amount of free space on board the object for additional people as NPC templates" type="integer"/>
<property name="people.capacity" result="Maximum amount of potential space on board the object for people as NPC templates" type="integer"/>

But when I use an Elite Sentinel, according to ship information my crew (on an empty ship with me piloting) is 0 / 2, indicating I can hire two people. However when I use those properties in my script, they return:

Ship Information (capacity) = 0 / 2
count = 0
free = 1 <----- this should be 2
capacity = 1 <----- this shuld be 2

I don't quite understand what as NPC templates (not actual NPCs) means because after I hire one crew member, my results are:

Ship Information (capacity) = 1 / 2
count = 1
free = 0 <----- this shuld be 1
capacity = 1 <----- this shuld be 2

Now interestingly if I promote that crewmember to a pilot:

Ship Information (capacity) = 1 / 2
count = 1
free = 1
capacity = 1 <----- this shuld be 2
kuertee
EGOSOFT
EGOSOFT
Posts: 818
Joined: Sun, 14. Dec 03, 13:05
x4

Re: people.count and people.free seem to be wrong

Post by kuertee »

npc templates are npcs that have not been created in the 3d world, i think.

e.g. when you converse with a crew member that has never existed in the real world (e.g. never taken control of the ship, never walked a station, etc.) ...
that is not in the 3d world,
the object parameter of event_conversation_started returns as a list of their (1) container then (2) their template.

Code: Select all

<debug_text text="'$npc: ' + @$npc + ' (' + typeof $npc + ')'"
results in:

Code: Select all

[Scripts] 635200.79 *** Context:md.kuertee_npc_reactions.OnConversationStarted: $npc: [component.{0x1a50fL},npctemplate<0x58b370b2>] (list)
when you converse with an npc in the 3d world, the object parameter of event_conversation_started returns as an object

Code: Select all

[Scripts] 635222.87 *** Context:md.kuertee_npc_reactions.OnConversationStarted: $npc: 0x282f5cd (component)
so, the people.free and people.capacity are the counts of npc templates - because the pilot needs to be a created actor.

EDIT: I demoted a pilot, and once he disappeared behind the transporter room, conversing with him via the crew list, resulted in him returning as an npc template rather than as a component.
user1679
Posts: 1088
Joined: Fri, 20. Jul 18, 23:20

Re: people.count and people.free seem to be wrong

Post by user1679 »

kuertee wrote: Thu, 11. Mar 21, 07:34 npc templates are npcs that have not been created in the 3d world, i think.

e.g. when you converse with a crew member that has never existed in the real world (e.g. never taken control of the ship, never walked a station, etc.) ...
that is not in the 3d world,
the object parameter of event_conversation_started returns as a list of their (1) container then (2) their template.

Code: Select all

<debug_text text="'$npc: ' + @$npc + ' (' + typeof $npc + ')'"
results in:

Code: Select all

[Scripts] 635200.79 *** Context:md.kuertee_npc_reactions.OnConversationStarted: $npc: [component.{0x1a50fL},npctemplate<0x58b370b2>] (list)
when you converse with an npc in the 3d world, the object parameter of event_conversation_started returns as an object

Code: Select all

[Scripts] 635222.87 *** Context:md.kuertee_npc_reactions.OnConversationStarted: $npc: 0x282f5cd (component)
so, the people.free and people.capacity are the counts of npc templates - because the pilot needs to be a created actor.

EDIT: I demoted a pilot, and once he disappeared behind the transporter room, conversing with him via the crew list, resulted in him returning as an npc template rather than as a component.

So I've been working on Recruitment Service Extended, an expanded version of the Recruitment Service mod by LitauenLitauen and the problem I'm running into is when you first hire an NPC, it shows available slots of 1 (even though the ship actually has 2) because people.free reports 1.

This causes an issue where the player can't hire 1 crew and then hire immediately another without first entering the map and promoting the first one to pilot. What I want is an accurate count of available crew slots but I can't seem to get one unless I add 1 to the result of people.free, but I don't know if that is consistent across all ships.

EG:

With an Elite Sentinel, crew capacity of 0 / 2

Hire 1 crew
Hire 1 crew <---- error, not enough room even though capacity is 1 / 2
Open map
Promote first crew to pilot
Close map
Hire 1 crew <---- works
j.harshaw
EGOSOFT
EGOSOFT
Posts: 2189
Joined: Mon, 23. Nov 15, 18:02

Re: people.count and people.free seem to be wrong

Post by j.harshaw »

The pilot of a ship is referred to in scripts as an entity.
The various other crew members on the ship are people.

$controllable.people.* in scripts refers to just people (service personnel, marines; passengers or prisoners if you have any).
Crew capacity on the menu refers to people plus the pilot.
user1679
Posts: 1088
Joined: Fri, 20. Jul 18, 23:20

Re: people.count and people.free seem to be wrong

Post by user1679 »

j.harshaw wrote: Wed, 17. Mar 21, 00:50 The pilot of a ship is referred to in scripts as an entity.
The various other crew members on the ship are people.

$controllable.people.* in scripts refers to just people (service personnel, marines; passengers or prisoners if you have any).
Crew capacity on the menu refers to people plus the pilot.
Interesting, but wouldn't that mean on an Elite Sentinel (capacity 0/2) should actually say (capacity 1/2) because the player is the pilot? I always took that number to mean "you can hire two more people for this ship" because when I hire someone it changes to (1/2) on ship info. And if it does mean that then it isn't clear how to get the actual number in a script if the people.* properties don't represent that.
kuertee
EGOSOFT
EGOSOFT
Posts: 818
Joined: Sun, 14. Dec 03, 13:05
x4

Re: people.count and people.free seem to be wrong

Post by kuertee »

so to get the correct count, you just:
1. ignore the player
2. check if the ship already has an assigned pilot with $ship.assignedaipilot
3. if there's no ai pilot, add one more to required personnel (i.e. people.free + 1).
3a. but make sure that you first promote a captain via script before adding that last hire to the ship.
4. if there's an ai pilot, the required personnel is just people.free.
user1679
Posts: 1088
Joined: Fri, 20. Jul 18, 23:20

Re: people.count and people.free seem to be wrong

Post by user1679 »

kuertee wrote: Wed, 17. Mar 21, 04:30 so to get the correct count, you just:
1. ignore the player
2. check if the ship already has an assigned pilot with $ship.assignedaipilot
3. if there's no ai pilot, add one more to required personnel (i.e. people.free + 1).
3a. but make sure that you first promote a captain via script before adding that last hire to the ship.
4. if there's an ai pilot, the required personnel is just people.free.
Thanks so much, that's very helpful.

Unfortunately even if I assume there's only 1 slot left on an empty ship, I found that adding crew using <create_npc_template> and then hiring an NPC the usual way (by talking to them), it causes the ship info to bug out and crash (refuse to open) thereby breaking your ship.

I posted the crash report in a different thread because even though all my questions are related to the same project, they're technically different topics.

Having a hard time adding an NPC to my ship - breaking the map

Return to “X4: Foundations - Scripts and Modding”