[MOD 0.12.30] Vampire Biter - V0.0.5

Topics and discussion about specific mods
Post Reply
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

[MOD 0.12.30] Vampire Biter - V0.0.5

Post by TheSAguy »

So I have an idea for a new biter enemy type. I’m going to call them Vampires (or suckers) for now.

1. How it will work is that they will attack both the player and other biters.
2. Each time they kill an enemy biter, the killed biter will become a Vampire biter.
3. There won’t be a lot of these spawners, but the units will get stronger and stronger over time.
4. When a single Vampire biter has killed x number of units, it will get bigger.

UPDATE 4/18/16:
Thanks everyone for the code help, mainly Adil who wrote most of the current mod :D

1 – Force Code – DONE
2 – Spawn new V-Biter when killing enemy – DONE
3 – Limit spawn rate – DONE
4 – Have V-Biters level up, based on number of kills… Currently it seems this is not possible. The Turret entity has a kill counter, but not units. JorgenRe has some code below to try and emulate it, but currently won’t work on the V-Biters.

Currently I'm not sure where to go with this, if anyone has some ideas let me know.
Attachments
Vampire_Biters_0.0.5.zip
V-Biter 0.0.5
(7.2 KiB) Downloaded 312 times
Last edited by TheSAguy on Tue Apr 19, 2016 3:02 am, edited 4 times in total.

jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: New Enemy Type - Vampire Biter

Post by jorgenRe »

Will update this post as i go on.

- Making the Vampire biters attack other biters – Through ‘Force’ but don’t know how.
Nothing yet.
- Convert a killed biter to a Vampire biter. Done with ‘events.on_entity_died’, but how do you tell it only if a Vampire Biter did the killing.


This one might be a request for api seeing as i see no way of reading who killed the biter(read the api docs), but as a work around you can do a count_entities_filtered where type = player. then a count for vampire biters.
then for count of turrets. Now if only vampire biter is greater than zero it will be a vampire biter that 99 % sure did the kill.
However i dont know how bad it will be for the game's perfomance, but since its only counting it should be fine. Trye it out before abandoning i think :)!
- Lastly, each Vampire biter needs a counter of how many enemies it killed. When counter reaches, let’s say 50, kill it and spawn a larger
Vampire biter. I’m not exactly sure how to implement this. Turrets have a kill counter, so there is a way to do keep track of number of kills, I think…

Counter for any entity

Code: Select all

--Called every second or so also remember to create the table global.en at load, next thing will be to adapt it to your purpose
--which right now im not so sure about since you will need to find the vampire biters then add them to the table. 
function customcode()
stop = false
  if game.players[1].selected ~= nil then
for i = 1, #global.en do 
if global.en[i].ent == game.player.selected then
game.player.print("Found number: "..global.en[i].number.."! Count: "..global.en[i].counter)
stop = true
end
end
     if stop == false then
       global.en[#global.en+1] = {}
	   global.en[#global.en].ent = game.players[1].selected
  	   global.en[#global.en].counter = 60
	   global.en[#global.en].number  = #global.en
	 end
  end
  for i = 1, #global.en do 
    global.en[i].counter = global.en[i].counter - 11
	if global.en[i].counter <= 0 then
	 global.en[#global.en].counter = 60
    game.surfaces.nauvis.create_entity({
        name="stone",
        amount=5000,
        position={global.en[i].ent.position.x,global.en[i].ent.position.y}
        }) 
    end 
	end
  game.players[1].print("Counting: ")
end
As you see i put the biters into a global table that it puts code onto each biter.
Now as stated above at start of code. I'm a little unsure on how to properly do the finding of the vampire biters. You may want to put up a request for api changes.
  • Get entity that killed something during event_on_death
  • Run code on entity when its created. Like an event you add to its config file. Custom event calls for when something is created.
<--Terrible list :lol:
\<ol><li>Test</li></ol>
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: New Enemy Type - Vampire Biter

Post by TheSAguy »

I'm doing something wrong with my force creation, can someone please help me out here.

My Control.lua:

Code: Select all

require("defines")

game.create_force('vampire')
game.forces['vampire'].set_cease_fire('enemy', false)
game.forces['vampire'].set_cease_fire('player', false)
Error:

Code: Select all

__Vampire_Biters__/control.lua:3: attempt to index global 'game' (a nil value)
Thanks.
Last edited by TheSAguy on Fri Apr 01, 2016 3:03 am, edited 1 time in total.

jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: New Enemy Type - Vampire Biter

Post by jorgenRe »

TheSAguy wrote:I'm doing something wrong with my force creation, can someone please help me out here.

My Control.lua:

Code: Select all

require("defines")

game.create_force('vampire')
game.forces['vampire'].set_cease_fire('enemy', false)
game.forces['vampire'].set_cease_fire('player', false)
Error:

Code: Select all

__Vampire_Biters__/control.lua:3: attempt to index global 'game' (a nil value)
Thanks.
Game has to have started to do that. So it must be put somewhere else. Same for all game. ...
Last edited by jorgenRe on Thu Mar 31, 2016 7:07 pm, edited 1 time in total.
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces

orzelek
Smart Inserter
Smart Inserter
Posts: 3911
Joined: Fri Apr 03, 2015 10:20 am
Contact:

Re: New Enemy Type - Vampire Biter

Post by orzelek »

One place to not put it is in on_load. There is no acces to game there :D
It will work in any other - can use mod changed event for initialization.

jorgenRe
Filter Inserter
Filter Inserter
Posts: 535
Joined: Wed Apr 09, 2014 3:32 pm
Contact:

Re: New Enemy Type - Vampire Biter

Post by jorgenRe »

orzelek wrote:One place to not put it is in on_load. There is no acces to game there :D
It will work in any other - can use mod changed event for initialization.
Thanks for claryfying my faulty memory :)
Logo
Noticed the told change in FFF #111 so il continue to use my signature ^_^
Thanks for listening to our suggestions, devs :D!
I would jump of joy if we could specify which tiles spawned in a surfaces

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: New Enemy Type - Vampire Biter

Post by TheSAguy »

Okay, getting a little closer,
I was able to create the force and the new biters kill the others :) Fun to watch.

The game does crash sometimes on creation, not sure if it's to do with how I do the force.
Still figuring out the converting part. When I enable "script.on_event({defines.events.on_entity_died,},function(event) On_Remove(event) end)" I'm still getting a crash.

Check it out.
Last edited by TheSAguy on Mon Apr 18, 2016 4:38 pm, edited 1 time in total.

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: New Enemy Type - Vampire Biter

Post by TheSAguy »

Current version. 0.0.3.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: New Enemy Type - Vampire Biter

Post by Adil »

Wouldn't a vampire, named in accordance with standard vanilla naming mindset, be a "sucker" ? :P
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: New Enemy Type - Vampire Biter

Post by TheSAguy »

Adil wrote:Wouldn't a vampire, named in accordance with standard vanilla naming mindset, be a "sucker" ? :P
LOL - True.

Alfine
Burner Inserter
Burner Inserter
Posts: 5
Joined: Sun Jan 31, 2016 7:01 pm
Contact:

Re: [MOD 0.12.30] Vampire Biter - V0.0.5

Post by Alfine »

:D :D :D :D this mod is awesome!

Post Reply

Return to “Mods”