void PlayerOctopus::update() { if (isActive() && _character) { // update position based on cell //LOGINFO << "Position: " << getPosition() << endl; if (!real_cell) teleport(real_cell = _character->getCell()); else if (!move_wanted) { teleport(real_cell = destination_cell); moving = false; pathNext(); } else if (real_cell != destination_cell && _land_time + move_delay < TIMESERVICE->time()) { //LOGINFO << "Moving" << endl; // delta time in milliseconds Uint32 dt = (TIMESERVICE->time() - movement_begin); Point origin_pos = toContainerCoordinates(_grid->toAbsoluteCoordinates(_grid->getCellCenter(real_cell))); Point dest_pos = toContainerCoordinates(_grid->toAbsoluteCoordinates(_grid->getCellCenter(destination_cell))); Point delta = abs(origin_pos - dest_pos); Point middle = (origin_pos - dest_pos) / 2; Point step = ((dest_pos - origin_pos) * dt)/move_time; // jump Point jump(0, sqrt(pow(jump_height, 2) - (pow(jump_height,2) * abs(delta.y - step.y))/pow( delta.y, 2))); Point pos = origin_pos + step - jump; Point newPos = pos + getPadding(); step = abs(step); if (step.x >= delta.x && step.y >= delta.y) { //LOGINFO << "Landing on new cell" << endl; newPos = dest_pos + getPadding(); real_cell = destination_cell; moving = false; _grid->unmark(destination_cell->getNumber()); pathNext(); } setPosition(newPos); } // update z-index setZIndex(_grid->getZIndexFromCell(destination_cell->getNumber())); } }
void cBoat::PlankStuff(UOXSOCKET s, P_ITEM pi_plank)//If the plank is opened, double click Will send them here { P_CHAR pc_cs,pc_b; pc_cs = currchar[s]; P_ITEM boat = GetBoat(pc_cs); if(boat == NULL)//They aren't on a boat, so put then on the plank. { // LB, bugfix for tillerman not reacting if the boat was entered via plank ! // we need to get the boat again after beaming the character to the boat's plank // otherweise only -1's will be added to the boat hash-table pc_cs->moveTo(pi_plank->pos + Coord_cl(0,0,5)); pc_cs->multis=-3; // we have to trick getboat to start the search !!! // will be corrected automatically by setserial... P_ITEM boat2 = GetBoat(pc_cs); if (boat2 == NULL) return; unsigned int a; vector<SERIAL> vecCown = cownsp.getData(pc_cs->serial); for(a = 0; a < vecCown.size(); a++)//Put all their Pets/Hirlings on the boat too { pc_b = FindCharBySerial(vecCown[a]); if (pc_b != NULL) // never log -1's that indicate non existance !!! { if (pc_b->isNpc() && pc_cs->Owns(pc_b)) { pc_b->moveTo(boat2->pos + Coord_cl(1, 1, 2)); pc_b->SetMultiSerial(boat2->serial); teleport(pc_b); } } } OpenPlank(pi_plank); //lb if (boat2 != NULL) // now set the char coords to the boat !!! { pc_cs->moveTo(boat2->pos + Coord_cl(1, 1, 2)); } sysmessage(s,"you entered a boat"); pc_cs->SetMultiSerial(boat2->serial); } else { LeaveBoat(s, pi_plank);//They are on a boat, get off } teleport(pc_cs);//Show them they moved. }
TRIGGER( use )(obj user) { int Q5A2 = getObjType(this); loc Q4VS = loc( getLocation(user) ); loc there = loc( getLocation(this) ); int Q4IL = getDistanceInTiles(Q4VS, there); if(Q4IL > 0x02) { bark(user, "I am too far away to do that."); return(0x00); } int Q4Q1; switch(Q5A2) { case 0x0A53: setType(this, 0x0A52); callback(this, 0x0A, 0x26); break; case 0x0A4F: setType(this, 0x0A4E); callback(this, 0x0A, 0x26); break; case 0x0A51: setType(this, 0x0A50); callback(this, 0x0A, 0x26); break; case 0x0A4D: setType(this, 0x0A4C); callback(this, 0x0A, 0x26); break; case 0x0A52: setType(this, 0x0A53); Q4Q1 = teleport(this, getLocation(this)); break; case 0x0A4E: setType(this, 0x0A4F); Q4Q1 = teleport(this, getLocation(this)); break; case 0x0A50: setType(this, 0x0A51); Q4Q1 = teleport(this, getLocation(this)); break; case 0x0A4C: setType(this, 0x0A4D); Q4Q1 = teleport(this, getLocation(this)); break; default: break; } return(0x01); }
TRIGGER( use )(obj user) { obj player = user; if(!hasObjVar(this, "bountyPlayer")) { systemMessage(user, "Select player to bounty:"); targetObj(user, this); return(0x00); } string Q5IU = "PD BugKiller"; if(hasObjVar(this, "bountyPlayerName")) { Q5IU = getObjVar(this, "bountyPlayerName"); } systemMessage(user, "creating bounty for (" + objtoint(player) + "."); obj bountyInfo = createNoResObjectAt(0x01, getLocation(user)); setObjVar(bountyInfo, "subject", player); attachScript(bountyInfo, "bountyinfo"); list args = list( player, 0x029A, 0x00, Q5IU ); message(bountyInfo, "addBounty", args); int Q4Q1 = teleport(bountyInfo, getRelayLoc(player)); if(isValid(bountyInfo)) { clearList(args); message(bountyInfo, "teleported", args); } args = list( getAdjFame(user) ); systemMessage(user, "MurderReport: Messaging via probe to " + objtoint(user) + "."); Q56V(player, "murderReport", args); obj head = createNoResObjectIn(0x1DA0, getBackpack(user)); setObjVar(head, "nameVar", Q5IU); setObjVar(head, "controller", player); return(0x00); }
bool teleToCaster(Blob* caster,const int& cursorWorldX,const int& cursorWorldY){ Blob* blob; Tile* tile = BlobGame::instance()->getLevel()-> getTileForPosition(cursorWorldX,cursorWorldY); if((blob = BlobGame::instance()->blobOnTile(tile))){ Tile* startTile = caster->getCurrentTile(); Tile* targetTiles[8] = { AdjacentTileLeft(startTile,BlobGame::instance()->getLevel()), AdjacentTileRight(startTile,BlobGame::instance()->getLevel()), AdjacentTileTop(startTile,BlobGame::instance()->getLevel()), AdjacentTileBottom(startTile,BlobGame::instance()->getLevel()), AdjacentTileTopLeft(startTile,BlobGame::instance()->getLevel()), AdjacentTileTopRight(startTile,BlobGame::instance()->getLevel()), AdjacentTileBottomLeft(startTile,BlobGame::instance()->getLevel()), AdjacentTileBottomRight(startTile,BlobGame::instance()->getLevel()) }; for(int i = 0;i < 8;i++){ if(targetTiles[i] && !ContainsFlags(targetTiles[i]->getTileTypes(),BLOB_UNWALKABLES)){ teleport(blob,targetTiles[i]->getPositionX(),targetTiles[i]->getPositionY()); return true; } } } return false; }
int DoConnect (char *host, int port) { char buff[2]; Client *c; /**/ printf("Connect request from %hhu.%hhu.%hhu.%hhu:%u\n", host[0],host[1],host[2],host[3], port); printf("Assigning clientId: %d\n", clientID); /**/ clientID++; buff[0]=0; buff[1]=(char)clientID; c = new Client; c->id = clientID; c->address = strndup(host, 4); c->port = port; c->it = (clients.size()==0); teleport(c); clients.push_back(c); return send(host, port, buff, 2); }
char *teleport_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr) { //static char *teleport[] = { (char *)teleport_func, "teleport", "V", "NXT", "secret", "amount", "dest", "coin", "minage", 0 }; double amount; int32_t M,N; struct coin_info *cp; char NXTACCTSECRET[512],destaddr[512],minage[512],coinstr[512],*retstr = 0; if ( Historical_done == 0 ) return(clonestr("historical processing is not done yet")); copy_cJSON(NXTACCTSECRET,objs[1]); amount = get_API_float(objs[2]); copy_cJSON(destaddr,objs[3]); copy_cJSON(coinstr,objs[4]); copy_cJSON(minage,objs[5]); M = get_API_int(objs[6],1); N = get_API_int(objs[7],1); if ( M > N || N >= 0xff || M <= 0 ) M = N = 1; printf("amount.(%.8f) minage.(%s) %d | M.%d N.%d\n",amount,minage,atoi(minage),M,N); cp = get_coin_info(coinstr); if ( cp != 0 && sender[0] != 0 && amount > 0 && valid != 0 && destaddr[0] != 0 ) retstr = teleport(sender,NXTACCTSECRET,(uint64_t)(SATOSHIDEN * amount),destaddr,cp,atoi(minage),M,N); else retstr = clonestr("{\"error\":\"invalid teleport request\"}"); return(retstr); }
void cBoat::TurnStuff(P_ITEM pBoat, P_CHAR pc_i, int dir)//Turn an item that was on the boat when the boat was turned. { if (pc_i == NULL) return; int dx = pc_i->pos.x - pBoat->pos.x; int dy = pc_i->pos.y - pBoat->pos.y; mapRegions->Remove(pc_i); pc_i->pos.x = pBoat->pos.x; pc_i->pos.y = pBoat->pos.y; if(dir) { pc_i->pos.x+=dy*-1; pc_i->pos.y+=dx; } else { pc_i->pos.x+=dy; pc_i->pos.y+=dx*-1; } //Set then in their new cell mapRegions->Add(pc_i); teleport((pc_i)); }
///////////// // Name: reverseIncognito // Purpose: undo the effects of the incognito spell // History: by AntiChrist // isolated from two functions by Duke, 10.6.2001 // static void reverseIncognito(P_CHAR pc) { if(pc->incognito)//let's ensure it's under incognito effect! { pc->setId(pc->xid); pc->skin = pc->xskin; // SKIN COLOR pc->name = pc->orgname; // NAME if(pc->hairserial>-1)//if hairs exist, restore hair style/color { P_ITEM pHair = FindItemBySerial(pc->hairserial); if(pHair) { if(pHair->incognito) //let's ensure it was marked as under incognito effect { //stores old hair values pHair->color = static_cast<unsigned short>(pHair->moreb1 << 8) + pHair->moreb2; pHair->id1=pHair->moreb3; pHair->id2=pHair->moreb4; pHair->incognito=false; } } } if(pc->beardserial>-1)//if beard exists, restore beard style/color { P_ITEM pBeard = FindItemBySerial(pc->beardserial); if(pBeard) { if(pBeard->incognito) //let's ensure it was marked as under incognito effect { //restores old beard values pBeard->color = static_cast<unsigned short>(pBeard->moreb1<<8) + pBeard->moreb2; pBeard->id1=pBeard->moreb3; pBeard->id2=pBeard->moreb4; pBeard->incognito=false; } } } //only refresh once, when poly finished teleport(pc); int socket=calcSocketFromChar(pc);//calculate only once if (socket!=-1) { wornitems(socket, pc);//send update to current socket int j; for (j=0; j<now; j++) { //and to all inrange sockets (without re-sending to current socket)//AntiChrist if (perm[j] && inrange1p(pc, currchar[j]) && (j!=socket)) wornitems(j, pc); } } pc->incognito=false;//AntiChrist } }
/*! \brief Changes the orientation of a player \author Flameeyes \param p Point to face to */ void cChar::facexy(sPoint p) { uint8_t olddir = dir; dir = getDirFromXY(p); if ( dir != olddir ) teleport(teleNone); }
FUNCTION void Q4E8(obj user, obj Q66M, int Q4QY, string name) { if(isAtHome(this)) { systemMessage(user, "You can't use that, it belongs to someone else."); return; } int Q66P = getObjType(Q66M); if(Q4Z2(Q66P)) { if(!testSkill(user, 0x0D)) { systemMessage(user, "You burn the food to a crisp! It's ruined."); destroyOne(this); return; } if(name != "default") { if(hasObjVar(this, "NAME")) { removeObjVar(this, "NAME"); setObjVar(this, "NAME", name); } } if(random(0x00, 0x01)) { barkTo(user, user, "Looks delicious."); } else { barkTo(user, user, "Mmmm, smells good."); } obj Q47F = getBackpack(user); int Q4TM; obj Q5CN = createGlobalObjectOn(this, Q4QY); if(!isInContainer(this)) { if(canHold(Q47F, Q5CN)) { Q4TM = putObjContainer(Q5CN, Q47F); systemMessage(user, "You put the cooked food into your backpack."); } else { Q4TM = teleport(Q5CN, getLocation(user)); systemMessage(user, "You put the cooked food on the ground."); } } destroyOne(this); } else { systemMessage(user, "You can't cook on that."); } return; }
void ActionTeleport::executeImp (const Ptr& actor) { if (mTeleportFollowers) { //find any NPC that is following the actor and teleport him too std::set<MWWorld::Ptr> followers; getFollowers(actor, followers); for(std::set<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();++it) { MWWorld::Ptr follower = *it; if (Ogre::Vector3(follower.getRefData().getPosition().pos).squaredDistance( Ogre::Vector3( actor.getRefData().getPosition().pos)) <= 800*800) teleport(*it); } } teleport(actor); }
int teleport_to(string place) { object destination = load_object(resolve_path(previous_object()->query_cwd(), place)); if (!destination) { return error_out("Could not load object " + place); } return teleport(previous_object(), destination); }
void cTmpEff::Reverse() { int s = calcCharFromSer(getDest()); P_CHAR pc_s = MAKE_CHARREF_LR(s); switch(num) { case 1: pc_s->priv2 &= 0xFD; break; case 2: pc_s->fixedlight='\xFF';break; case 3: pc_s->chgDex(more1); break; case 4: pc_s->in+=more1; break; case 5: pc_s->st+=more1; break; case 6: pc_s->chgDex(-1 * more1);break; case 7: pc_s->in-=more1; break; case 8: pc_s->st-=more1; break; case 11: pc_s->st-=more1; pc_s->chgDex(-1 * more2); pc_s->in-=more3; break; case 12: pc_s->st+=more1; pc_s->chgDex(more2); pc_s->in+=more3; break; case 18: //Polymorph spell by AntiChrist if(pc_s->polymorph) { pc_s->id1=pc_s->xid1; pc_s->id2=pc_s->xid2; pc_s->polymorph=false; teleport(s); } break; case 19: //Incognito spell by AntiChrist reverseIncognito(pc_s); break; case 21: int toDrop; toDrop = more1; //Effect->more1; if( ( pc_s->baseskill[PARRYING] - toDrop ) < 0 ) pc_s->baseskill[PARRYING] = 0; else pc_s->baseskill[PARRYING] -= toDrop; default: clConsole.send("ERROR: Fallout of switch\n"); //Morrolan return; }//switch Items->CheckEquipment(s); //AntiChrist - checks equipments for stats requirements }
int ImpEntity::hurt(int damages, enumShotType hurtingType, int level, bool critical, int sourceType) { int result = EnemyEntity::hurt(damages, hurtingType, level, critical, sourceType); if (!isDying && !isAgonising) { teleport(); state = 3; changingDelay = 0.4f; } return result; }
void TeleporterSceneNode::OnAnimate(irr::u32 timeMs) { if (!this->dontTeleport) { irr::core::list<irr::scene::ISceneNode*>::Iterator it; //const irr::core::list<irr::scene::ISceneNode*>::ConstIterator it; only works on Linux, mingw on windows doesn't like it irr::core::list<irr::scene::ISceneNode*>::Iterator end; for(it = this->nodesToWatch.begin(); it != end; ++it) { irr::scene::ISceneNode* const node = (*it); if (this->placeA.isPointInside(node->getAbsolutePosition())) { //teleport from A to B teleport(node, this->placeB.getCenter()); } else if (this->viceversa && placeB.isPointInside(node->getAbsolutePosition())) { //teleport from B to A teleport(node, this->placeA.getCenter()); } } } else { this->dontTeleportTimer -= this->demo->getElapsed(); if (this->dontTeleportTimer <= 0) { this->dontTeleport = false; this->whirl[0]->setVisible(true); this->whirl[1]->setVisible(true); } } ISceneNode::OnAnimate(timeMs); }
/** * \brief Search the players and update the position of the camera. * \param elapsed_time Elapsed time since the last call. */ void ptb::shared_camera::progress_no_players ( bear::universe::time_type elapsed_time ) { search_players(); if ( m_first_player!=NULL ) { m_progress = &shared_camera::progress_with_players; if ( m_second_player!=NULL ) teleport ( (m_first_player.hot_spot() + m_second_player.hot_spot()) / 2 ); else teleport( m_first_player.hot_spot() ); } else if ( m_second_player!=NULL ) { m_progress = &shared_camera::progress_with_players; teleport( m_second_player.hot_spot() ); } else progress_zoom(elapsed_time); } // shared_camera::progress_no_players()
void ActionTeleport::executeImp (const Ptr& actor) { if (mTeleportFollowers) { //find any NPC that is following the actor and teleport him too std::set<MWWorld::Ptr> followers; getFollowers(actor, followers); for(std::set<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();++it) { MWWorld::Ptr follower = *it; std::string script = follower.getClass().getScript(follower); if (!script.empty() && follower.getRefData().getLocals().getIntVar(script, "stayoutside") == 1) continue; if ((follower.getRefData().getPosition().asVec3() - actor.getRefData().getPosition().asVec3()).length2() <= 800*800) teleport(*it); } } teleport(actor); }
void ImpEntity::animate(float delay) { if (!isDying && !isAgonising) { if (age < 0.0f) frame = 1; else { changingDelay -= delay; if (changingDelay < 0.0f) { if (state == 0) // flying -> pause { viscosity = 0.965f; state = 1; changingDelay = 0.5f; } else if (state == 1) // pause -> fire -> pause { changingDelay = 0.4f; fire(); state = 2; } else if (state == 2) // pause -> teleport -> pause { teleport(); state = 3; changingDelay = 0.4f; } else if (state == 3) { velocity = Vector2D(creatureSpeed); changingDelay = 1.5f + (float)(rand() % 2500) / 1000.0f; viscosity = 1.0f; state = 0; } } frame = ((int)(age * 5.0f)) % 4; if (frame == 3) frame = 1; } if (impType == ImpTypeBlue) frame += 5; } EnemyEntity::animate(delay); }
void pickup(int n, game::dynent *d) { int np = 1; loopv(players) if (players[i]) np++; np = np<3 ? 4 : (np>4 ? 2 : 3); // spawn times are dependent on number of players int ammo = np*2; switch (ents[n].type) { case I_SHELLS: additem(n, d->ammo[1], ammo); break; case I_BULLETS: additem(n, d->ammo[2], ammo); break; case I_ROCKETS: additem(n, d->ammo[3], ammo); break; case I_ROUNDS: additem(n, d->ammo[4], ammo); break; case I_HEALTH: additem(n, d->health, np*5); break; case I_BOOST: additem(n, d->health, 60); break; case I_GREENARMOUR: // (100h/100g only absorbs 166 damage) if (d->armourtype==A_YELLOW && d->armour>66) break; additem(n, d->armour, 20); break; case I_YELLOWARMOUR: additem(n, d->armour, 20); break; case I_QUAD: additem(n, d->quadmillis, 60); break; case CARROT: ents[n].spawned = false; triggertime = int(lastmillis()); // TODO world::trigger(ents[n].attr1, ents[n].attr2, false); // needs to go over server for client::multiplayer break; case TELEPORT: { static int lastteleport = 0; if (lastmillis()-lastteleport<500) break; lastteleport = int(lastmillis()); teleport(n, d); } break; case JUMPPAD: { static int lastjumppad = 0; if (lastmillis()-lastjumppad<300) break; lastjumppad = int(lastmillis()); vec3f v((int)(char)ents[n].attr3/10.0f, (int)(char)ents[n].attr2/10.0f, ents[n].attr1/10.0f); player1->vel.z = 0; player1->vel += v; sound::playc(sound::JUMPPAD); } break; } }
//------------------------------------------------------------------------------------- PyObject* Entity::pyTeleport(PyObject* nearbyMBRef, PyObject* pyposition, PyObject* pydirection) { if(!PySequence_Check(pyposition) || PySequence_Size(pyposition) != 3) { PyErr_Format(PyExc_Exception, "%s::teleport: %d position not is Sequence!\n", getScriptName(), getID()); PyErr_PrintEx(0); S_Return; } if(!PySequence_Check(pydirection) || PySequence_Size(pydirection) != 3) { PyErr_Format(PyExc_Exception, "%s::teleport: %d direction not is Sequence!\n", getScriptName(), getID()); PyErr_PrintEx(0); S_Return; } Position3D pos; Direction3D dir; PyObject* pyitem = PySequence_GetItem(pyposition, 0); pos.x = (float)PyFloat_AsDouble(pyitem); Py_DECREF(pyitem); pyitem = PySequence_GetItem(pyposition, 1); pos.y = (float)PyFloat_AsDouble(pyitem); Py_DECREF(pyitem); pyitem = PySequence_GetItem(pyposition, 2); pos.z = (float)PyFloat_AsDouble(pyitem); Py_DECREF(pyitem); pyitem = PySequence_GetItem(pydirection, 0); dir.roll = (float)PyFloat_AsDouble(pyitem); Py_DECREF(pyitem); pyitem = PySequence_GetItem(pydirection, 1); dir.pitch = (float)PyFloat_AsDouble(pyitem); Py_DECREF(pyitem); pyitem = PySequence_GetItem(pydirection, 2); dir.yaw = (float)PyFloat_AsDouble(pyitem); Py_DECREF(pyitem); teleport(nearbyMBRef, pos, dir); S_Return; }
TRIGGER( use )(obj user) { int Q4FS = getX(getLocation(this)); int Q4FT = getY(getLocation(this)); int Q4FU = getZ(getLocation(this)); int Q5CG = Q4FU + 0x01; loc Q5C0 = loc( Q4FS, Q4FT, Q5CG ); loc trapLocation = loc( 0x14CB, 0x023C, 0x00 ); list Q5DQ; if(!hasObjVar(this, "working")) { bark(this, "SOUND EFFECT"); callback(this, 0x05, 0x01); int Q64U = teleport(this, Q5C0); messageToRange(trapLocation, 0x0A, "disarm", Q5DQ); setObjVar(this, "working", 0x01); } return(0x01); }
int teleport_player(string player, string place) { object *players = users(); object destination; object victim; string name = player; string room = place; string msg = ""; int index; player = lower_case(player); switch (lower_case(player)) { case "me": case "myself": name = lower_case(previous_object()->query_name()); } switch (lower_case(place)) { case "here": room = file_name(here()); } index = member_array(name, map(players, (: lower_case($1->query_name()) :))); if (index >= 0) { victim = players[index]; } destination = load_object(resolve_path(previous_object()->query_cwd(), room)); if (!victim) { msg = "Could not find player " + player; } if (!destination) { msg += (strlen(msg) ? "\n" : "" ) + "Could not find place " + place; } if (!msg) { return teleport(victim, destination); } return error_out(msg); }
TRIGGER( use )(obj user) { int Q5DQ; loc Q59R = loc( getLocation(this) ); loc Q5H8 = loc( getLocation(user) ); if(getDistanceInTiles(Q59R, Q5H8) > 0x02) { ebarkTo(user, user, "If you had been closer, you might have stepped in and met a gruesome fate!"); return(0x00); } if(hasObjVar(this, "MaidenWorking")) { return(0x00); } if(hasObjVar(this, "MaidenClosed")) { setType(this, 0x1249); removeObjVar(this, "MaidenClosed"); setObjVar(this, "MaidenOpen", Q5DQ); callBack(this, 0x0A, 0x01); ebarkTo(user, user, "Hmm... you suspect that if you used this again, it might hurt."); return(0x00); } if(hasObjVar(this, "MaidenOpen")) { setType(this, 0x124B); removeObjVar(this, "MaidenOpen"); setObjVar(this, "MaidenWorking", Q5DQ); callBack(this, 0x01, 0x03); callBack(this, 0x05, 0x02); int Q69K = getX(Q59R) + 0x01; int Q69T = getY(Q59R) + 0x01; int Q6A2 = getZ(Q59R); loc Q63E = loc( Q69K, Q69T, Q6A2 ); if(!teleport(user, Q59R)) { } loseHP(user, dice(0x0A, 0x03)); return(0x01); } return(0x00); }
int UpdateBoard () { if (clients.size() > 0) { Client *it = NULL; for (int i=0;i<clients.size();i++) { if (clients[i]->it) { it = clients[i]; break; } } assert(it); for (int i=0;i<clients.size();i++) { if (clients[i] != it && closeEnough(clients[i], it)) { clients[i]->it = true; it->it = false; teleport(clients[i]); return 0; } } } return 0; }
Robot::Robot(Adafruit_TCS34725 *colorSensor1, Adafruit_TCS34725 *colorSensor2, float periodAsserv, float x, float y, float theta) : _pidDist(ACTIVE_PID_DISTANCE, KP_DISTANCE, KD_DISTANCE, KI_DISTANCE), _pidOrientation(ACTIVE_PID_ANGLE, KP_ANGLE, KD_ANGLE, KI_ANGLE), _consigneDist(VITESSE_MAX, ACCELARATION_MAX_EN_REEL_LIN, periodAsserv, COEFF_FREINAGE_DIST, DIST_ARRIVE_DIST), _consigneOrientation(VITESSE_MAX_ROT, ACCELARATION_MAX_EN_REEL_ROT, periodAsserv, COEFF_FREINAGE_ANG, DIST_ARRIVE_ANG), _logger(0), _comm(0) { _tourneFini = false; _pingReceived = false; _typeDeplacement = TournePuisAvance; _typeAsserv = Auto; Point point; point.x = x; point.y = y; point.theta = theta; teleport(point); forceObjectif(point); _thetaTotal = 0.0; _deltaDistMm = 0.0; _deltaOrientRad = 0.0; _periodAsserv = periodAsserv; _commandeRoueGauche = MAX_PWM_MOTORS / 2.0; _commandeRoueDroite = MAX_PWM_MOTORS / 2.0; pasPrecendentGauche = 0.0; pasPrecendentDroit = 0.0; _colorSensor[ColorSensor1] = colorSensor1; _colorSensor[ColorSensor2] = colorSensor2; _sens = true; _stopObst = false; coeffDetectionObst = 1; MAJSonar(255, 255, 255, 255); }
bool groupTeleport(Blob* caster,const int& cursorWorldX,const int& cursorWorldY){ Tile* targetTile = BlobGame::instance()->getLevel()-> getTileForPosition(cursorWorldX,cursorWorldY); if(targetTile && !ContainsFlags(targetTile->getTileTypes(),BLOB_UNWALKABLES)){ Tile* startTile = caster->getCurrentTile(); Tile* targetTiles[9] = { targetTile, AdjacentTileTopLeft(targetTile,BlobGame::instance()->getLevel()), AdjacentTileTop(targetTile,BlobGame::instance()->getLevel()), AdjacentTileTopRight(targetTile,BlobGame::instance()->getLevel()), AdjacentTileLeft(targetTile,BlobGame::instance()->getLevel()), AdjacentTileRight(targetTile,BlobGame::instance()->getLevel()), AdjacentTileBottomLeft(targetTile,BlobGame::instance()->getLevel()), AdjacentTileBottom(targetTile,BlobGame::instance()->getLevel()), AdjacentTileBottomRight(targetTile,BlobGame::instance()->getLevel()) }; Tile* startTiles[9] = { startTile, AdjacentTileTopLeft(startTile,BlobGame::instance()->getLevel()), AdjacentTileTop(startTile,BlobGame::instance()->getLevel()), AdjacentTileTopRight(startTile,BlobGame::instance()->getLevel()), AdjacentTileLeft(startTile,BlobGame::instance()->getLevel()), AdjacentTileRight(startTile,BlobGame::instance()->getLevel()), AdjacentTileBottomLeft(startTile,BlobGame::instance()->getLevel()), AdjacentTileBottom(startTile,BlobGame::instance()->getLevel()), AdjacentTileBottomRight(startTile,BlobGame::instance()->getLevel()) }; Blob* blob = NULL; for(int i = 0;i < 9;i++){ if(targetTiles[i] && !ContainsFlags(targetTiles[i]->getTileTypes(),BLOB_UNWALKABLES) && (blob = BlobGame::instance()->blobOnTile(startTiles[i]))){ teleport(blob,targetTiles[i]->getPositionX(),targetTiles[i]->getPositionY()); } } return true; } return false; }
void teleporters(CHARACTER s) { P_CHAR pc_s = MAKE_CHARREF_LR(s); multimap<int, tele_locations_st>::iterator iter_tele_locations; iter_tele_locations = tele_locations.find(pc_s->pos.x); while (pc_s->pos.x == iter_tele_locations->second.origem.x && iter_tele_locations != tele_locations.end()) { if(pc_s->pos.y == iter_tele_locations->second.origem.y) { if((iter_tele_locations->second.origem.z == illegal_z)||(pc_s->pos.z == iter_tele_locations->second.origem.z)) { pc_s->MoveTo(iter_tele_locations->second.destination.x, iter_tele_locations->second.destination.y, iter_tele_locations->second.destination.z); teleport(s); return; } } iter_tele_locations++; } }
int main (int argc, char **argv) { xcb_window_t win; if (argc != 6) usage(argv[0]); init_xcb(&conn); win = strtoul(argv[5], NULL, 16); if (!win) errx(1, "cannot get window"); teleport(win, atoi(argv[1]), atoi(argv[2]), atoi(argv[3]), atoi(argv[4])); xcb_flush(conn); kill_xcb(&conn); return 0; }
void cBoat::Move(UOXSOCKET s, int dir, P_ITEM pBoat) {//Move the boat and all it's items 1 square int tx=0,ty=0; int serial; if (pBoat == NULL) return; serial = calcserial(pBoat->moreb1, pBoat->moreb2, pBoat->moreb3, pBoat->moreb4); if (serial == INVALID_SERIAL) return; P_ITEM pTiller = FindItemBySerial( serial ); if(pTiller == NULL) return; P_ITEM pi_p1 = FindItemBySerial( pBoat->morex ); if(pi_p1 == NULL) return; P_ITEM pi_p2 = FindItemBySerial( pBoat->morey ); if(pi_p2 == NULL) return; P_ITEM pHold = FindItemBySerial( pBoat->morez ); if(pHold == NULL) return; Xsend(s,wppause,2); switch(dir&0x0F)//Which DIR is it going in? { case '\x00' : ty--; break; case '\x01' : tx++; ty--; break; case '\x02' : tx++; break; case '\x03' : tx++; ty++; break; case '\x04' : ty++; break; case '\x05' : tx--; ty++; break; case '\x06' : tx--; break; case '\x07' : tx--; ty--; break; default: { sprintf((char*)temp,"warning: Boat direction error: %i int boat %i\n",pBoat->dir&0x0F,pBoat->serial); LogWarning((char*)temp); break; } } if((pBoat->pos.x+tx<=200 || pBoat->pos.x+tx>=6000) && (pBoat->pos.y+ty<=200 || pBoat->pos.y+ty>=4900)) //bugfix LB { pBoat->type2=0; itemtalk(s, pTiller, "Arr, Sir, we've hit rough waters!"); Xsend(s,restart,2); return; } if(Block(pBoat,tx,ty,dir)) { pBoat->type2=0; itemtalk(s, pTiller, "Arr, somethings in the way!"); Xsend(s,restart,2); return; } //Move all the special items Coord_cl desloc(tx, ty, 0); pBoat->moveTo(pBoat->pos + desloc); pTiller->moveTo(pTiller->pos + desloc); pi_p1->moveTo(pi_p1->pos + desloc); pi_p2->moveTo(pi_p2->pos + desloc); pHold->moveTo(pHold->pos + desloc); serial = pBoat->serial; unsigned int a; vector<SERIAL> vecEntries = imultisp.getData(pBoat->serial); for (a = 0; a < vecEntries.size(); a++) { P_ITEM pi = FindItemBySerial(vecEntries[a]); if(pi != NULL) { pi->MoveTo(pi->pos.x+=tx, pi->pos.y+=ty, pi->pos.z); sendinrange(pi); } } vecEntries.clear(); vecEntries = cmultisp.getData(pBoat->serial); for (a = 0; a < vecEntries.size(); a++) { P_CHAR pc_c = FindCharBySerial(vecEntries[a]); if (pc_c != NULL) { pc_c->moveTo(pc_c->pos + desloc); teleport((pc_c)); } } Xsend(s,restart,2); }