Linking Destructable Objects

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
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Linking Destructable Objects

Post by trainmaster611 »

If you have several destructable objects, how would you make it so that if one is destroyed, so are all the rest. I'm guessing this will involve some intensive scripting since I plan on linking chunks, turrets, and cps together :?
RC-1290

Post by RC-1290 »

why don't you just check one of the shipped spacemaps....
It uses the script ScriptCB_DoFile("LinkedDestroyables")
this is about the linked destroyables in SPA2c_c

Code: Select all

function SetupLinkedObjects()
    SetupShields()
    SetupDestroyables()
--    SetupTurrets()  
end

function SetupShields()
    -- CIS Shielded objects    
    linkedShieldObjectsCIS = { "cis_fly_fedcruiser5", "cis_fly_fedcruiser1", "cis_fly_fedcruiser8", "cis_fly_fedcruiser9", 
                                "cisbridge01", "cis_prop_shipturret3", "cis_prop_shipturret1", "ciseng02", "ciseng01", "comms_cis"}
    shieldStuffCIS = LinkedShields:New{objs = linkedShieldObjectsCIS, maxShield = 70000, addShield = 2000, controllerObject = "shield_cis"}
    shieldStuffCIS:Init()
    
    function shieldStuffCIS:OnAllShieldsDown() 
        ShowMessageText("level.spa.hangar.shields.atk.down", REP)
        ShowMessageText("level.spa.hangar.shields.def.down", CIS)
        EnableLockOn({"cisbridge01", "ciseng02", "ciseng01", "comms_cis"}, true)
    end
end

function SetupDestroyables()
    --CIS destroyables
    engineLinkageCIS = LinkedDestroyables:New{ objectSets = {{"ciseng01", "ciseng02"}, {"engine_cis"}} }
    engineLinkageCIS:Init()
    
end
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Post by trainmaster611 »

I've never noticed that before. Where did you get it? :)

Ok so looking at this briefly, what I'm afraid I may stumble upon is what do the Setup lines do and what am I putting there and to make the objects linked, all I have to do is list the names of the objects (chunks), the turrets, etc. with "ObjectNameHere", right? :D


-[EDIT]-

Oh and where exactly in the LUA does this go? :?
RC-1290

Post by RC-1290 »

Study some space lua's. I haven't done any work with linked objects yet but I did start to learn about mission objectives by combining the things said in the ' how where etc ambush topic' ( don't know the exact topic name), the scripting documentation, my current knowledge in PHP and C++ and by looking at the scripts in the assets.
---
Remeber things like " SetupDestroyables()" are functions; block of codes. those can have any name you give em. Those " setup" lines are just ways to keep the code managable and compact. Sorry I'm bad at explaining things but I suggest checking a tutorial about functions in for example the programming language C++ or something. You'll find that lua files have much similarities with some very well known programming languages.
---
I think I just confused you and made everything sound harder than it is. Don't worry, I'm sure there is someone here that can explain stuff... like I said, I can't :P.
Good luck

RC-1290'Dreadnought'
MercuryNoodles
Jedi
Jedi
Posts: 1003
Joined: Sun Mar 12, 2006 7:16 pm
Projects :: Space - Boarding Action
xbox live or psn: No gamertag set

Post by MercuryNoodles »

This is for the destructible capital ship idea, right? You should mention details like that, so we don't waste time guessing. Chunks shouldn't be a worry, since chunks would be dealt with in an odf. You only need to list ZE-given object names for the LinkedDestroyables, but I think more advanced scripting will be needed to destroy the CPs as well. That next step I can't explain, since I haven't dealt with it yet.


Here's an example from my lua, with some details highlighted:
frigateLinkageIMP = LinkedDestroyables:New{ objectSets = {{"imp_bldg_frigateturret", "imp_bldg_frigateturret1", "imp_bldg_frigateturret2", "imp_bldg_frigateturret3", "imp_bldg_frigateturret4", "imp_bldg_frigateturret5"}, {"imp-frigate"}} }
frigateLinkageIMP:Init()
Basically, just remember to list the objects you don't want causing everything to blow first. In this case, they are individual turrets (red), with the frigate itself in the second (blue) set. Oh, and the new script name's in yellow so you know it goes in two places.

Btw, they go between this line:

function SetupDestroyables()

and "end".
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Post by trainmaster611 »

I found something about linked turrets in the LUA but not anything about SetupDestroyables(). Would that mean I would have to start my own section? And what exactly is frigateLinkageIMP? Is it a command for the Munger to read or is it an odf or what? :|

Btw, this is already starting to make sense. :P Thanks for the help so far :)
MercuryNoodles
Jedi
Jedi
Posts: 1003
Joined: Sun Mar 12, 2006 7:16 pm
Projects :: Space - Boarding Action
xbox live or psn: No gamertag set

Post by MercuryNoodles »

