|
Page 1 of 1
|
[ 14 posts ] |
|
Inherited targeting on non-actors?
Author |
Message |
carriontrooper
Joined: Mon Apr 13, 2009 12:27 pm Posts: 813 Location: Yogyakarta, Indonesia. A slice o' paradise.
|
Inherited targeting on non-actors?
Allright, I have this idea for a weapon, but I'm not sure how it could be coded. In essence, it fires a missile that locks on to an actor, which after some time splits into smaller missiles which inherit the same target as its parent. But here's the deal: the parent first checks the firer's team, and inherits that variable to its children. So, I'm asking the sparkle magicians here, how could this weapon be coded?
This could preferably be expanded to make multi-stage homing missiles, in which a missile splits into two missiles which each split into two missiles, all of them inherits its firer's team.
|
Fri Jun 11, 2010 2:02 pm |
|
|
Petethegoat
Joined: Mon Jun 15, 2009 4:02 pm Posts: 905
|
Re: Inherited targeting on non-actors?
Code: function Create(self) self.Timer = Timer(); end
function Update(self) if self.Timer:IsPastSimMS(300) then local new = CreateMOSRotating("lolmissle"); new.Pos = self.Pos; new.Vel = self.Vel; new.Team = self.Team; MovableMan:AddMO(new); MovableMan:AddMO(new); self:GibThis(); end end This creates two lolmissiles after three seconds, with the same position, velocity and team. It then gibs the original MO. Hopefully this is what you're looking for. Edit:Forgot an end.
|
Fri Jun 11, 2010 4:01 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Inherited targeting on non-actors?
Petethegoat wrote: This creates two lolmissiles after three seconds, with the same position, velocity and team. It then gibs the original MO. Hopefully this is what you're looking for. Edit:Forgot an end. I think he/she wants the missiles to inherit targeting and already knows how to "split" the missiles. What I would do is for the main missile to create a MOPixel right on the position of the target, and give the MOPixel a random number (math.random()) and store that number in the MOPixel's sharpness,= and the missile's sharpness. The MOPixel will have a Lua script where it looks for the closest actor (should get the target) and maintains its position on the target and zeroes its velocity. The pixel deletes itself (self.ToDelete = true) after a few seconds, or if the target is dead. When the main missile splits into smaller missiles, it will change those smaller missiles' sharpness into the main missile's sharpness. Those smaller missiles will then do a particle check to look for the special MOPixel's presetname and check to see if their sharpness values match. If so, the small missile will lock onto the MOPixel, which is pretty much the same as if it was locking onto the actor, since the MOPixel is at the actor's position.
|
Fri Jun 11, 2010 7:01 pm |
|
|
Petethegoat
Joined: Mon Jun 15, 2009 4:02 pm Posts: 905
|
Re: Inherited targeting on non-actors?
Oh yeah. On closer inspection of the OP, that would be more logical.
As for method though, could you not have the parent missile set the PresetName of it's target to a random number, which it then gives to it's children to track? If that is possible, it seems like it would be an awful lot easier.
I did not actually read the body of your post. That said, why not just use the PresetName of the actor, rather than fiddling around with MOPixels?
|
Fri Jun 11, 2010 7:07 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Inherited targeting on non-actors?
Because that may break some mods that work off the default setting of PresetName, like weegee's metagame mission thing, my Repair Kit, DarkStorm, and many others. And you can't use the default PresetName for a missile lock-on, 'cause there could be more than one of that type of actor in the game.
|
Fri Jun 11, 2010 7:09 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Inherited targeting on non-actors?
Store a pointer to the target in the minimissile's presetnames after you spawn them. Then just have the minimissile's scripts read self.Presetname and use it as a pointer.
You can also store Team in goldvalue, if you like.
|
Fri Jun 11, 2010 7:18 pm |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Inherited targeting on non-actors?
GoldValue is read-only. I'm going to test storing a pointer in presetname, never thought about that.
Edit: Can't store pointers in PresetNames.
Lua Console error: the attribute 'Actor.PresetName' is of type: (const string (wierd symbol here)) and does not match: (Actor)
|
Fri Jun 11, 2010 7:21 pm |
|
|
411570N3
Joined: Wed Jan 07, 2009 10:26 am Posts: 4074 Location: That quaint little British colony down south
|
Re: Inherited targeting on non-actors?
Is there any format a pointer can be stored as that is compatible with storing it in a string? No numbers, no nothing?
|
Sat Jun 12, 2010 3:17 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Inherited targeting on non-actors?
I don't know how pointers actually store actors. Using print() on a pointer without defining any properties gives an error.
|
Sat Jun 12, 2010 3:19 am |
|
|
411570N3
Joined: Wed Jan 07, 2009 10:26 am Posts: 4074 Location: That quaint little British colony down south
|
Re: Inherited targeting on non-actors?
Then yeah, it's probably not something that can be done. Is there any function with something like a numerical input that returns a pointer based on that? Otherwise, you'd probably have to end up fiddling with global tables and stuff, which could get fiddly.
|
Sat Jun 12, 2010 3:40 am |
|
|
carriontrooper
Joined: Mon Apr 13, 2009 12:27 pm Posts: 813 Location: Yogyakarta, Indonesia. A slice o' paradise.
|
Re: Inherited targeting on non-actors?
CaveCricket48 wrote: I think he/she wants the missiles to inherit targeting and already knows how to "split" the missiles.
What I would do is for the main missile to create a MOPixel right on the position of the target, and give the MOPixel a random number (math.random()) and store that number in the MOPixel's sharpness,= and the missile's sharpness. The MOPixel will have a Lua script where it looks for the closest actor (should get the target) and maintains its position on the target and zeroes its velocity. The pixel deletes itself (self.ToDelete = true) after a few seconds, or if the target is dead. When the main missile splits into smaller missiles, it will change those smaller missiles' sharpness into the main missile's sharpness. Those smaller missiles will then do a particle check to look for the special MOPixel's presetname and check to see if their sharpness values match. If so, the small missile will lock onto the MOPixel, which is pretty much the same as if it was locking onto the actor, since the MOPixel is at the actor's position. Hmmm... instead of assigning a random number, could it use the same mechanism as the vanilla C4s (using lists)? I initially asked about inheriting because this could be combined with the Cordyc stuff ( viewtopic.php?f=73&t=18615 long story short, this code turns enemy actors into one of yours if they get damaged enough, thanks CC48). I had an idea for a missile/rocket to explode in mid-air, making spores that float slowly down, which, when close to an enemy actor, gib into several 'infecting' particles. So, the whole process goes like this: -missile detects parent actor and stores its team -missile has its own lua to seek out enemies, if it hits enemies or when time comes, it gibs into spores, which inherit the team of the firer -spores float, has its own lua to detect enemy actors, gib into infectyparticles which also inherits the team of the firer -infectyparticles damage enemies and gibs them into a new actor on our side if the enemy is already damaged enough To avoid enemies gibbing into the wrong team we could use lists (a missile acquires its team, it goes in the list as a number which is the sharpness thing above)... I think you guys should get it by now. Now the last part has been solved thanks to none and CC48, but the whole inheriting teams thing seems interesting. It could be used in other ways too. Also, if anything in this post confuses you, please ask. I typed this in the morning and I haven't bathed yet.
|
Sat Jun 12, 2010 4:37 am |
|
|
CaveCricket48
Joined: Tue Jun 12, 2007 11:52 pm Posts: 13144 Location: Here
|
Re: Inherited targeting on non-actors?
The vanilla C4s use a global list that stores pointers to the C4 bombs. Since it's global, anything can edit the list, which might cause some problems when using multiple missiles. You could do something to keep tracked of list number, but that might change when list entries are removed.
|
Sun Jun 13, 2010 2:15 am |
|
|
411570N3
Joined: Wed Jan 07, 2009 10:26 am Posts: 4074 Location: That quaint little British colony down south
|
Re: Inherited targeting on non-actors?
Yeah, like I said, it goes into a bunch of incredibly annoying stuff regarding database management. What I'd do is something like adding a randomly generated string to the end of the name, which is also added to the table (I'm assuming Lua tables are basically arrays) as well as the correct pointers. Whenever a missile dies it removes itself and tidies the stack. Since you're using distinct strings instead of an index reference it'll get crossed wires a bit less, but it'll be a tad laggy having to go through the entire list every time a missile dies.
|
Sun Jun 13, 2010 2:25 am |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Inherited targeting on non-actors?
Store the pointers in a global array and then store the cell IDs in presetname/sharpness/whatever useless property you like.
|
Sun Jun 13, 2010 2:53 am |
|
|
|
|
Page 1 of 1
|
[ 14 posts ] |
|
Who is online |
Users browsing this forum: No registered users |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|