Linking Destructable Objects
Moderator: Moderators
- trainmaster611
- Sith Lord

- Posts: 1779
- Joined: Thu Aug 24, 2006 5:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Building a railway to Coruscant
- Contact:
Linking Destructable Objects
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
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
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- trainmaster611
- Sith Lord

- Posts: 1779
- Joined: Thu Aug 24, 2006 5:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Building a railway to Coruscant
- Contact:
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?
-[EDIT]-
Oh and where exactly in the LUA does this go?
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?
-[EDIT]-
Oh and where exactly in the LUA does this go?
-
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
.
Good luck
RC-1290'Dreadnought'
---
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
Good luck
RC-1290'Dreadnought'
-
MercuryNoodles
- Jedi

- Posts: 1003
- Joined: Sun Mar 12, 2006 7:16 pm
- Projects :: Space - Boarding Action
- xbox live or psn: No gamertag set
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:
Btw, they go between this line:
function SetupDestroyables()
and "end".
Here's an example from my lua, with some details highlighted:
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.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()
Btw, they go between this line:
function SetupDestroyables()
and "end".
- trainmaster611
- Sith Lord

- Posts: 1779
- Joined: Thu Aug 24, 2006 5:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Building a railway to Coruscant
- Contact:
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.
Thanks for the help so far 
Btw, this is already starting to make sense.
-
MercuryNoodles
- Jedi

- Posts: 1003
- Joined: Sun Mar 12, 2006 7:16 pm
- Projects :: Space - Boarding Action
- xbox live or psn: No gamertag set
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.
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.
- trainmaster611
- Sith Lord

- Posts: 1779
- Joined: Thu Aug 24, 2006 5:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Building a railway to Coruscant
- Contact:
- trainmaster611
- Sith Lord

- Posts: 1779
- Joined: Thu Aug 24, 2006 5:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Building a railway to Coruscant
- Contact:
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

- Posts: 1003
- Joined: Sun Mar 12, 2006 7:16 pm
- Projects :: Space - Boarding Action
- xbox live or psn: No gamertag set
- trainmaster611
- Sith Lord

- Posts: 1779
- Joined: Thu Aug 24, 2006 5:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Building a railway to Coruscant
- Contact:
-
MercuryNoodles
- Jedi

- Posts: 1003
- Joined: Sun Mar 12, 2006 7:16 pm
- Projects :: Space - Boarding Action
- xbox live or psn: No gamertag set
- trainmaster611
- Sith Lord

- Posts: 1779
- Joined: Thu Aug 24, 2006 5:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Building a railway to Coruscant
- Contact:
This is the odf file

In game it just appears like a regular object. I did btw define the team in gamecis_munificent_left wrote:[GameObjectClass]
ClassLabel = "armedbuilding"
GeometryName = "cis_munificent_left.msh"
[Properties]
GeometryName = "cis_munificent_left"
MaxHealth = "100000.0"
FoleyFXGroup = "metal_foley"
-
MercuryNoodles
- Jedi

- Posts: 1003
- Joined: Sun Mar 12, 2006 7:16 pm
- Projects :: Space - Boarding Action
- xbox live or psn: No gamertag set
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.
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.
- xbox live or psn: No gamertag set
- trainmaster611
- Sith Lord

- Posts: 1779
- Joined: Thu Aug 24, 2006 5:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Building a railway to Coruscant
- Contact:
- trainmaster611
- Sith Lord

- Posts: 1779
- Joined: Thu Aug 24, 2006 5:22 pm
- Projects :: No Mod project currently.
- xbox live or psn: No gamertag set
- Location: Building a railway to Coruscant
- Contact:
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()
