EntityBygeomId(id) = dead?
11 posts • Page 1 of 1
EntityBygeomId(id) = dead?
To enhance some AI code of DugRel's drones even further, I need to counter an annoying issue which basically turns my drones off:
If the drone has the ID of an target, but the target is dead and it doesnt know what to do anymore...
I need a 100% garuanteed way of making the drone notice if it can't find an entity by that ID anymore, or that the entity is out of range(which is the easy part that I already know). If they try to get the position of an non-existend object, they just fly around, shooting into thin air, without beeing able to rotate to any known enemy
If the drone has the ID of an target, but the target is dead and it doesnt know what to do anymore...
I need a 100% garuanteed way of making the drone notice if it can't find an entity by that ID anymore, or that the entity is out of range(which is the easy part that I already know). If they try to get the position of an non-existend object, they just fly around, shooting into thin air, without beeing able to rotate to any known enemy
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: EntityBygeomId(id) = dead?
This code works but it will throw an error in the console each time you execute it.
- Code: Select all
scene.entityBygeomId(id) ? {} : {
<code here>
}
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: EntityBygeomId(id) = dead?
I think more elegant way is to tell target notify drone of it's death)
For example put some onDie code in it from turret code with call back.
For example put some onDie code in it from turret code with call back.
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: EntityBygeomId(id) = dead?
The problem is that the drones do a 1-way-data-transmission, meaning that 1 drone owns the id of the other, but the other may not own the id of the first drone.
Also, I didnt know scene.entitybygeomid returns a boolean. Gotta try it out
Also, I didnt know scene.entitybygeomid returns a boolean. Gotta try it out
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: EntityBygeomId(id) = dead?
FRA32 wrote:The problem is that the drones do a 1-way-data-transmission, meaning that 1 drone owns the id of the other, but the other may not own the id of the first drone.
Also, I didnt know scene.entitybygeomid returns a boolean. Gotta try it out
scene.entityBygeomid doesn't return a boolean, it can't be used in boolean operations.
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: EntityBygeomId(id) = dead?
If it doesnt return a boolean, why can you use it in an if statement then?
<boolean> ? {C1} : {C2}
scene.entitybygeomid(id) ? {} : {<discard id>}
<boolean> ? {C1} : {C2}
scene.entitybygeomid(id) ? {} : {<discard id>}
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: EntityBygeomId(id) = dead?
It will return an object, I've not tried this nor can I comment on the accuracy of what I say, but I think it's one of those if the if condition returns null/nothing it will be considered false, but if it returns something it will be seen as true. The magic of computers is that sometimes you can get them to do crazy stuff.
When asking for help, READ THE STICKIES!
- electronicboy
- Posts: 1694
- Joined: Mon Aug 31, 2009 6:18 pm
Re: EntityBygeomId(id) = dead?
If it returns nothing it will be considered false, but if it returns something and if it's not a boolean it won't be seen as true, nothing will happen.
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: EntityBygeomId(id) = dead?
Here it is a safe way:
- Code: Select all
scene.my.entityExists = (ID) => {
{probe := Scene.entityByID(ID); probe} != undefined
}
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: EntityBygeomId(id) = dead?
Kilinich wrote:
- Code: Select all
scene.my.entityExists = (ID) => {
{probe := Scene.entityByID(ID); probe} != undefined
}
That's a more legit way to do it, but it still fills the console with errors.
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: EntityBygeomId(id) = dead?
So, in short: If the reference is undefined then return false?
This is actually somehow the way I tried it, but the code seems to skip something, causing it to malfunciton. Yet thanks for the answers, since now I own a garuantee that it works.
This is actually somehow the way I tried it, but the code seems to skip something, causing it to malfunciton. Yet thanks for the answers, since now I own a garuantee that it works.
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
11 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 9 guests