How to detect what kill biters

Place to get help with not working mods / modding interface.
Post Reply
User avatar
darius456
Fast Inserter
Fast Inserter
Posts: 222
Joined: Thu Jan 02, 2014 6:33 am
Contact:

How to detect what kill biters

Post by darius456 »

One fast question. On entity died event I can check what type of entity died... Biter, building etc. but how I can determine what was the cause of death. How to determine that I shoot biter or laser tower did?
Lenovo Y580 8GB Ram GF660m 128GB SSD W7

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: How to detect what kill biters

Post by drs9999 »

I am afraid that this is not possible.

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: How to detect what kill biters

Post by FreeER »

I'm fairly sure that's not directly supported... You could check the distance of the player (util.distance) from the biter but that's obviously not foolproof... As far as I (and the wiki) know onentitydied only contains the Lua/Entity that died not what killed it, and as far as I know there's no way to tell what damaged it...

edit for completeness: you'd compare the distance to the range of the weapons that the player has equipped, not sure if you can tell which weapon is active though... or if there is an easy way to tell the range of any weapon (maybe game.itemprototypes would have that? but there doesn't seem to be a listing anywhere of exactly which parts of the prototypes are provided in the runtime prototypes...)

User avatar
darius456
Fast Inserter
Fast Inserter
Posts: 222
Joined: Thu Jan 02, 2014 6:33 am
Contact:

Re: How to detect what kill biters

Post by darius456 »

Thank you for your answers, I thought so. But I have 2 another small questions:
1. Have you ever tried to use this command:

Code: Select all

game.findentitiesfiltered{area = {{-10, -10}, {10, 10}}, type="resource"} -- gets all resources in the rectangle
game.findentitiesfiltered{area = {{-10, -10}, {10, 10}}, name="iron-ore"} -- gets all iron ores in the rectangle
but try to filter by force not type/name?

2.Help me with command:
This doesn't work:

Code: Select all

glob.dog[1].setcommand({type=defines.command.attackarea, destination = {pos_x, pos_y}, Radius=8 ,distraction=defines.distraction.none })
-attackarea - requires Destination=Types/position, Radius=Types/double, and Distraction=Types/Distraction

This doesn't too:

Code: Select all

glob.dog[1].setcommand({type=defines.command.attack, target = uwilldie, distraction=defines.distraction.none })
-attack - requires Target=entity and Types/Distraction

This work:

Code: Select all

glob.dog[i].setcommand({type=defines.command.gotolocation, destination = {pos_x, pos_y}, Radius=20 ,distraction=defines.distraction.none })
-gotolocation - requires Destination=Types/position or entity, Radius=Types/double, and Distraction=Types/Distraction

I got error that i'm trying to put nil value instead of table. How to use attack or attackarea commands? Please give me an example.

I'm trying to create PSI technology with PSI Tower that capture bitters, then friendly bitters will fallow player and player will have ability to order them to attack or move somewhere.
May be bitters will be upgradable... if you kill enough bitters of one kind or DNA modify or even implant exoskeleton :)
Lenovo Y580 8GB Ram GF660m 128GB SSD W7

drs9999
Filter Inserter
Filter Inserter
Posts: 831
Joined: Wed Mar 06, 2013 11:16 pm
Contact:

Re: How to detect what kill biters

Post by drs9999 »

darius456 wrote:1. Have you ever tried to use this command: [...]
You can only use type or name, but not force.

I cannot answer the rest, because I had not used it, though...

User avatar
FreeER
Smart Inserter
Smart Inserter
Posts: 1266
Joined: Mon Feb 18, 2013 4:26 am
Contact:

Re: How to detect what kill biters

Post by FreeER »

darius456 wrote:but try to filter by force not type/name?
Nope ;) as drs9999 said it only filters based on type or name, there is a game.findenemyunits command (which I assume checks the force as well as type), but it won't find unit-spawners, to do so you'd need to use findentities and check each entity yourself. Or findenemyunits and findentitiesfiltered{type="unit-spawner"}.
darius456 wrote: glob.dog[1].setcommand({type=defines.command.attackarea, destination = {pos_x, pos_y}, Radius=8 ,distraction=defines.distraction.none })
Radius should be lowercase 'radius', then it works (just tested with destination=game.player.position), I'll update the wiki to show it properly ;) not sure why it's different than gotolocation however :lol:
darius456 wrote: glob.dog[1].setcommand({type=defines.command.attack, target = uwilldie, distraction=defines.distraction.none })
This worked for me as written, assuming 'uwilldie' was a valid lua/entity (I used game.player.selected over a biter-spawner, they were the same force so that's not a problem)

User avatar
darius456
Fast Inserter
Fast Inserter
Posts: 222
Joined: Thu Jan 02, 2014 6:33 am
Contact:

Re: How to detect what kill biters

Post by darius456 »

Thank you... fuc!@#$ R...
Lenovo Y580 8GB Ram GF660m 128GB SSD W7

Post Reply

Return to “Modding help”