scripting Problem with linked auto turrets...Need help.

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
Big_rich

scripting Problem with linked auto turrets...Need help.

Post by Big_rich »

Ok my problem is that I want ot have linkedturrets on a ground map. Object is to destroy a power generator. The auto turrets stop. Here is what I've done so far, and haven't gotten then to work yet:

Place both power generator and turrets in ZE assigned them the following names: Imp-defense(for pwr generator), and Imp_turr_1, imp_turr_2(for turrets). Assigned both of them to team #1(imp team).

Here are the odf's I'm useing:
Building:

Code: Select all

[GameObjectClass]       

ClassLabel      =   "armedbuilding"
GeometryName    =   "uta1_bldg_tower.msh"

[Properties]        

GeometryName    	= "uta1_bldg_tower"
MaxHealth       	= "15000.0"
MapTexture 				= "hud_dest_icon"
MapScale 				= 3.0
RespawnTime				= "999999"
ExplosionName           = "uta1_bldg_tower_destruct_exp"
DestroyedGeometryName   = "uta1_bldg_tower_destroyed"

//  DAMAGE STATES  =============================================================
DamageStartPercent	= 85.0
DamageStopPercent	= 70.0
DamageEffect            = "uta_bldg_tower_damage1"
DamageInheritVelocity	= 0.0
DamageAttachPoint	= "hp_damage"

DamageStartPercent	= 70.0
DamageStopPercent	= 55.0
DamageEffect            = "uta_bldg_tower_damage2"
DamageInheritVelocity	= 0.0
DamageAttachPoint	= "hp_damage"

DamageStartPercent	= 55.0
DamageStopPercent	= 40.0
DamageEffect            = "uta_bldg_tower_damage3"
DamageInheritVelocity	= 0.0
DamageAttachPoint	= "hp_damage"

DamageStartPercent	= 40.0
DamageStopPercent	= 25.0
DamageEffect            = "uta_bldg_tower_damage4"
DamageInheritVelocity	= 0.0
DamageAttachPoint	= "hp_damage"

DamageStartPercent	= 25.0
DamageStopPercent	= 10.0
DamageEffect            = "uta_bldg_tower_damage5"
DamageInheritVelocity	= 0.0
DamageAttachPoint	= "hp_damage"

DamageStartPercent	= 10.0
DamageStopPercent	= 1.0
DamageEffect            = "uta_bldg_tower_damage6"
DamageInheritVelocity	= 0.0
DamageAttachPoint	= "hp_damage"

//  DESTROYED CHUNKS  ==========================================================
CHUNKSECTION            = "CHUNK1"
ChunkGeometryName       = "uta1_bldg_tower_destroyed_chunk1"
ChunkNodeName           = ""
ChunkTerrainCollisions      = "3"
ChunkTerrainEffect      = "dirtspray"
ChunkPhysics            = "FULL"
ChunkOmega         	= "3.0 1.0 4.0"
ChunkSpeed         	= "9.0"

CHUNKSECTION            = "CHUNK2"
ChunkGeometryName       = "uta1_bldg_tower_destroyed_chunk2"
ChunkNodeName           = ""
ChunkTerrainCollisions      = "3"
ChunkTerrainEffect      = "dirtspray"
ChunkPhysics            = "FULL"
ChunkOmega         	= "3.0 1.0 4.0"
ChunkSpeed         	= "9.0"

CHUNKSECTION            = "CHUNK3"
ChunkGeometryName       = "uta1_bldg_tower_destroyed_chunk3"
ChunkNodeName           = ""
ChunkTerrainCollisions      = "3"
ChunkTerrainEffect      = "dirtspray"
ChunkPhysics            = "FULL"
ChunkOmega         	= "3.0 1.0 4.0"
ChunkSpeed         	= "9.0"

CHUNKSECTION            = "CHUNK4"
ChunkGeometryName       = "uta1_bldg_tower_destroyed_chunk4"
ChunkNodeName           = ""
ChunkTerrainCollisions      = "3"
ChunkTerrainEffect      = "dirtspray"
ChunkPhysics            = "FULL"
ChunkOmega         	= "3.0 1.0 4.0"
ChunkSpeed         	= "9.0"

CHUNKSECTION            = "CHUNK5"
ChunkGeometryName       = "uta1_bldg_tower_destroyed_chunk5"
ChunkNodeName           = ""
ChunkTerrainCollisions      = "3"
ChunkTerrainEffect      = "dirtspray"
ChunkPhysics            = "FULL"
ChunkOmega         	= "3.0 1.0 4.0"
ChunkSpeed         	= "9.0"

CHUNKSECTION            = "CHUNK6"
ChunkGeometryName       = "uta1_bldg_tower_destroyed_chunk6"
ChunkNodeName           = ""
ChunkTerrainCollisions      = "3"
ChunkTerrainEffect      = "dirtspray"
ChunkPhysics            = "FULL"
ChunkOmega         	= "3.0 1.0 4.0"
ChunkSpeed         	= "9.0"

