Mark, on 21 December 2020 - 06:35 AM, said:

Make a small sector behind the machine gun and put a stayput version of the enemy in that sector. Then use the findnearactor feature in the gun actor so that if the enemy gets killed first it is no longer found and the gun stops shooting. And if the gun gets "killed" first have that cactor the enemy into the non-stayput version. The only problem is if you need the gun to fire in any direction and not just mostly forward. It would still work but the enemy won't follow the gun direction. Also you would have to tag this enemy somehow different from the rest so they don't all get affected. Maybe a different pal.
yeah, you can press the nuke symbol and the tank will auto destruct

i was thinking allong those line, but most eduke programming is beyond my capabilities at the moment.. for now i have a small sector and an stayput enemy, and made the gun destructable. placed a small wall crack and use that to blow the entire area killing everything. a cop out but for the moment it looks half decent. in the future i will make a custom dedicated machine gunner so the game can look for that actor and ignore all others. making the gun shoot in a 45 degree arc relative to the original angle is something to be added.
so how would i implement the findnearactor, something like findnearactor myactor 1, if 1 run code if 0 dont?
right now i have this coded, basically i hacked the floofflame code.
define MG42NPC 3951 define MG42ANPC 3952 // the a is for ambience, this gun is placed outside the playable areas to make the world seem bigger than it really is. action MG42STAND 0 1 5 1 0 action MG42FIRES 5 1 5 1 0 action MG42ASTAND -1 1 5 1 0 action MG42AFIRE 4 1 5 1 0 useractor notenemy MG42NPC 100 MG42STAND ifaction MG42FIRES { ifactioncount 2 shoot SHOTSPARK1 sound MG42FIRE ifrnd 64 { shoot FIRELASER } ifactioncount 16 action MG42STAND } ifaction MG42STAND ifrnd 8 // was 4 { action MG42FIRES resetactioncount else action MG42STAND } ifhitweapon { debris SCRAP1 2 ifdead { sound VENT_BUST debris SCRAP1 10 killit } } enda useractor notenemy MG42ANPC 100 MG42ASTAND // and the ambience version, basically the same but wont require an owner to run. ifaction MG42AFIRE { ifactioncount 2 sound MG42FIRE ifrnd 64 { shoot FIRELASER } ifactioncount 16 action MG42ASTAND } ifaction MG42ASTAND ifcansee ifp palive ifcanshoottarget ifrnd 16 // was 4 { action MG42AFIRE resetactioncount else action MG42ASTAND } ifhitweapon { debris SCRAP1 2 ifdead { sound VENT_BUST debris SCRAP1 10 killit } } enda
so i'd probably add something like
gamevar MGNEAR 0 0 findnearactor MGGUNNER 512 MGNEAR onevent MGNEAR 1 run code ( action MGSTAND, wich will loop in intervalls ) else action MGABANDONED or something ( same action as MGSTAND but wont run the shooting code )
i could also run a check if the gun is still 'alive' and if not callactor MGgunner roaming or something so he can abandon his position and change to a regular soldier.