MinePlanter - Printable Version +- Colobot Forum - International Colobot Community (https://colobot.info/forum) +-- Forum: [Archive] New forum (2015-2019) (https://colobot.info/forum/forumdisplay.php?fid=76) +--- Forum: Colobot: Gold Edition Basics (https://colobot.info/forum/forumdisplay.php?fid=58) +---- Forum: Workshop (https://colobot.info/forum/forumdisplay.php?fid=60) +---- Thread: MinePlanter (/showthread.php?tid=818) MinePlanter - krakers - 08-04-2016 I have an idea to make a robot what will plant mines. I decided to use Sniffer and "produce" command, because of (un)limitations of colobot For now it's so simple Quote:extern void object::MinePlanter() { sniff(); produce(Mine); } I wonder how to make Sniffer produce the Mine in front of him - do you guys have any idea? RE: MinePlanter - tomaszkax86 - 08-04-2016 You need to use robot's position and orientation to calculate position in front of it and use it as an argument for produce. This code should do it: Code:```float angle = orientation; float radius = 5.0; point pos; pos.x = position.x + radius * cos(angle); pos.y = position.y + radius * sin(angle); produce(pos, orientation, Mine);``` If you want it to make a mine behind it, just add 180 to "angle". You can change the distance by changing variable "radius". RE: MinePlanter - krakers - 08-06-2016 Thank you! That's exactly what i need Quote:extern void object::MinePlanter() { float angle = orientation; float radius = 1.7; point pos; pos.x = position.x + radius * cos(angle); pos.y = position.y + radius * sin(angle); sniff(); produce(pos, orientation, Mine); } @edit. That's pretty strange. I used "produce" command before "sniff" and when I runned this program while robot was standing in place, it was OK. When program finished I could even go thru the mine. The problem was when I runned program while robot was moving - then Mine was destroying robots immediately. So i had to use "sniff" before "produce" - then robot needs to stop to sniff and it works fine