This is in the xxxx_Diet Dr. Pepper.lua, not cmn.lua Look there towards the end. It defines the life support and engine linkages there.

frigateLinkageIMP is just my own script in the lua as an example for you. It could be anything, since you can name your scripts. This, I used to link turrets to an Imperial frigate, thus the name. :P
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Post by trainmaster611 »

Aww I see it. Thanks :D
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Post by trainmaster611 »

Ok its not working :( Its acting like a prop and turrets like it did before. And I did give the chunks a max health and an add health line :?
frigateLinkageCIS = LinkedDestroyables:New{ objectSets = {{"cis_turr_74", "cis_turr_86", "cis_turr_77", "cis_turr_75", "cis_turr_85", "cis_turr_87", "cis_turr_88", "cis_turr_80", "cis_turr_79", "cis_turr_93", "cis_turr_92", "cis_turr_83", "cis_turr_84", "cis_turr_91", "cis_turr_81", "cis_turr_90", cis_turr_89", "cis_turr_82", "cis_turr_71", "cis_turr_66", "cis_turr_65", "cis_turr_68", "cis_turr_69", "cis_turr_71", "cis_turr_70", "cis_turr_72", "cis_turr_73", "cis_turr_76", "cis_prop_shipturret42", "cis_prop_shipturret43", "cis_prop_shipturret41"}, {"cis_munificent_left", "cis_munificent_right"}} } frigateLinkageCIS:Init()
MercuryNoodles
Jedi
Jedi
Posts: 1003
Joined: Sun Mar 12, 2006 7:16 pm
Projects :: Space - Boarding Action
xbox live or psn: No gamertag set

Post by MercuryNoodles »

AddHealth is health regeneration, if I remember correctly, which you would use to keep things from being destroyed. See if getting rid of those lines fixes it, because I see nothing wrong with the script itself, unless you misnamed something.
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Post by trainmaster611 »

Well I deleted the Addhealth line and deleted changed the part in the ODF that says "prop" to "armedbuilding". Uhhh....what's wrong with the ODF file??? Is there anything else I'm missing? :?

Btw, thanks for the turret :P
MercuryNoodles
Jedi
Jedi
Posts: 1003
Joined: Sun Mar 12, 2006 7:16 pm
Projects :: Space - Boarding Action
xbox live or psn: No gamertag set

Post by MercuryNoodles »

What's happening, now? I can't see what you see.

No problemo. heh
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Post by trainmaster611 »

This is the odf file
cis_munificent_left wrote:[GameObjectClass]

ClassLabel = "armedbuilding"
GeometryName = "cis_munificent_left.msh"


[Properties]

GeometryName = "cis_munificent_left"
MaxHealth = "100000.0"
FoleyFXGroup = "metal_foley"
In game it just appears like a regular object. I did btw define the team in game :?
MercuryNoodles
Jedi
Jedi
Posts: 1003
Joined: Sun Mar 12, 2006 7:16 pm
Projects :: Space - Boarding Action
xbox live or psn: No gamertag set

Post by MercuryNoodles »

Does it appear to lose health when attacked? What's happening in the game? That's what I meant.

Btw, do you have the RemoveFromMapWhenDead line in that odf as well? That may have something to do with it. I would suggest adding the Damageblahblahblah lines, but I don't know if the model has hard points to attach those effects to.
Qdin
Old School Staff
Posts: 2059
Joined: Wed Feb 23, 2005 9:54 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Post by Qdin »

otherwise, just look in BConstructor and apply it to a mesh. it might not be as accurate as it'll mos tlikely get attached to the pivot/local center of the mesh.

should work :wink:

Isn't AddHealth just to ADD health to that object? If I remember right there was some other line to regenerate health.
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Post by trainmaster611 »

It just acts like a prop in-game. Its like I didn't even mess with the ODF :?
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Post by trainmaster611 »

Ok, I figured out what I am doing wrong and now the health works in game. But despite the fact that I have the object connecty thing, they will still only be destroyed one chunk at a time :?
frigateLinkageCIS = LinkedDestroyables:New{ objectSets = {{"cis_turr_74", "cis_turr_86", "cis_turr_77", "cis_turr_75", "cis_turr_85", "cis_turr_87", "cis_turr_88", "cis_turr_80", "cis_turr_79", "cis_turr_93", "cis_turr_92", "cis_turr_83", "cis_turr_84", "cis_turr_91", "cis_turr_81", "cis_turr_90", cis_turr_89", "cis_turr_82", "cis_turr_71", "cis_turr_66", "cis_turr_65", "cis_turr_68", "cis_turr_69", "cis_turr_71", "cis_turr_70", "cis_turr_72", "cis_turr_73", "cis_turr_76", "cis_prop_shipturret42", "cis_prop_shipturret43", "cis_prop_shipturret41"}, {"cis_prop_munificent_left", "cis_prop_munificent_right"}} } frigateLinkageCIS:Init()
Post Reply