Author |
Message |
Hunter0
Joined: Mon Aug 29, 2011 9:26 pm Posts: 28
|
Transforming a certain actor via a TDExplosive
Basically, I want to make a TDExplosive that transforms the nearest actor in a small radius to its impact point, as long as it is a certain type (Soldier Light for example), into another one (Soldier Heavy for example). Any help at all would be appreciated especially as I have been trying to figure it out for the last 2-3 hours. Also, sorry if this doesn't make any sense.
|
Wed Feb 22, 2012 10:49 pm |
|
|
DudeAbides
Joined: Thu Jan 13, 2011 1:31 pm Posts: 158
|
Re: Transforming a certain actor via a TDExplosive
I think maybe this will work This code should activate when the item destroys itself, and checks for 1) actors 2) distance and 3) Soldier name, replicating it's position, velocity, rotation angle, angular velocity, and team. I forget if you're supposed to use the 'ToActor' thing but maybe someone else here can clear it up.
|
Thu Feb 23, 2012 12:23 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Transforming a certain actor via a TDExplosive
Change Code: function destroy (self)
to Code: function Destroy(self)
and it should work as intended. However, inventory is still an issue.
|
Thu Feb 23, 2012 2:34 am |
|
|
Hunter0
Joined: Mon Aug 29, 2011 9:26 pm Posts: 28
|
Re: Transforming a certain actor via a TDExplosive
Inventory won't be an issue because ACrabs can't pick up stuff. Thank you!
|
Thu Feb 23, 2012 8:25 am |
|
|
Hunter0
Joined: Mon Aug 29, 2011 9:26 pm Posts: 28
|
Re: Transforming a certain actor via a TDExplosive
Wait a second, this doesn't work for me. The only effect it has on the actor is that he turns around and looks at me....
|
Thu Feb 23, 2012 9:14 am |
|
|
lucariokiller
Banned
Joined: Fri Dec 09, 2011 10:32 am Posts: 226 Location: In the datarealms cemetery
|
Re: Transforming a certain actor via a TDExplosive
Quote: Inventory won't be an issue because ACrabs can't pick up stuff. Thank you! XD
|
Thu Feb 23, 2012 10:20 am |
|
|
Bad Boy
Joined: Fri Sep 10, 2010 1:48 am Posts: 666 Location: Halifax, Canada
|
Re: Transforming a certain actor via a TDExplosive
Make sure you throw the bomb close enough. That script only affects actors that are within 50 pixels of the bomb upon its detonation. If you want to increase that limit, change the the 50 in the line "if SceneMan:ShortestDistance(self.Pos,actor.Pos,true).Magnitude < 50 then" to whatever distance you want. And yeah, if the actor is outside of the max range he'll just be alerted or whatever by the bomb's detonation and will turn towards it.
|
Thu Feb 23, 2012 10:46 am |
|
|
Hunter0
Joined: Mon Aug 29, 2011 9:26 pm Posts: 28
|
Re: Transforming a certain actor via a TDExplosive
Nope, the distance isn't the issue: I have another weapon that deals damage to anyone in a 40 pixel radius and that works fine on the same ACrab. It must be something else
|
Thu Feb 23, 2012 7:14 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Transforming a certain actor via a TDExplosive
If you modified the script in any way, post it here.
|
Thu Feb 23, 2012 9:20 pm |
|
|
Bad Boy
Joined: Fri Sep 10, 2010 1:48 am Posts: 666 Location: Halifax, Canada
|
Re: Transforming a certain actor via a TDExplosive
The script was borked, here's a fixed version. Code: function Destroy(self) for actor in MovableMan.Actors do if SceneMan:ShortestDistance(self.Pos,actor.Pos,true).Magnitude < 50 then if actor.PresetName == "Soldier Light" then local hevact = CreateAHuman("Soldier Heavy" , "Coalition.rte"); hevact.Pos = actor.Pos; hevact.RotAngle = actor.RotAngle hevact.AngularVel = actor.AngularVel hevact.Vel = actor.Vel hevact.Team = actor.Team hevact.Health = actor.Health MovableMan:AddActor(hevact); hevact:FlashWhite(500); actor.ToDelete = true; end end end end He got the preset names wrong and forgot an = sign. Also keep in mind that this script has a few problems. It takes all nearby actors instead of just the closest (not sure how you want it to work) and if you have multiple explosives detonating at the same time you'll get more actors (i.e. 2 of them at the same time will give 4 actors, etc.). Though to be fair the latter probably only happens if they detonate at the exact same time as they did when I used a keypress to test them.
|
Thu Feb 23, 2012 9:43 pm |
|
|
Hunter0
Joined: Mon Aug 29, 2011 9:26 pm Posts: 28
|
Re: Transforming a certain actor via a TDExplosive
It still won't work for some reason. Is it just me?
|
Thu Feb 23, 2012 10:19 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Transforming a certain actor via a TDExplosive
You ARE shooting at a "Soldier Light," right. Just asking.
|
Thu Feb 23, 2012 10:47 pm |
|
|
Bad Boy
Joined: Fri Sep 10, 2010 1:48 am Posts: 666 Location: Halifax, Canada
|
Re: Transforming a certain actor via a TDExplosive
It works perfectly for me and I tested it pretty extensively so there's no reason it shouldn't work for you if you copy-pasted my script. That said, you should check and see if you're getting any console errors (if you don't know you open the console with ~ or /). For what it's worth I made a copy of ronin's stone and attached the script to it and I gibbed it with a keypress in the update function. But none of that should matter at all. Maybe you should post up your explosive so someone can take a look.
|
Thu Feb 23, 2012 11:04 pm |
|
|
Hunter0
Joined: Mon Aug 29, 2011 9:26 pm Posts: 28
|
Re: Transforming a certain actor via a TDExplosive
That's strange, it works now after I redo it completely of course. I must have edited it or something before so it wouldn't function. Thanks for all your help!
|
Fri Feb 24, 2012 9:17 am |
|
|
|