SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > Silent Hunter 3 - 4 - 5 > SH5 Mods Workshop
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 03-06-10, 09:17 PM   #1
Heretic
Commodore
 
Join Date: Mar 2005
Location: Nebraska
Posts: 617
Downloads: 240
Uploads: 2


Default [TEC] Crew Scripting

The crewmen are referenced by the waypoint they are initially assigned to. Waypoints are prefixed by the compartment.
CR - Control Room
CT - Conning Tower
DER - Diesel Engine Room
QRF - Forward Quarters
RR - Radio Room, part of QRF
SQ - Stern Quarters
TRA - Aft Torpedo Room
TRF - Forward Torpedo Room
WP - Weapon?
WT - Watch Tower

The waypoints for the Control Room are:
CR_CHIEF - Chief starts here so he is CR_CHIEF
CR_CHIEF_MAP
CR_HA - Aft Hydroplane operator
CR_HELM - Helmsman
CR_HF - Fore Hydroplane
CR_LADDER - halfway up the ladder
CR_NAV - Navigator
CR_SO_01 - Second officer
CR_SO_MAP01
CR_SO_MAP01
CR_SO_PER
CR_STAIRS - foot of the ladder
CR_VALVE - Ballast tank operator
etc...

These are the Crewmen we currently have to work with:
CR_CHIEF - Chief Engineer
CR_HA - Aft Hydroplane Operator
CR_HELM - Helmsman
CR_HF - Fore Hydroplane Operator
CR_NAV - Navigator
CR_SO_01 - Second Officer
CR_VALVE - Ballast Tank Operator
DER_DE_CPO - Engine Room Chief
DER_DE_PORT01 - Port Diesel Operator
DER_DE_STB01_A - Starboard Diesel Operator
QRF_Petty_01 - Petty Officer 01
QRF_Petty_02 - Petty Officer 02
QRF_WATCH - Watch Officer
RR_HIDRO - Hydrophone Operator
RR_RADIO_A - Radio Operator
SQ_BED01 - Crewman in Bunk 01
SQ_BED02 - Crewman in Bunk 02
SQ_BED03 - Crewman in Bunk 03
SQ_BED04 - Crewman in Bunk 04
SQ_BOSUN_A - Bosun
SQ_COOK_A - Cook
TRA_EE_PORT01_A - Port Motor Operator 01
TRA_EE_PORT02 - Pot Motor Operator 02
TRA_EE_STB02 - Starboard Motor Operator
TRA_LOAD01 - Aft Torpedo Crewman
TRF_LOAD01 - Forward Torpedo Crewman 01
TRF_LOAD03 - Forward Torpedo Crewman 02
TRF_LOAD05 - Forward Torpedo Crewman 03

The animations are designed to work from specific waypoints. They are prefixed with that compartment and waypoint. So "CR_CHIEF_Idle01" is set up to work on a character in waypoint CR_CHIEF. It doesn't have to be the Chief and is doesn't have to be used only in that waypoint. Things might not line up, you may get clipping, etc, if you use it somewhere else. The animations are in data\Characters\Animations.

Last edited by Heretic; 03-09-10 at 02:44 PM.
Heretic is offline   Reply With Quote
Old 03-06-10, 09:23 PM   #2
Heretic
Commodore
 
Join Date: Mar 2005
Location: Nebraska
Posts: 617
Downloads: 240
Uploads: 2


Default

Scripting commands
The script files are text files with an aix suffix in data\scripts\AI\crew. they can be edited using any text editor. You define 'strategies' that the crewmen will perform when the circumstances you define for them are met. So, you can have different behaviors when surfaced or submerged, etc. I've mostly dealt with the idle strategies, so that's what I'll describe. You can also set up strategies for use with commands.

Here are the functions I've identified