CHUNKSECTION            = "CHUNK7"
ChunkGeometryName       = "uta1_bldg_tower_destroyed_chunk7"
ChunkNodeName           = ""
ChunkTerrainCollisions      = "3"
ChunkTerrainEffect      = "dirtspray"
ChunkPhysics            = "FULL"
ChunkOmega         	= "3.0 1.0 4.0"
ChunkSpeed         	= "9.0"

CHUNKSECTION            = "CHUNK8"
ChunkGeometryName       = "uta1_bldg_tower_destroyed_chunk8"
ChunkNodeName           = ""
ChunkTerrainCollisions      = "3"
ChunkTerrainEffect      = "dirtspray"
ChunkPhysics            = "FULL"
ChunkOmega         	= "3.0 1.0 4.0"
ChunkSpeed         	= "9.0"


AttachOdf = "uta1_bldg_tower_flicker"

AttachToHardPoint = "hp_tower0"
AttachToHardPoint = "hp_tower1"
AttachToHardPoint = "hp_tower2"
AttachToHardPoint = "hp_tower3"
AttachToHardPoint = "hp_tower4"
AttachToHardPoint = "hp_tower5"
And for the turrets:

Code: Select all

[GameObjectClass]
ClassLabel              = "armedbuilding"
GeometryName            = "rep_bldg_boxturret.msh"

[Properties]

BUILDINGSECTION            = "BODY"
PilotType = "self"
Controllable = "0"
//AutoFire = "1"
MapTexture         	= "turret_icon"
IconTexture         	= "HUD_all_lascannon_icon"

MapScale            	= "0.0"
HealthTexture           = "HUD_kam_turret_icon"

GeometryName            = "rep_bldg_boxturret"
ExplosionName       = "rep_bldg_boxturret_exp"
DestroyedGeometryName   = "rep_bldg_boxturret_chunk1"

MaxHealth           	= "1000.0"


BUILDINGSECTION         = "TURRET1"
PilotType = "self"
Controllable = "0"
//AutoFire = "1"
ForceMode = 1

TurretNodeName          = "aimer_head"

PitchLimits             = "-40 15"
YawLimits           	= "-180 180"

PitchTurnFactor    	 = "0.0"

//FirstPerson           = "com\comviewf;com_1st_cockpit_viewfinder"
ThirdPersonFOV	    	= "65"
WeaponName           	= "tur_weap_spa_chaingun"
WeaponAmmo          	= "0"


MaxTurnSpeed            = "5.0"
MaxPitchSpeed           = "5.0"
PitchRate           		= "1.5"
TurnRate            		= "1.5"
PCMaxPitchSpeed         = "5.0"
PCMaxTurnSpeed          = "5.0"    
EyePointOffset          = "0.0 8.0 0.0"
TrackCenter							= "0.0 15.0 -15.0"
TrackOffset             = "0.0 -8.0 -8.0"
TiltValue 					  	= "10"

TURRETSECTION       = "TURRET1"
    
PilotType = "self"
Controllable = "0"
//AutoFire = "1"
TargetEnemy         = "1"
TargetNeutral           = "0"
TargetFriendly          = "0"

TargetPerson            = "0"
TargetAnimal            = "0"
TargetDroid         = "0"
TargetVehicle           = "1"
TargetBuilding          = "1"
//TargetFlyer             ="1
AimerNodeName           = "aimer_barrels"
AimerPitchLimits        = "-30 10"
AimerYawLimits          = "-0 0"


BarrelNodeName          = "barrel1"
BarrelRecoil            = "0.5"
FirePointName           = "hp_fire1"

NextBarrel              = "-"

BarrelNodeName          = "barrel2"
BarrelRecoil            = "0.5"
FirePointName           = "hp_fire2"


TurretYawSound         = "turret_whir_yaw_lp"
TurretYawSoundPitch    = "0.7"
TurretPitchSound       = "turret_whir_pitch_lp"
TurretPitchSoundPitch   = "0.7"
TurretAmbientSound     = ""
TurretActivateSound    = "vehicle_equip"
TurretDeactivateSound  = "vehicle_equip"
TurretStartSound       = ""
TurretStopSound        = ""


FoleyFXGroup    = "metal_foley"

DamageStartPercent      = 50.0
DamageStopPercent       = 30.0
DamageEffect            = "com_sfx_vehiclespark"

DamageStartPercent      = 30.0
DamageStopPercent       = 0.0
DamageEffect            = "com_sfx_vehiclespark"
DamageAttachPoint       = "hp_spark_1"

//////  Chunks  //////////


CHUNKSECTION        = "CHUNK1"
ChunkGeometryName   = "rep_bldg_boxturret_chunk1"
ChunkNodeName       = ""
ChunkPhysics        = "STATIC"


CHUNKSECTION        = "CHUNK1"
ChunkGeometryName   = "rep_bldg_boxturret_chunk2"
ChunkNodeName       = ""
ChunkTerrainCollisions  = "6"
ChunkTerrainEffect  = "com_sfx_explosion_lg"
ChunkPhysics        = "FULL"
ChunkOmega      = "1.4 1.5 2.0"
ChunkBounciness     = 0.45
ChunkStickiness     = 0.25
ChunkSpeed      = "16.0"
ChunkUpFactor       = "14.00"
ChunkTrailEffect    = "com_sfx_chunktrail_sm"
And I've made a new/copied/edited script:

