Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → AI Firing Question
AI Firing Question
2006-05-15, 11:54 AM #1
I have two enemies standing next to one another in a rather tight room. When the player enters this room, they often end up firing on one another and the enemy farther from the player usually ends up inflicting a good deal of damage on the enemy closer. Without relocating these enemies, is there any way to reduce the probability of friendly fire?
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2006-05-15, 1:33 PM #2
Maybe you could edit their projectile templates to only damage players. Or write a cog that checks LOS on the player in a tight channel, then LOS on other actors in a tight channel, and only fires when player IS but actors AREN'T in LOS.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-05-15, 5:09 PM #3
Code:
Fire:
   AI = GetSenderRef();
   destroyed = 0;
   DistToPlayer = VectorDist(GetThingPos(AI), GetThingPos(GetLocalPlayerThing()));
   For(i=0; (i<GetThingCount() && !destroyed); i=i+1)
   {
      If(GetThingType(i) == 2 && i != AI && ThingViewDot(AI, i) < .8) // If actor, not the same one, and inside firecone
      {
         If(VectorDist(GetThingPos(AI), GetThingPos(i)) < DistToPlayer) // Thing is in front of player, therefore (alot) more likely to hit
         {
               DestroyThing(GetSourceRef()); // Destroy the projectile it just fired
               destroyed = 1;
         }
      }
   }
   Return;

I hope this isn't too complex of a solution, and there is an even more complex one, but this should suffice. But itwill also look like it is shooting w/ sounds and all but in a balls out firefight, it won't go noticed. However, the more complex solution will look clean.
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2006-05-16, 7:40 AM #4
But with an automatic weapon, wouldn't that slow the game down tremendously (going through each thing every time the enemy shoots)?
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2006-05-16, 8:11 AM #5
Yeah, I think he should work with NextThingInView instead.
"Häb Pfrässe, süsch chlepfts!" - The coolest language in the world (besides Cherokee)
2006-05-20, 10:21 AM #6
First off, I hate First/NextThingInView(), too many damm problems getting it to work right, too easy to screw it up. ;) Second, it will prob take about the same time or less, since this does alot of filtering, going through every thing beforehand, where as FirstThingInView has to at least go through everything as well, doing the same steps more or less, but different filtersteps. However, this is milliseconds of calcuating time, and I haven't had any slowdowns on my comp (1.62 Ghz w/ 512 MB ram), running on a pulse of 0.01. However, it all comes down to likes and dislikes.

*shrugs*
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack

↑ Up to the top!