Wp:GetCurrentlyLoadingTube()
Wp:GetGlobalVariable(variable)
Wp:IsBunkerState()
Wp:IsCharacterPosture(val) A,B,C,D,E (don't know what the postures are)
Wp:IsConningTower("tower")
Wp:IsCrewState(val) DMG_TKN, HUNTER, HUNTED, PROX_EXPL, T_FIRED, T_TRAVEL, T_HIT, T_MISS, SIL_RUN, B_STATIONS - B_STATIONS doesn't appear to work
Wp:IsCurrentWaypoint("waypoint")
Wp:IsGunManned(slot)
Wp:IsSubmerged()
Wp:IsSurfaced()
Wp:IsTorpedoLoadingInProgress()
Wp:IsTutorial()

Wp:BindAvatarCameraToObject("object", var)
Wp:DeactivateCrewState(val)
Wp:DoNothing()
Wp:ExecuteCommand
Wp:GetDistanceToAvatar()
Wp:GetGunType(slot)
Wp:GetHydrophoneState()
Wp:GetRadarState()
Wp:Goto("waypoint")
Wp:LoadTorpedo("animation", val)
Wp:ManTheGun(slot, "text", role) - ROLE_GUNNER, ROLE_TRAV, ROLE_ELEV
Wp:PlayAnimation("animation")
Wp:PlayAnimationAndWait("animation")
Wp:PlayAttenuatedSoundWithLipsync("file", delay);
Wp:PlaySoundWithLipsync("file", delay);
Wp:ScriptCompleted();
Wp:SetBodyPartVisibility(part, 0/1) VERY nice. Can change and add parts
Wp:SetGlobalVariable(variable, value)
Wp:SetNonInteractive()
Wp:Teleport("waypoint")
Wp:UnbindAvatarCamera(1)
Wp:UnmanTheGun(slot, role)

Last edited by Heretic; 03-22-10 at 02:00 PM.
Heretic is offline   Reply With Quote
Old 03-06-10, 09:24 PM   #3
Heretic
Commodore
 
Join Date: Mar 2005
Location: Nebraska
Posts: 617
Downloads: 240
Uploads: 2


Default

So here's an example using the Chief. His idles entry are defined in the submarine files

Quote:
strategy CR_CHIEF_IDLE01(wp)
{
strategies Define the strategies
{
CR_CHIEF_TUTORIAL,
CR_CHIEF_NORMAL,
CR_CHIEF_DAMAGE_TAKEN,
CR_CHIEF_PROXIMITY_EXPLOSIONS,
CR_CHIEF_HUNT
}
}
Now here's his NORMAL strategy. The precond statement tells under what conditions this strategy will be used. This one is when the CrewState is not ("!" means not) DMG_TKN, PROX_EXPL, HUNTER, or HUNTED and it's not both the Tutorial and not in the bunker

Quote:
strategy CR_CHIEF_NORMAL(wp)
{
precond
{
!Wp:IsCrewState(DMG_TKN|PROX_EXPL|HUNTER|HUNTED) and !(Wp:IsTutorial() and !Wp:IsBunkerState())
}
action
{

if Wp:IsCurrentWaypoint( "CR_CHIEF" ) then
{
Wp:PlayAnimationAndWait( "CR_CHIEF_Idle01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Talk2HA_01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Idle02" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Talk2HELM_01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Idle01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Talk_VALVE01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Idle01" );
Wp:Goto("CR_CHIEF_MAP");
}
endif;
if Wp:IsCurrentWaypoint( "CR_CHIEF_MAP" ) then
{
Wp:PlayAnimationAndWait( "CR_CHIEF_MAP_Idle01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_MAP_Idle02" );
Wp:PlayAnimationAndWait( "CR_CHIEF_MAP_Idle03" );
Wp:Goto("CR_CHIEF");
}
endif;

Wp:ScriptCompleted(); <---- IMPORTANT
}
}
So if he's currently at waypoint "CR_CHIEF", he'll perform a series of animations, then move to "CR_CHIEF_MAP". If he's at the "CR_CHIEF_MAP", he'll do a different set and move back to "CR_CHIEF". Browse through the files and it's pretty easy to figure out what's going on and the potential of this.

Last edited by Heretic; 03-22-10 at 02:02 PM.
Heretic is offline   Reply With Quote
Old 03-08-10, 11:45 AM   #4
Heretic
Commodore
 
Join Date: Mar 2005
Location: Nebraska
Posts: 617
Downloads: 240
Uploads: 2


Default

Here's some simple examples using the function Wp:SetBodyPartVisibility().
syntax is Wp:SetBodyPartVisibility("object", 1 or 0); 1 for on, 0 for off. Objects are defined in the body parts file in Characters folder.

Crewmen are made up of Head, Left Eye, Right Eye, Torso, and Pants. Optionally they can have a Hat and an Object. They start out as defined in the CHR files, be can all be changed with this function.


Add binoculars to a crewman.
Quote:
Wp:SetBodyPartVisibility("object1_Binocular", 1);
Adding a hat. Not all hats work on all heads. Some of the larger heads will show through the hat.
Quote:
Wp:SetBodyPartVisibility("A_Hat01", 1);
Changing a uniform. Important to remove the old one or both will be displayed.
Quote:
Wp:SetBodyPartVisibility("D_Torso05", 1); <-- adds Torso05
Wp:SetBodyPartVisibility("D_Torso01", 0); <-- Removes Torso01
Adding a beard.
Quote:
Wp:SetBodyPartVisibility("object1_Barba_CAP13", 1);
Changing a head. It's best to also use the proper eyes. It's not required, but they might not line up right otherwise.
Quote:
Wp:SetBodyPartVisibility("B_Head03", 0);
Wp:SetBodyPartVisibility("B_EyeL03", 0);
Wp:SetBodyPartVisibility("B_EyeR03", 0);
Wp:SetBodyPartVisibility("D_Head10", 1);
Wp:SetBodyPartVisibility("D_EyeL10", 1);
Wp:SetBodyPartVisibility("D_EyeR10", 1);
The stock scripts use this function to convert the XO into the Captain for the tutorial. Whenever you see someone with something in their hand, a book, knife, screwdriver, whatever, it's done with this function.

Last edited by Heretic; 03-08-10 at 12:02 PM.
Heretic is offline   Reply With Quote
Old 03-08-10, 11:50 AM   #5
urfisch
Sea Lord
 
Join Date: Mar 2005
Location: Deep down in Germany
Posts: 1,969
Downloads: 42
Uploads: 0
Default





definitely a sticky...

thanks a lot!!
__________________


urfisch is offline   Reply With Quote
Old 03-08-10, 12:16 PM   #6
Dowly
Lucky Jack
 
Join Date: Apr 2005
Location: Finland
Posts: 25,005
Downloads: 32
Uploads: 0


Default

Thanks a ton! Very good info!

Say, have you looked into adding more waypoints? I was thinking if it would be possible with the IsBunkerState and some new waypoints have the crew standing on the deck of the uboat when it's in the bunker.

Or even better by adding new waypoints and (if possible) new state that is triggered by the player pressing a certain button have the crew standing on deck. Would be AWESOME to slowly sail through the harbor, returning from a long patrol with the crew standing on deck.
Dowly is offline   Reply With Quote
Old 03-09-10, 01:17 AM   #7
GermanGS
Sailor man
 
Join Date: Feb 2010
Location: New Jersey
Posts: 49
Downloads: 32
Uploads: 0
Default

strategy CR_CHIEF_NORMAL(wp)
{
precond
{
!Wp:IsCrewState(DMG_TKN|PROX_EXPL|HUNTER|HUNTED) and !(Wp:IsTutorial() and !Wp:IsBunkerState())
}
action
{
Wp:SetBodyPartVisibility("D_Torso01", 0);
Wp:SetBodyPartVisibility("D_Pants01", 0);
Wp:SetBodyPartVisibility("B_Torso03", 1);
Wp:SetBodyPartVisibility("B_Pants03", 1);
Wp:SetBodyPartVisibility("D_Hat02", 1);

if Wp:IsCurrentWaypoint( "CR_CHIEF" ) then
{
Wp:PlayAnimationAndWait( "CR_CHIEF_Idle01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Talk2HA_01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Idle02" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Talk2HELM_01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Idle01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Talk_VALVE01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_Idle01" );
Wp:Goto("CR_CHIEF_MAP");
}
endif;
if Wp:IsCurrentWaypoint( "CR_CHIEF_MAP" ) then
{
Wp:PlayAnimationAndWait( "CR_CHIEF_MAP_Idle01" );
Wp:PlayAnimationAndWait( "CR_CHIEF_MAP_Idle02" );
Wp:PlayAnimationAndWait( "CR_CHIEF_MAP_Idle03" );
Wp:Goto("CR_LADDER");
}
endif;
if Wp:IsCurrentWaypoint( "CR_LADDER" );

Wp:IsCurrentWaypoint( "SAILOR01_Wait_near_ladder" );
{
Wp:Goto( "CT_ATTAK" );
}
endif;
if Wp:IsCurrentWaypoint( "CT_ATTAK" );
{
Wp:PlayAnimationAndWait( "CT_ATTAK_Idle01" );
Wp:Goto( "CT_STAIRS" );
}
endif;
if Wp:IsCurrentWaypoint( "CT_STAIRS" );
{
Wp:Goto( "CR_CHIEF" );
}
Wp:ScriptCompleted();
}
}



What Am i doing wrong here that the game CTD???

Can anyone figure out???
__________________
GermanGS is offline   Reply With Quote
Old 03-09-10, 03:42 AM   #8
Therion_Prime
Helmsman
 
Join Date: Apr 2005
Posts: 105
Downloads: 27
Uploads: 0
Default

Quote:
Originally Posted by GermanGS View Post
if Wp:IsCurrentWaypoint( "CR_LADDER" );

Wp:IsCurrentWaypoint( "SAILOR01_Wait_near_ladder" );
1) You forgot a "then"
2) Replace Wp:IsCurrentWaypint with Wp:PlayAnimationAndWait
Therion_Prime is offline   Reply With Quote
Old 03-08-10, 07:42 PM   #9
GermanGS
Sailor man
 
Join Date: Feb 2010
Location: New Jersey
Posts: 49
Downloads: 32
Uploads: 0
Default

thanx this is def were ill spend my time
__________________
GermanGS is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 11:34 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 1995- 2024 Subsim®
"Subsim" is a registered trademark, all rights reserved.