(turret script):

Code: Select all

ScriptCB_DoFile("LinkedTurrets")
function SetupTurrets() 
    
   
     --IMP turrets
    turretLinkageIMP = LinkedTurrets:New{ team = IMP, mainframe = "imp-defense", 
		turrets = {"imp_turr_1", "imp_turr_2"} }
    turretLinkageIMP:Init()

function turretLinkageIMP:OnDisableMainframe()
        ShowMessageText("level.spa.hangar.mainframe.atk.down", ALL)
        ShowMessageText("level.spa.hangar.mainframe.def.down", IMP)
        
        BroadcastVoiceOver( "IOSMP_obj_21", IMP )
        BroadcastVoiceOver( "AOSMP_obj_20", ALL )
    end
    function turretLinkageIMP:OnEnableMainframe()
        ShowMessageText("level.spa.hangar.mainframe.atk.up", ALL)
        ShowMessageText("level.spa.hangar.mainframe.def.up", IMP)
        
        BroadcastVoiceOver( "IOSMP_obj_23", IMP )
        BroadcastVoiceOver( "AOSMP_obj_22", ALL )
    end
    
    end
And in the mission.lua calling for the script:

Code: Select all

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("OMFg_cmn") --which is the linkedturret script

I've been trying to get it to work for two days, with about 5-6 hours of reading and trying and failing... anyone have any ideas why it not working?
It's not working at all. When I destroy the building, the turrets still work, no message comes on the screen and no VO. Thanks in advance.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

RE: scripting Problem with linked auto turrets...Need help.

Post by [RDH]Zerted »

I've also have had troubles (in the Deathmatch game mode) with using custom script files. Take it out of your custom file and place it where is was designed to go.

Remember, you can edit the setup_teams, LinkedTurrets, etc... scripts too.
Big_rich

Post by Big_rich »

Ok, figured it out. It was simple, yet complicated at the same time. As space and land scripts vary so much. Here is the code I used to finally get it working:

Mission.lua

Code: Select all

--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("ObjectiveConquest")





	--  Empire Attacking (attacker is always #1)
    local ALL = 1
    local IMP = 2
    --  These variables do not change
    local ATT = 1
    local DEF = 2


[color=red]ScriptCB_DoFile("cusg_cmn")[/color]  --custom turret script needed to be placed after team setup
function ScriptPostLoad()	   
     
 [color=red]SetupTurrets()[/color] --had to be placed after Post load
   
    --This defines the CPs.  These need to happen first
    cp1 = CommandPost:New{name = "cp1"}
    cp2 = CommandPost:New{name = "cp2"}
    cp3 = CommandPost:New{name = "cp3"}
    cp4 = CommandPost:New{name = "cp4"}
    cp6 = CommandPost:New{name = "cp6"}
Turret script called cusg_cmn( just copied/edited from space cmn script:

Code: Select all


ScriptCB_DoFile("LinkedTurrets")

function SetupTurrets() 
 
   
     --IMP turrets
    turretLinkageIMP = LinkedTurrets:New{ team = IMP, mainframe = "imp_auto", 
		turrets = {"imp1", "imp2"} }
    turretLinkageIMP:Init()

function turretLinkageIMP:OnDisableMainframe()
        ShowMessageText("level.spa.hangar.mainframe.atk.down", 1) --has to be changed from IMP to 1 for teams to get message
        ShowMessageText("level.spa.hangar.mainframe.def.down", 2)
        
        BroadcastVoiceOver( "IOSMP_obj_21", 2 )
        BroadcastVoiceOver( "AOSMP_obj_20", 1 )
    end
    function turretLinkageIMP:OnEnableMainframe()
        ShowMessageText("level.spa.hangar.mainframe.atk.up",1)
        ShowMessageText("level.spa.hangar.mainframe.def.up", 2)
        
        BroadcastVoiceOver( "IOSMP_obj_23",2 )
        BroadcastVoiceOver( "AOSMP_obj_22", 1 )
    end
    
    end
mission.req in script files:

Code: Select all

ucft
{
    REQN
    {
        "config"
        "ingame_movies"	
    }

    REQN
    {
        "script"
        "setup_teams"
        "gametype_conquest"
        "gametype_capture"
        "Objective"
        "MultiObjectiveContainer"
        "ObjectiveCTF"
        "ObjectiveAssault"
        "ObjectiveSpaceAssault"
        "ObjectiveConquest" 
        "ObjectiveTDM"
        "ObjectiveOneFlagCTF"
	"SoundEvent_ctf"
        "ObjectiveGoto"        
        "LinkedShields"
        "LinkedDestroyables"
        "LinkedTurrets"
        "Ambush"
  [color=red]      "cusg_cmn"[/color]-- calls the custom script
        "PlayMovieWithTransition"
        
    }

    REQN
    {
        "lvl"
        "CUSg_con"
        
        
    }
}
cusg_cmn has to be in common\scripts. not common\scripts\pc
Post Reply