ToastedFishSandwich Posted July 25, 2014 Share Posted July 25, 2014 Hey there forum-goers. As some of you may know, I've made a mod which duplicates zombies when you kill them. It's pretty cool. For the next version I'm looking to try out a new feature. I want to spawn the zombies a little way away and have them move towards the location of the parent zombie.my profile picture is bloody terrifying, like, seriously; wtf me?I haven't got access to my code right now but I'll be able to recall the relevant stuff from memory. Basically the function gets the location of the parent zombie, does some freaky trigonometry to it and spits out a location for the new zombie. I then create it by declaring it as a variable using whatever function creates zombies, something like: "zomb = createZombie(x,y,z)" So I have a variable ("zomb") which is my zombie. I can call functions through it like " z:setX(100) " or whatever else I feel like. What function or series of functions should I use to make a zombie walk, and not teleport, to a set of coordinates? ie " zomb:walkTo(x,y,z) " PhantomWarlock 1 Link to comment Share on other sites More sharing options...
DosBuster Posted July 27, 2014 Share Posted July 27, 2014 Y-y'know, naming a variable 'z' is really unclean to be honest. Especially how I'm assuming it's going to be used heavily, gah my ocd. Link to comment Share on other sites More sharing options...
ToastedFishSandwich Posted July 27, 2014 Author Share Posted July 27, 2014 Nah it's not used very heavily. It's a local variable right at the end of a function. I literally just need to make it walk to a location. In the current version it's not a variable at all, I just create it and never think about it again. I'm only naming it so I can call some kind of function. Link to comment Share on other sites More sharing options...
Fryhizzle Posted July 27, 2014 Share Posted July 27, 2014 I agree with DosBuster, especially considering you would be using it for coordinates.zspawn=x,y,z, seems confusing if you don't know what you are looking at. Of course that only matters to the guy programming it. Link to comment Share on other sites More sharing options...
ToastedFishSandwich Posted July 27, 2014 Author Share Posted July 27, 2014 Okay, zomb. Is that better. It can be called whatever you want, I just need a function or series of functions which can accomplish this task. Link to comment Share on other sites More sharing options...
DosBuster Posted July 28, 2014 Share Posted July 28, 2014 You should capitalize the Spawn then, that's the usual variable naming condition Link to comment Share on other sites More sharing options...
ToastedFishSandwich Posted August 19, 2014 Author Share Posted August 19, 2014 Bump? Is that allowed? Link to comment Share on other sites More sharing options...
Deadend Posted August 19, 2014 Share Posted August 19, 2014 well, since its a moving object. move() might work http://theindiestone.com/zomboidjavadocs/zombie/iso/IsoMovingObject.html#Move(zombie.iso.Vector2)It's probably also a good idea to just look at that IsoMovingObject class in general for a solution. Another work around which I believe should be easier to implement is that as soon as you spawn the zombies, create a sound from the player's position (and by sound I mean the type that you can't really hear but zombies can, hypothetically speaking, like when you press Q). If within radius the zombies should start making their way towards the sound (i.e. where the parent zombie was killed). Link to comment Share on other sites More sharing options...
EnigmaGrey Posted August 19, 2014 Share Posted August 19, 2014 I'd assume you use PathTo(int x, int y, int z, boolean critical) Link to comment Share on other sites More sharing options...
ToastedFishSandwich Posted August 19, 2014 Author Share Posted August 19, 2014 I'd assume you usePathTo(int x, int y, int z, boolean critical) I assumed that too but all it seemed to do it make zombies lurch directly at the player rather than the coordinates given, in the rare event it does anything at all. well, since its a moving object. move() might work http://theindiestone.com/zomboidjavadocs/zombie/iso/IsoMovingObject.html#Move(zombie.iso.Vector2)It's probably also a good idea to just look at that IsoMovingObject class in general for a solution. Another work around which I believe should be easier to implement is that as soon as you spawn the zombies, create a sound from the player's position (and by sound I mean the type that you can't really hear but zombies can, hypothetically speaking, like when you press Q). If within radius the zombies should start making their way towards the sound (i.e. where the parent zombie was killed). I'll try out move() asap. Thanks to both of you though. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now