def OFFSHOP_OnUpdate(self): if constInfo.SHOP_MOVE_FLAG: import background, chr, player x, y, z = background.GetPickingPoint() net.offshopx = int(x) net.offshopy = int(y) chr.SelectInstance(constInfo.SHOP_LAST_VID) if 0 != z: chr.SetPixelPosition(int(x), int(y), int(z)) else: chr.SetPixelPosition(int(x), int(y))
def __MakeCharacter(self, race, x, y): nonplayer.GetEventType(1) nonplayer.GetGradeByVID(1) nonplayer.GetLevelByVID(100) nonplayer.GetMonsterName("SeMa Test") nonplayer.LoadNonPlayerData() chr.CreateInstance(race) chr.SetInstanceType(chr.INSTANCE_TYPE_NPC) chr.SelectInstance(race) chr.SetVirtualID(race) chr.SetRace(1) chr.SetNameString("Test SeMa") chr.Refresh() #chr.SetMotionMode(chr.MOTION_MODE_GENERAL) #chr.SetLoopMotion(chr.MOTION_MODE_GENERAL) chr.SetPixelPosition(x, y) chr.SetDirection(chr.DIR_SOUTHEAST) chr.SetMoveSpeed(300) chr.Render() grp.RestoreViewport() grp.PopState() grp.SetInterfaceRenderState() chr.Show()
def OnUpdate(self): chr.Update() for i in xrange(4): self.curGauge[i] += (self.destGauge[i] - self.curGauge[i]) / 10.0 if abs(self.curGauge[i] - self.destGauge[i]) < 0.005: self.curGauge[i] = self.destGauge[i] self.GaugeList[i].SetPercentage(self.curGauge[i], 1.0) for i in xrange(self.CHARACTER_TYPE_COUNT): self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0 self.NameList[i].SetAlpha(self.curNameAlpha[i]) for i in xrange(self.SLOT_COUNT): if FALSE == chr.HasInstance(i): continue chr.SelectInstance(i) distance = 50.0 rotRadian = self.curRotation[i] * (math.pi * 2) / 360.0 x = distance * math.sin(rotRadian) + distance * math.cos(rotRadian) y = distance * math.cos(rotRadian) - distance * math.sin(rotRadian) chr.SetPixelPosition(int(x), int(y), 30) ##### dir = app.GetRotatingDirection(self.destRotation[i], self.curRotation[i]) rot = app.GetDegreeDifference(self.destRotation[i], self.curRotation[i]) if app.DEGREE_DIRECTION_RIGHT == dir: self.curRotation[i] += rot / 10.0 elif app.DEGREE_DIRECTION_LEFT == dir: self.curRotation[i] -= rot / 10.0 self.curRotation[i] = (self.curRotation[i] + 360.0) % 360.0 ####################################################### if -1 != self.startIndex: ## Temporary ## BackGroundLoading이 지원 될때까지 임시로.. if app.GetTime() - self.startReservingTime > 3.0: if FALSE == self.openLoadingFlag: chrSlot = self.stream.GetCharacterSlot() net.DirectEnter(chrSlot) self.openLoadingFlag = TRUE playTime = net.GetAccountCharacterSlotDataInteger( self.slot, net.ACCOUNT_CHARACTER_SLOT_PLAYTIME) import player player.SetPlayTime(playTime) import chat chat.Clear() ## 들어갈때 Chat 을 초기화. 임시 Pos.
def OnUpdate(self): chr.Update() (xposEventSet, yposEventSet) = self.textBoard.GetGlobalPosition() event.UpdateEventSet(self.descIndex, xposEventSet+7, -(yposEventSet+7)) self.descriptionBox.SetIndex(self.descIndex) for i in xrange(SLOT_COUNT[self.gender]): self.curNameAlpha[i] += (self.destNameAlpha[i] - self.curNameAlpha[i]) / 10.0 self.NameList[self.gender][i].SetAlpha(self.curNameAlpha[i]) for i in xrange(4): self.curGauge[i] += (self.destGauge[i] - self.curGauge[i]) / 10.0 if abs(self.curGauge[i] - self.destGauge[i]) < 0.005: self.curGauge[i] = self.destGauge[i] self.GaugeList[i].SetPercentage(self.curGauge[i], 1.0) for page in xrange(PAGE_COUNT): for i in xrange(SLOT_COUNT[page]): chr.SelectInstance(self.__GetSlotChrID(page, i)) distance = 50.0 rotRadian = self.curRotation[i] * (math.pi*2) / 360.0 x = distance*math.sin(rotRadian) + distance*math.cos(rotRadian) y = distance*math.cos(rotRadian) - distance*math.sin(rotRadian) chr.SetPixelPosition(int(x), int(y), 30) if abs(self.destRotation[i] - self.curRotation[i]) < 1.0: self.curRotation[i] = self.destRotation[i] dir = app.GetRotatingDirection(self.destRotation[i], self.curRotation[i]) rot = app.GetDegreeDifference(self.destRotation[i], self.curRotation[i]) if app.DEGREE_DIRECTION_RIGHT == dir: self.curRotation[i] += rot / 10.0 elif app.DEGREE_DIRECTION_LEFT == dir: self.curRotation[i] -= rot / 10.0 self.curRotation[i] = (self.curRotation[i] + 360.0) % 360.0 ########################################################### if -1 != self.reservingRaceIndex: if app.GetTime() - self.reservingStartTime >= 1.5: chrSlot=self.stream.GetCharacterSlot() textName = self.editCharacterName.GetText() raceIndex = self.reservingRaceIndex shapeIndex = self.reservingShapeIndex startStat = self.START_STAT[self.reservingRaceIndex] statCon = self.stat[0] - startStat[0] statInt = self.stat[1] - startStat[1] statStr = self.stat[2] - startStat[2] statDex = self.stat[3] - startStat[3] net.SendCreateCharacterPacket(chrSlot, textName, raceIndex, shapeIndex, statCon, statInt, statStr, statDex) self.reservingRaceIndex = -1
def TeleportToPosition(dst_x, dst_y, max_packets=MAX_TELEPORT_PACKETS): """ Teleport to a position by using pathfinding and telporting in multiple small steps. max_packets allows to avoid spamming the server and crash by putting a limit on maximum number of packets sent. Args: dst_x ([float]): Destination X dst_y ([float]): Destination Y max_packets ([int], optional): Number maximum of positions packets to send. Defaults to MAX_TELEPORT_PACKETS. Returns: [int]: Returns the number of State packets sent. """ if STATE_MOVING == Movement.state: StopMovement() x, y, z = player.GetMainCharacterPosition() points = net_packet.FindPath(x, y, dst_x, dst_y) if len(points) == 0: return None #chat.AppendChat(3,"Teleporting to X->" + str(dst_x) + " Y->" + str(dst_y) + " Distance->" + str(OpenLib.dist(x,y,dst_x,dst_y)) + " Number of Points ->"+ str(len(points))) curr_x, curr_y = (x, y) dest_last_x, dest_last_y = points[0] counter = 0 for point in points: dest1_x, dest1_y = point counter_, pos = TeleportStraightLine(curr_x, curr_y, dest_last_x, dest_last_y, max_packets - counter) counter += counter_ if counter >= max_packets: chr.SetPixelPosition(pos[0], pos[1]) chat.AppendChat(3, str(counter) + " packets sent.") app.sleep(TELEPORT_WAIT_TIME) return max_packets + TeleportToPosition(dst_x, dst_y, max_packets) curr_x, curr_y = (dest_last_x, dest_last_y) dest_last_x, dest_last_y = point counter_, pos = TeleportStraightLine(curr_x, curr_y, dest_last_x, dest_last_y, max_packets - counter) counter += counter_ chat.AppendChat(3, str(counter) + " packets sent.") chr.SetPixelPosition(pos[0], pos[1]) return counter
def TeleportInDirection(self, direction): (x, y, z) = player.GetMainCharacterPosition() if direction == 1: trueX = x trueY = y - 2400 elif direction == 2: trueX = x trueY = y - 2400 elif direction == 3: trueX = x + 2400 trueY = y elif direction == 4: trueX = x - 2000 trueY = y chr.SetPixelPosition(int(trueX), int(trueY), int(z)) net_packet.SendStatePacket(trueX, trueY, 0, net_packet.CHAR_STATE_STOP, 0)