How to detect what kill biters
How to detect what kill biters
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
Re: How to detect what kill biters
I am afraid that this is not possible.
Re: How to detect what kill biters
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...)
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...)
Re: How to detect what kill biters
Thank you for your answers, I thought so. But I have 2 another small questions:
1. Have you ever tried to use this command: but try to filter by force not type/name?
2.Help me with command:
This doesn't work:
-attackarea - requires Destination=Types/position, Radius=Types/double, and Distraction=Types/Distraction
This doesn't too:
-attack - requires Target=entity and Types/Distraction
This work:
-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
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
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 })
This doesn't too:
Code: Select all
glob.dog[1].setcommand({type=defines.command.attack, target = uwilldie, distraction=defines.distraction.none })
This work:
Code: Select all
glob.dog[i].setcommand({type=defines.command.gotolocation, destination = {pos_x, pos_y}, Radius=20 ,distraction=defines.distraction.none })
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
Re: How to detect what kill biters
You can only use type or name, but not force.darius456 wrote:1. Have you ever tried to use this command: [...]
I cannot answer the rest, because I had not used it, though...
Re: How to detect what kill biters
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:but try to filter by force not type/name?
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 howeverdarius456 wrote: glob.dog[1].setcommand({type=defines.command.attackarea, destination = {pos_x, pos_y}, Radius=8 ,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)darius456 wrote: glob.dog[1].setcommand({type=defines.command.attack, target = uwilldie, distraction=defines.distraction.none })
Re: How to detect what kill biters
Thank you... fuc!@#$ R...
Lenovo Y580 8GB Ram GF660m 128GB SSD W7