""" MOBA by thepolm3 Idea by Jdrew Use this script with the "mobapowers" script for best effects """ from twisted.internet.reactor import callLater from random import randint from pyspades.server import Territory from pyspades.collision import vector_collision PER_LANE=2 LANES=3 BLUE_BASE=20,492 GREEN_BASE=492,20 NOCP=max(0,min(16,PER_LANE*LANES*2+2)) LANEMIDDLES=[(20,20),(255,255),(492,492)] class MOBACP(Territory): lane=0 position=0 start_team=None per_lane=PER_LANE lanes=LANES def reset(self): self.team=self.start_team self.update() def add_player(self, player): if self.position==0: for i in range(LANES): cp=self.protocol.find_cp(i,1,self.team) if cp and cp.team!=self.team: return Territory.add_player(self,player) if player.team!=self.team: player.kill() return elif player.team!= self.start_team and self.position=max_count: return cp def get_cp(self,index): #magic function if index>=NOCP/2: team=self.green_team index-=NOCP/2 else: team=self.blue_team if index+1==NOCP/2: x,y=[BLUE_BASE,GREEN_BASE][team==self.green_team] lane=0 position=0 else: position=index % PER_LANE+1 lane=((index-(position-1))/PER_LANE) if team==self.blue_team: xa,ya=LANEMIDDLES[lane] xb,yb=BLUE_BASE xa,ya=xa-xb,ya-yb xa,ya=xa/(PER_LANE+1),ya/(PER_LANE+1) x,y=(xa*(position))+BLUE_BASE[0],(ya*(position))+BLUE_BASE[1] else: xa,ya=LANEMIDDLES[lane] xb,yb=GREEN_BASE xa,ya=xa-xb,ya-yb xa,ya=xa/(PER_LANE+1),ya/(PER_LANE+1) x,y=(xa*(position))+GREEN_BASE[0],(ya*(position))+GREEN_BASE[1] return lane,position,team,x,y,self.map.get_z(x,y) def get_cp_entities(self): cps = [] for i in xrange(NOCP): l,p,t,x,y,z = self.get_cp(i) cp = MOBACP(i, self, x,y,z) cp.team = t cp.position = p cp.lane = l cp.start_team = t cps.append(cp) self.cps=cps return cps return MOBAProtocol,MOBAConnection