Ejemplo n.º 1
0
    def onEvent(self, e):
        if isinstance(e, NotifyEvent):
            con_println("notice! " + str(e) + "\n")

        elif e.eventType == "research_complete":
            objtype = savage.ObjectType(e.objtype)
            obj = savage.getGameObject(e.sourceId)
            team = savage.Team(obj.getTeam())
            if objtype.isBuildingType():
                if objtype.getName() == "beast_sublair":
                    Sound_PlaySound(
                        savage.getSound("beast_sublair_constructed"))
                elif objtype.getName() == "human_garrison":
                    Sound_PlaySound(
                        savage.getSound("human_garrison_constructed"))
                else:
                    Sound_PlaySound(
                        savage.getSound(team.getRace() + "_new_building"))

            elif objtype.isWeaponType():
                Sound_PlaySound(savage.getSound(team.getRace() +
                                                "_new_weapon"))
            elif objtype.isItemType():
                Sound_PlaySound(savage.getSound(team.getRace() + "_new_item"))
            elif objtype.isUnitType() and not objtype.isWorkerType():
                Sound_PlaySound(savage.getSound(team.getRace() + "_new_unit"))
Ejemplo n.º 2
0
	def onEvent(self, e):
		if isinstance(e, WaypointEvent):
			if e.eventType == 'waypoint_complete' or e.eventType == 'waypoint_cancel' or e.eventType == 'waypoint_destroy':
				self.setVisible(False);
			else:
				self.label.setImage(CL_GetWaypointImage(0));
				self.label.setSize(48,48);
				self.setVisible(True);
				if e.targetId != -1:
					self.waypointObject = savage.getGameObject(e.targetId);
				else:
					self.waypointObject = None;
Ejemplo n.º 3
0
    def __init__(self, what, who, where):
        self.playerId = who
        player = savage.getGameObject(who)
        team = savage.getTeamObject(player.getTeam())

        race = team.getRace() + "s"
        msg = player.getFormattedName() + " " + what + " the " + race
        CommAlert.__init__(self, self.PRIORITY, self.RATE, msg)
        self.text.setFont(fontSizeSmall)
        self.text.setX(5)

        self.pic.setVisible(False)
Ejemplo n.º 4
0
    def onEvent(self, e):
        #if isinstance(e, GameEvent):
        #con_println(str(e));
        #pass;
        # CommanderEvents

        if e.eventType == "under_attack":
            where = e.pos
            what = e.sourceId
            # Is it the CommandCenter?
            cc = savage.getLocalTeam().getCommandCenter()
            if cc.objectId == what:
                self.ccAlert.rebuild()
                self.ccAlert.flash()
                #Flash CommandCenter alert!
                return

            for alert in self.alertQueue:
                if isinstance(alert, AttackAlert):
                    if alert.buildingId == e.sourceId:
                        alert.expire()

            alert = AttackAlert(what, where)
            self.insertAlert(alert)

        # GameEvents
        elif e.eventType == "research_complete":
            objtype = savage.ObjectType(e.objtype)
            source = savage.getGameObject(e.sourceId)
            alert = ResearchAlert(objtype, source)
            self.insertAlert(alert)

        elif e.eventType == "player_join" or e.eventType == "player_leave":
            for alert in self.alertQueue:
                if isinstance(alert, ConnectionAlert):
                    if alert.playerId == e.sourceId:
                        alert.expire()

            what = "joined" if e.eventType == "player_join" else "left"
            alert = ConnectionAlert(what, e.sourceId, e.targetId)
            self.insertAlert(alert)

        elif e.eventType == "request_powerup" or e.eventType == "request_gold" or e.eventType == "request_promote":
            for alert in self.alertQueue:
                if isinstance(alert, RequestAlert):
                    if alert.playerId == e.sourceId:
                        alert.expire()

            alert = RequestAlert(e.sourceId, e.eventType, e.parameter)
            self.insertAlert(alert)
Ejemplo n.º 5
0
    def __init__(self, who, what, p):

        self.playerId = who
        self.parameter = p
        self.reqtype = what

        self.player = savage.getGameObject(who)
        team = savage.Team(self.player.getTeam())
        objtype = savage.getObjectType(p)

        prio = self.PRIORITY if not self.player.isOfficer(
        ) else self.PRIORITY + 10
        CommAlert.__init__(self, prio, self.RATE, "")

        self.text.setX(self.pic.getWidth() + 2)

        self.pos = self.player.getPosition()

        self.approvebtn = DefaultImageButton()
        self.approvebtn.setImage("yestr.s2g")
        self.approvebtn.setId("approve")
        self.approvebtn.setSize(32, 32)
        self.approvebtn.addActionListener(self)
        self.content.add(self.approvebtn,
                         self.content.getWidth() - 70, "center")

        self.denybtn = DefaultImageButton()
        self.denybtn.setImage("canceltr.s2g")
        self.denybtn.setId("deny")
        self.denybtn.setSize(32, 32)
        self.denybtn.addActionListener(self)
        self.content.add(self.denybtn,
                         self.content.getWidth() - 35, "center")

        self.btn.setSize(
            self.content.getWidth() -
            (self.content.getWidth() - self.approvebtn.getX()),
            self.content.getHeight())

        self.text.setCaption(self.player.getName())

        if what == "request_powerup":
            self.pic.setImage(objtype.getValue("icon") + ".s2g")
        elif what == "request_gold":
            self.pic.setImage("/gui/game/images/gold_icon.s2g")
        elif what == "request_promote":
            self.pic.setImage("/models/" + team.getRace() +
                              "/items/icons/officer1.tga")
        self.pic.setSize(self.content.getHeight(), self.content.getHeight())
Ejemplo n.º 6
0
    def __init__(self, what, where):
        CommAlert.__init__(self, self.PRIORITY, self.RATE,
                           "We're under attack")

        building = savage.getGameObject(what)
        self.pos = where
        if not set(self.pos) - set((0, 0)):
            # Maybe something went wrong, double check:
            self.pos = (building.getPosition()[0], building.getPosition()[1])

        self.buildingId = what

        self.pic.setImage("../../../" + building.getType().getValue("icon") +
                          ".s2g")
        self.pic.setSize(self.content.getHeight(), self.content.getHeight())
Ejemplo n.º 7
0
	def getBuilder(self):
		return savage.getGameObject(self.builder);
Ejemplo n.º 8
0
 def getTarget(self):
     import savage
     return savage.getGameObject(self.targetId)
Ejemplo n.º 9
0
 def getSource(self):
     import savage
     return savage.getGameObject(self.sourceId)
Ejemplo n.º 10
0
	def getOwner(self):
		return savage.getGameObject(savage.go_getowner(self.objectId));
Ejemplo n.º 11
0
	def getInflictor(self):
		if self.inflictor == -1:
			return None;
		return savage.getGameObject(self.inflictor);