Data Realms Fan Forums http://45.55.195.193/ |
|
C-4 Lua Help - Temporary detonator http://45.55.195.193/viewtopic.php?f=73&t=19251 |
Page 1 of 1 |
Author: | Roast Veg [ Wed Jul 14, 2010 9:54 pm ] |
Post subject: | C-4 Lua Help - Temporary detonator |
Little intro to what I am trying to do: There is a sad lack of terminator mods in cortex, and that needs fixing. I am not experienced enough to implement this, but I wanted to see how far I could get making the terminator's prequel foe, the forces of Tech-Com. My thinking was that once I had made the good guys, bad guys would come naturally to me. That has yet to happen. I am sourcing my mod from the very old (in gamer terms) and very bad (in gamer terms also) PS2 game: Terminator - Dawn of Fate. The reasoning behind this was that it has an astoundingly simple setup, with very few guns or charachters (and because i'm lazy). The game does, however, contain some rather interesting weaponry in the form of canister bombs and it's very own setup of C-4 explosive. I have sorted out, to a reasonable degree, the canister bombs. The C-4, however, is posing a problem. You see, the C-4 in TDoF works on the principle that a detonator appears out of nowhere every time you place a C-4, and disappears mysteriously when you detonate it. If you have ever played the game then you know what I mean. Not wanting to appear too lazy, I decided to keep to the theme, and try to make it. The only problem is, I am a real noob at Lua, and I would have sorted it myself had the wiki not gone down. So far, I have resprited my C-4 + detonator, made an .ini for them both and started a couple of Lua files for each. The code so far is as follows: C-4: Code: function Create(self) print("C-4 planted!"); --Make sure the blue C-4 list exists. if c4List == nil then --If not, create it. c4List = { }; end --Add this C-4 to the list. c4ListB[#c4List + 1] = self; --Create detonator in actors hand. for actor in MovableMan.Actors do local distcheck = SceneMan:shortestDistance(self.Pos,actor.Pos,true).Magnitude self.AddInventory = HDFirearm CopyOf = Detonator end end function Destroy(self) print("C-4 detonated") --TODO Destroy detonator end Detonator Code: function Create(self) --Make sure the red C-4 list exists. if c4List ~= nil then --Go through the list of red C-4. for i=1,#c4List do --Make sure the C-4 still exists, it may have been destroyed. if MovableMan:IsParticle(c4List[i]) then --Detonate the C-4! c4List[i]:GibThis(); end end end --Empty/create the red C-4 list. c4List = { }; end Any help (really, any at all) would be useful right now, so please respond! I will include an attachment for my mod if it is required, but to save time I will wait until someone asks. Please do if it will help you. Roast. |
Author: | CaveCricket48 [ Thu Jul 15, 2010 4:52 am ] |
Post subject: | Re: C-4 Lua Help - Temporary detonator |
What I would do is have the thrown C4 have an attached script that 1. Checks if it is "Activated" with the function "MovableObject:IsActivated()". 2. If so, find the nearest actor with prefered method of distance checking. 3. Once the actor is found, check if the actor has the detonator device with the function "Actor:HasObject()" 4. If the actor does not have the detonator, add it to the actor's inventory. For the detonator, make it delete itself after a one-time use. I highly suggest that you don't copy entire scripts and modify them, unless if you know what every single line of the original did. In my opinion, it's better to start from scratch with what you know than to copy and change something that looks like gibberish. Doing it yourself will also boost your experience. |
Author: | Roast Veg [ Thu Jul 15, 2010 3:52 pm ] |
Post subject: | Re: C-4 Lua Help - Temporary detonator |
K thanks for the advice Cricket. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |