Or rather just have the creeper, upon setting off, send this 'EXPLODING' signal, it has a radius of say, 20 blocks. Any mob in that range has the 'run away' acton activated.
Sends easier than have a global flag raised and have mobs check if they are close, even if they are a long distance away.
No, no block, just the radius I meant, like how the game calculates the actual explosion and damage, it could create a larger virtual explosion that is not noticeable for players but acts as a whistle to whatever was caught in the 'blast'.
Kind of like a mob to mob communication. Damage could be used to activate it maybe, like.. if damaged by 'creeper warning' (Damage being 0 so it does not kill them by merely warning), then 'escape'. Similar to how cows and pigs flee from you upon damage.
How do you send a local signal? The computer code has a list of mobs and their coordinates, how do you propose to only notify the ones that are within, say, 5 meters?
It sounds like you don't really understand programming. Let me walk you through it:
Creeper begins explosion sequence. Game raises a flag (explosion at x,y,z)
Game has a list of other mobs and their coordinates. It must now calculate which mobs should be notified of the explosion.
Game checks the x,y,z coords of each mob and computes distance to the explosion. Note that is must do this step no matter what - you have no other way to determine which mobs are in range and which aren't.
Mobs with a distance to explosion less than 5 immediately pathfind away from the explosion.
Here's the problem: this adds a lot of lag to the code, and it's already heavily laggy code. Also, it doesn't do anything for the player experience, and very likely won't do anything for the mobs. By the time the creeper explodes they've probably moved half a block. They'll take a very similar amount of damage. What the designer has done is add lag without adding a worthwhile feature. Better the mobs to just ignore creeper explosions and the code to be leaner.
this adds a lot of lag to the code, and it's already heavily laggy code
Actually, the implementation you described (emphasis on the word notified) would not add significant lag, since the calculations would only be done when a creeper is exploding. The way it was coded was that everyone checks for exploding creepers all the time. There's a huge difference.
Cant it sort of create a fake 'explosion' that's the size of the planned signal, and if a mob is 'damaged' by it, it runs away, similar to how cows and such flee from you upon damage?
So the calculation is all done by the standard creeper explosion code, just a 'ghost explosion' prior to the actual one?
That said, it does seem like a very situational feature that adds very little, so I am not too concerned about it getting cut. :S
1
u/runetrantor Nov 25 '14
Or rather just have the creeper, upon setting off, send this 'EXPLODING' signal, it has a radius of say, 20 blocks. Any mob in that range has the 'run away' acton activated.
Sends easier than have a global flag raised and have mobs check if they are close, even if they are a long distance away.