gametechmods
Robot Arena => General Support => Topic started by: WhamettNuht on February 07, 2018, 02:25:22 PM
-
Hi all! Long time no see!
Just a quickie - I can remember from ages and ages ago I was told how to edit a value in some sort of file so that AI robots don't go after human players, but for the life of me and all of my poking around in RA2's files I cannot remember where this value lies.... Just wondering if someone would happen to know where one might find such a thing??
Also - can someone super savvy advise me on whether it would be possible to alter the Action Cam to only focus on say 2 robots when there's 3 in the arena?
Thanks guys!!
-
in init.py for the SuperAI-class
def GetNearestEnemy(self):
closest = None
min_dist = 9999
min_weighted_dist = 9999
enemies = self.GetEnemies()
# target human players first
for enemy in enemies:
dist = self.GetDistanceToID(enemy)
weighted_dist = dist
if not plus.isHuman(enemy): weighted_dist += 3
if weighted_dist < min_weighted_dist:
closest = enemy
min_weighted_dist = weighted_dist
min_dist = dist
return closest, min_dist
Invert the weighted_dist modifier.
For action cam, in actioncam.py
for p in self.players:
if plus.isEliminated(p) or plus.isDefeated(p):
if p in self.expiration:
if self.expiration[p] <= plus.getTimeElapsed():
self.players.remove(p)
self.playerCount -= 1
else:
self.expiration[p] = plus.getTimeElapsed() + self.defeatedDelay
Add a line after to remove robots you want to ignore
self.players.remove(id)
-
holy crap, this is awesome!!
Can I create a separate PY file and add this? Like will it still work?
-
Thank you for the fast reply!
Been having a tinker, but it's still not quite right, just wanted to make sure I'm getting it right (been a while since I've done all of this advanced coding lark lol)
When you say 'Invert the weighted_dist modifier' am I inverting this value:
if not plus.isHuman(enemy): weighted_dist += 3
As for the Action Cam, am I adding the self.players.remove value straight after the 'self.expiration' line?
Also, does the (id) value work on a 1-4 basis (as in 4 is robot number 4) or the typical RA2 method of 0-3 (so that 3 is robot number 4)?
Apologies for my newbness! (There's a word I haven't used for some years lol)
-
Just change this
if not plus.isHuman(enemy): weighted_dist += 3
to something like this
if plus.isHuman(enemy): weighted_dist += 9999
For the actioncam, make it look like this. id is a player id between 0-3. Also, there are more than one place where the code is used, so make sure you change it everywhere. Observe the indentation.
for p in self.players:
if plus.isEliminated(p) or plus.isDefeated(p):
if p in self.expiration:
if self.expiration[p] <= plus.getTimeElapsed():
self.players.remove(p)
self.playerCount -= 1
else:
self.expiration[p] = plus.getTimeElapsed() + self.defeatedDelay
self.players.remove(id)
self.playerCount -= 1
I haven't tried any of these, but it should work, so: :cancer::cancer::cancer::cancer::cancer: