Inheritance: Thing
Exemplo n.º 1
0
 public override void process(Actor obj)
 {
     if(obj.getType()==ThingType.OBJECT_CHARACTER)
     {
         GameState.enqueueWarp((Character)(obj), mMap, mX, mY);
     }
 }
Exemplo n.º 2
0
        public void insert(Actor obj)
        {
            ThingType type=obj.getType();

            if(type==ThingType.OBJECT_CHARACTER)
            {
                if(nbCharacters!=nbMovingObjects)
                {
                    if(nbMovingObjects!=objects.Count)
                    {
                        objects.Add(objects[nbMovingObjects]);
                        objects[nbMovingObjects]=objects[nbCharacters];
                    }
                    else
                    {
                        objects.Add(objects[nbCharacters]);
                    }

                    objects[nbCharacters]=obj;
                    ++nbCharacters;
                    ++nbMovingObjects;
                    //break;
                }
                ++nbCharacters;
            }

            if(type==ThingType.OBJECT_CHARACTER||type==ThingType.OBJECT_MONSTER||type==ThingType.OBJECT_NPC)
            {
                if(nbMovingObjects!=objects.Count)
                {
                    objects.Add(objects[nbMovingObjects]);
                    objects[nbMovingObjects]=obj;
                    ++nbMovingObjects;
                    //break;
                }
                ++nbMovingObjects;
            }

            objects.Add(obj);

            //            //Original ohne code
            //            switch(type)
            //            {
            //                case ThingType.OBJECT_CHARACTER:
            //                    {
            //
            //                    } // no break!
            //                case ThingType.OBJECT_MONSTER:
            //                case ThingType.OBJECT_NPC:
            //                    {
            //
            //                    } // no break!
            //                default:
            //                    {
            //                    }
            //            }
        }
Exemplo n.º 3
0
        static Actor findActorNear(Actor p, int id)
        {
            //MapComposite *map = p.getMap();
            //const Point &ppos = p.getPosition();
            //// See map.h for tiles constants
            //const int pixelDist = DEFAULT_TILE_LENGTH * TILES_TO_BE_NEAR;
            //for (ActorIterator i(map.getAroundPointIterator(ppos, pixelDist)); i; ++i)
            //{
            //    Actor *a = *i;
            //    if (a.getPublicID() != id)
            //        continue;
            //    return ppos.inRangeOf(a.getPosition(), pixelDist) ? a : 0;
            //}
            //return 0;

            return null; //ssk
        }
Exemplo n.º 4
0
 void insert(Actor obj)
 {
     //int type = obj.getType();
     //switch (type)
     //{
     //    case OBJECT_CHARACTER:
     //    {
     //        if (nbCharacters != nbMovingObjects)
     //        {
     //            if (nbMovingObjects != objects.size())
     //            {
     //                objects.push_back(objects[nbMovingObjects]);
     //                objects[nbMovingObjects] = objects[nbCharacters];
     //            }
     //            else
     //            {
     //                objects.push_back(objects[nbCharacters]);
     //            }
     //            objects[nbCharacters] = obj;
     //            ++nbCharacters;
     //            ++nbMovingObjects;
     //            break;
     //        }
     //        ++nbCharacters;
     //    } // no break!
     //    case OBJECT_MONSTER:
     //    case OBJECT_NPC:
     //    {
     //        if (nbMovingObjects != objects.size())
     //        {
     //            objects.push_back(objects[nbMovingObjects]);
     //            objects[nbMovingObjects] = obj;
     //            ++nbMovingObjects;
     //            break;
     //        }
     //        ++nbMovingObjects;
     //    } // no break!
     //    default:
     //    {
     //        objects.push_back(obj);
     //    }
     //}
 }
Exemplo n.º 5
0
        static void sayTo(Actor destination, Actor source, string text)
        {
            //if (destination.getType() != OBJECT_CHARACTER)
            //    return; //only characters will read it anyway

            //MessageOut msg(GPMSG_SAY);
            //if (source == NULL)
            //{
            //    msg.writeInt16(0);
            //}
            //else if (!source.canMove())
            //{
            //    msg.writeInt16(65535);
            //}
            //else
            //{
            //    msg.writeInt16(static_cast< Actor * >(source).getPublicID());
            //}
            //msg.writeString(text);

            //gameHandler.sendTo(static_cast< Character * >(destination), msg);
        }
Exemplo n.º 6
0
        static void sayAround(Actor obj, string text)
        {
            //Point speakerPosition = obj.getPosition();
            //int visualRange = Configuration::getValue("game_visualRange", 448);

            //for (CharacterIterator i(obj.getMap().getAroundActorIterator(obj, visualRange)); i; ++i)
            //{
            //    if (speakerPosition.inRangeOf((*i).getPosition(), visualRange))
            //    {
            //        sayTo(*i, obj, text);
            //    }
            //}
        }
Exemplo n.º 7
0
 public static void enqueueRemove(Actor ptr)
 {
     //DelayedEvent e = { EVENT_REMOVE, 0, 0, 0 };
     //enqueueEvent(ptr, e);
 }
Exemplo n.º 8
0
 static void enqueueInsert(Actor ptr)
 {
     //DelayedEvent e = { EVENT_INSERT, 0, 0, 0 };
     //enqueueEvent(ptr, e);
 }
Exemplo n.º 9
0
        /**
         * Enqueues an event. It will be executed at end of update.
         */
        static void enqueueEvent(Actor ptr, DelayedEvent e)
        {
            delayedEvents.Add(ptr, e);

            //TODO Implementieren und in Originalimplementation schauen
            //            // Delete events take precedence over other events.
            //            if(e!=null&&e.type==Event.EVENT_REMOVE)
            //            {
            //                p.first.second.type=Event.EVENT_REMOVE;
            //            }
        }
Exemplo n.º 10
0
        //MapContent::~MapContent()
        //{
        //    for (int i = 0; i < 256; ++i)
        //    {
        //        delete buckets[i];
        //    }
        //    delete[] zones;
        //}
        public bool allocate(Actor obj)
        {
            // First, try allocating from the last used bucket.
            ObjectBucket b=buckets[last_bucket];
            int i=b.allocate();
            if(i>=0)
            {
                b.objects[i]=obj;
                obj.setPublicID(last_bucket*256+i);
                return true;
            }

            /* If the last used bucket is already full, scan all the buckets for an
               empty place. If none is available, create a new bucket. */
            for(i=0; i<256; ++i)
            {
                b=buckets[i];
                if(b!=null)
                {
                    /* Buckets are created in order. If there is nothing at position i,
                       there will not be anything in the next positions. So create a
                       new bucket. */
                    b=new ObjectBucket();
                    buckets[i]=b;
                    Logger.Write(LogLevel.Debug, "New bucket created");
                }
                int j=b.allocate();
                if(j>=0)
                {
                    last_bucket=i;
                    b.objects[j]=obj;
                    obj.setPublicID(last_bucket*256+j);
                    return true;
                }
            }

            // All the IDs are currently used, fail.
            Logger.Write(LogLevel.Error, "unable to allocate id");
            return false;
        }
Exemplo n.º 11
0
        public void remove(Actor obj)
        {
            ////List< Actor >::iterator i_beg = objects.begin(), i, i_end;

            //ThingType type = obj.getType();

            //switch (type)
            //{
            //    case ThingType.OBJECT_CHARACTER:
            //    {
            //        i = i_beg;
            //        i_end = objects.begin() + nbCharacters;
            //    } break;
            //    case ThingType.OBJECT_MONSTER:
            //    case ThingType.OBJECT_NPC:
            //    {
            //        i = objects.begin() + nbCharacters;
            //        i_end = objects.begin() + nbMovingObjects;
            //    } break;
            //    default:
            //    {
            //        i = objects.begin() + nbMovingObjects;
            //        i_end = objects.end();
            //    }
            //}

            //i = std::find(i, i_end, obj);
            ////assert(i != i_end);
            //uint pos = i - i_beg;

            //if (pos < nbCharacters)
            //{
            //    objects[pos] = objects[nbCharacters - 1];
            //    pos = nbCharacters - 1;
            //    --nbCharacters;
            //}

            //if (pos < nbMovingObjects)
            //{
            //    objects[pos] = objects[nbMovingObjects - 1];
            //    pos = nbMovingObjects - 1;
            //    --nbMovingObjects;
            //}

            //objects[pos] = objects[objects.size() - 1];
            //objects.pop_back();
        }
Exemplo n.º 12
0
        ZoneIterator getAroundActorIterator(Actor obj, int radius)
        {
            //MapRegion r;
            //mContent.fillRegion(r, obj.getPosition(), radius);
            //return ZoneIterator(r, mContent);

            return null; //ssk
        }
Exemplo n.º 13
0
        bool start(Actor actor)
        {
            //if (mItems.empty())
            //{
            //    cancel();
            //    return false;
            //}

            //MessageOut msg(mSell ? GPMSG_NPC_SELL : GPMSG_NPC_BUY);
            //msg.writeInt16(actor.getPublicID());
            //for (TradedItems::const_iterator i = mItems.begin(),
            //     i_end = mItems.end(); i != i_end; ++i)
            //{
            //    msg.writeInt16(i.itemId);
            //    msg.writeInt16(i.amount);
            //    msg.writeInt16(i.cost);
            //}
            //mChar.getClient().send(msg);
            return true;
        }
Exemplo n.º 14
0
 /**
  * Enqueues an event. It will be executed at end of update.
  */
 static void enqueueEvent(Actor ptr, DelayedEvent e)
 {
     //std::pair< DelayedEvents::iterator, bool > p =
     //    delayedEvents.insert(std::make_pair(ptr, e));
     //// Delete events take precedence over other events.
     //if (!p.second && e.type == EVENT_REMOVE)
     //{
     //    p.first.second.type = EVENT_REMOVE;
     //}
 }
Exemplo n.º 15
0
        int damage(Actor source, Damage damage)
        {
            //    if (mAction == DEAD)
            //        return 0;

            //    int HPloss = damage.base;
            //    if (damage.delta)
            //        HPloss += rand() * (damage.delta + 1) / RAND_MAX;

            //    // TODO magical attacks and associated elemental modifiers
            //    switch (damage.type)
            //    {
            //        case DAMAGE_PHYSICAL:
            //            if (!damage.trueStrike &&
            //                rand()%((int) getModifiedAttribute(ATTR_DODGE) + 1) >
            //                    rand()%(damage.cth + 1))
            //            {
            //                HPloss = 0;
            //                // TODO Process triggers for a dodged physical attack here.
            //                // If there is an attacker included, also process triggers for the attacker (failed physical strike)
            //            }
            //            else
            //            {
            //                HPloss = HPloss * (1.0 - (0.0159375f *
            //                                          getModifiedAttribute(ATTR_DEFENSE)) /
            //                                   (1.0 + 0.017 *
            //                                    getModifiedAttribute(ATTR_DEFENSE))) +
            //                         (rand()%((HPloss >> 4) + 1));
            //                // TODO Process triggers for receiving damage here.
            //                // If there is an attacker included, also process triggers for the attacker (successful physical strike)
            //            }
            //            break;
            //        case DAMAGE_MAGICAL:
            //#if 0
            //            getModifiedAttribute(BASE_ELEM_BEGIN + damage.element);
            //#else
            //            LOG_WARN("Attempt to use magical type damage! This has not been"
            //                      "implemented yet and should not be used!");
            //            HPloss = 0;
            //#endif
            //        case DAMAGE_DIRECT:
            //            break;
            //        default:
            //            LOG_WARN("Unknown damage type '" << damage.type << "'!");
            //            break;
            //    }

            //    if (HPloss > 0)
            //    {
            //        mHitsTaken.push_back(HPloss);
            //        Attribute &HP = mAttributes.at(ATTR_HP);
            //        LOG_DEBUG("Being " << getPublicID() << " suffered " << HPloss
            //                  << " damage. HP: "
            //                  << HP.getModifiedAttribute() << "/"
            //                  << mAttributes.at(ATTR_MAX_HP).getModifiedAttribute());
            //        setAttribute(ATTR_HP, HP.getBase() - HPloss);
            //        // No HP regen after being hit if this is set.
            //        setTimerSoft(T_B_HP_REGEN,
            //                     Configuration::getValue("game_hpRegenBreakAfterHit", 0));
            //    }
            //    else
            //    {
            //        HPloss = 0;
            //    }

            //    return HPloss;

            return 0;
        }
Exemplo n.º 16
0
 public abstract void process(Actor obj);