示例#1
0
void psClientDR::HandleDeadReckon( MsgEntry* me )
{
    psDRMessage drmsg(me,0,msgstrings,psengine->GetEngine() );
    GEMClientActor* gemActor = (GEMClientActor*)celclient->FindObject( drmsg.entityid );
     
    if (!gemActor)
    {
        csTicks currenttime = csGetTicks();
        if (currenttime - lastquery > 750)
        {
            lastquery = currenttime;
        }

        Error2("Got DR message for unknown entity %s.", ShowID(drmsg.entityid));
        return;
    }

    if (!msgstrings)
    {
        Error1("msgstrings not received, cannot handle DR");
        return;
    }

    // Ignore any updates to the main player...psForcePositionMessage handles that.
    if (gemActor == celclient->GetMainPlayer())
    {
        psengine->GetModeHandler()->SetModeSounds(drmsg.mode);
        return;
    }

    // Set data for this actor
    gemActor->SetDRData(drmsg);
}
示例#2
0
bool pawsPetStatWindow::SetupDoll()
{
    pawsObjectView* widget = dynamic_cast<pawsObjectView*>(FindWidget("Doll"));
    GEMClientActor* actor = target;
    if (!widget || !actor)
        return false;

    csRef<iMeshWrapper> mesh = actor->GetMesh();
    if (!mesh)
    {
        return false;
    }

    // Set the doll view
    widget->View( mesh );

    // Register this doll for updates
    widget->SetID(actor->GetEID().Unbox());

    csRef<iSpriteCal3DState> spstate = scfQueryInterface<iSpriteCal3DState> (widget->GetObject()->GetMeshObject());
    if (spstate)
    {
        // Setup cal3d to select random 0 velocity anims
        spstate->SetVelocity(0.0,&psengine->GetRandomGen());
    }

    charApp->SetMesh(widget->GetObject());
    charApp->ApplyTraits(actor->traits);
    charApp->ApplyEquipment(actor->equipment);

    widget->EnableMouseControl(true);

    return (true);
}
void pawsGroupWindow::Draw()
{
    GEMClientActor* player = psengine->GetCelClient()->GetMainPlayer();

    player->GetVitalMgr()->Predict( csGetTicks(),"Self" );

    if (memberList->GetRowCount()>0)
        SetStats( player );
    pawsWidget::Draw();
}
void psEntityLabels::RefreshGuildLabels()
{
    const csPDelArray<GEMClientObject>& entities = celClient->GetEntities();
    for (size_t i=0; i < entities.GetSize(); i++)
    {
        GEMClientActor* actor = dynamic_cast<GEMClientActor*>(entities.Get(i));
        if ( actor && csString(actor->GetGuildName()).Length() )
            OnObjectArrived(actor);
    }
}
示例#5
0
void psClientCharManager::HandleAction( MsgEntry* me )
{
    psUserActionMessage action(me);
    GEMClientActor* actor = dynamic_cast<GEMClientActor*>(cel->FindObject(action.target));
    if (actor)
    {
        if ( !actor->SetAnimation(action.action) )
            Error2("Error playing animation %s!", action.action.GetData() );
    }
    else
        Error1("Received psUserActionMessage for invalid object.");
}
示例#6
0
void psClientDR::HandleOverride( MsgEntry* me )
{
    psOverrideActionMessage msg(me);
    if (!msg.valid)
        return;

    GEMClientActor* gemActor = (GEMClientActor*)celclient->FindObject(msg.entity_id);
    if (!gemActor)
        return;

    gemActor->SetAnimation( msg.action.GetData(), msg.duration );
}
示例#7
0
void psClientCharManager::SetTarget(GEMClientObject *newTarget, const char *action, bool notifyServer)
{

if(!lockedTarget)
{
    if (target != newTarget)
    {
        target = newTarget;

        GEMClientActor* gemActor = dynamic_cast<GEMClientActor*>(newTarget);
        if (gemActor)
            PawsManager::GetSingleton().Publish("sTargetName",gemActor->GetName(false) );
        else
        {
            PawsManager::GetSingleton().Publish("sTargetName",target?target->GetName():"" );
            PawsManager::GetSingleton().Publish("fVitalValue0:Target",0);
        }
    }

    // delete the old target effect
    psengine->GetEffectManager()->DeleteEffect(targetEffect);
    targetEffect = 0;

    EID mappedID;

    // Action locations don't have effects
    if (target && target->GetObjectType() != GEM_ACTION_LOC)
    {
         // render the target effect
         csRef<iMeshWrapper> targetMesh = target->GetMesh();
         if (targetMesh)
             targetEffect = psengine->GetEffectManager()->RenderEffect("target", csVector3(0,0,0), targetMesh);

         // notify the server of selection
         mappedID = target->GetEID();
    }

    // if it's a message sent by server, there is no need to resend back the same information
    if (notifyServer)
    {
        psUserActionMessage userAction(0, mappedID, action);
        userAction.SendMessage();
    }
}
}
示例#8
0
bool pawsInventoryWindow::SetupDoll()
{
    pawsObjectView* widget = dynamic_cast<pawsObjectView*>(FindWidget("InventoryDoll"));
    if (widget)
    {
        GEMClientActor* actor = psengine->GetCelClient()->GetMainPlayer();
        if (!actor)
            return false;

        while(!widget->ContinueLoad())
        {
            csSleep(100);
        }

        // Set the doll view
        while(!widget->View(actor->GetFactName()))
        {
            csSleep(100);
        }

        CS_ASSERT(widget->GetObject()->GetMeshObject());

        // Set the charApp.
        widget->SetCharApp(charApp);

        // Register this doll for updates
        widget->SetID(actor->GetEID().Unbox());

        csRef<iSpriteCal3DState> spstate = scfQueryInterface<iSpriteCal3DState> (widget->GetObject()->GetMeshObject());
        if (spstate)
        {
            // Setup cal3d to select random 0 velocity anims
            spstate->SetVelocity(0.0,&psengine->GetRandomGen());
        }

        charApp->Clone(actor->CharAppearance());
        charApp->SetMesh(widget->GetObject());

        charApp->ApplyTraits(actor->traits);
        charApp->ApplyEquipment(actor->equipment);
    }
    return true;
}
示例#9
0
void psClientCharManager::ChangeTrait( MsgEntry* me )
{
    psTraitChangeMessage mesg(me);
    EID objectID = mesg.target;

    GEMClientActor *actor = dynamic_cast<GEMClientActor*>(psengine->GetCelClient()->FindObject(objectID));
    if (!actor)
    {
        Error2("Got trait change for %s, but couldn't find it!", ShowID(objectID));
        return;
    }

    // Update main object
    //psengine->BuildAppearance( object->pcmesh->GetMesh(), mesg.string );
    actor->CharAppearance()->ApplyTraits(mesg.string);

    // Update any doll views registered for changes
    csArray<iPAWSSubscriber*> dolls = PawsManager::GetSingleton().ListSubscribers("sigActorUpdate");
    for (size_t i=0; i<dolls.GetSize(); i++)
    {
        if (dolls[i] == NULL)
            continue;
        pawsObjectView* doll = dynamic_cast<pawsObjectView*>(dolls[i]);

        if (doll == NULL)
            continue;
        if (doll->GetID() == objectID.Unbox()) // This is a doll of the updated object
        {
            iMeshWrapper* dollObject = doll->GetObject();
            if (dollObject == NULL)
            {
                Error2("Cannot update registered doll view with ID %d because it has no object", doll->GetID());
                continue;
            }
            psCharAppearance* p = doll->GetCharApp();
            p->Clone(actor->CharAppearance());
            p->SetMesh(dollObject);
            p->ApplyTraits(mesg.string);
        }
    }
}
示例#10
0
void psClientDR::HandleStatsUpdate( MsgEntry* me )
{
    psStatDRMessage statdrmsg(me);
    GEMClientActor* gemObject  = (GEMClientActor*)celclient->FindObject( statdrmsg.entityid );
    if (!gemObject)
    {
        Error2("Stat request failed because CelClient not ready for %s", ShowID(statdrmsg.entityid));
        return;
    }

    // Dirty short cut to allways display 0 HP when dead.
    if (!gemObject->IsAlive() && statdrmsg.hp)
    {
//printf("clientdr 275 dead");
        Error1("Server report HP but object is not alive");
        statdrmsg.hp = 0;
        statdrmsg.hp_rate = 0;
    }
    
    // Check if this client actor was updated
    GEMClientActor* mainActor = celclient->GetMainPlayer();
    
    if (mainActor == gemObject)
    {
        gemObject->GetVitalMgr()->HandleDRData(statdrmsg,"Self");
    }        
    else 
    {   // Publish Vitals data using EntityID
        csString ID;
        ID.Append(gemObject->GetEID().Unbox());
        gemObject->GetVitalMgr()->HandleDRData(statdrmsg, ID.GetData() );
    }

    //It is not an else if so Target is always published
    if (psengine->GetCharManager()->GetTarget() == gemObject)
        gemObject->GetVitalMgr()->HandleDRData(statdrmsg,"Target"); 
    
    if (mainActor != gemObject && gemObject->IsGroupedWith(celclient->GetMainPlayer()) )
    {
        if (!groupWindow)
        {
            // Get the windowMgr

            pawsWidget* widget = PawsManager::GetSingleton().FindWidget("GroupWindow");
            groupWindow = (pawsGroupWindow*)widget;

            if (!groupWindow) 
            {
                Error1("Group Window Was Not Found. Bad Error");
                return;
            }
        }
        
        groupWindow->SetStats(gemObject);
    }
}
示例#11
0
bool pawsSkillWindow::SetupDoll()
{
    pawsObjectView* widget = dynamic_cast<pawsObjectView*>(FindWidget("Doll"));
    GEMClientActor* actor = psengine->GetCelClient()->GetMainPlayer();
    if (!widget || !actor)
    {
        return true; // doll not wanted, not an error
    }

    // Set the doll view
    while(!widget->View(actor->GetFactName()))
    {
        continue;
    }

    CS_ASSERT(widget->GetObject()->GetMeshObject());

    // Set the charApp.
    widget->SetCharApp(charApp);

    // Register this doll for updates
    widget->SetID(actor->GetEID().Unbox());

    csRef<iSpriteCal3DState> spstate = scfQueryInterface<iSpriteCal3DState> (widget->GetObject()->GetMeshObject());
    if (spstate)
    {
        // Setup cal3d to select random 0 velocity anims
        spstate->SetVelocity(0.0,&psengine->GetRandomGen());
    }

    charApp->SetMesh(widget->GetObject());

    charApp->ApplyTraits(actor->traits);
    charApp->ApplyEquipment(actor->equipment);

    widget->EnableMouseControl(true);

    //return (a && e);
    return true;
}
示例#12
0
void psClientCharManager::HandleEquipment(MsgEntry* me)
{
    psEquipmentMessage equip(me);
    unsigned int playerID = equip.player;

    GEMClientActor* object = (GEMClientActor*)cel->FindObject(playerID);
    if (!object)
    {
        Error2("Got equipment for actor %d, but couldn't find it!", playerID);
        return;
    }

    Debug2(LOG_CELPERSIST,0,"Got equipment for actor %d", playerID);


    csString slotname(psengine->slotName.GetName(equip.slot));

    //If the mesh has a $ it means it's an helm ($H) / bracher ($B) / belt ($E) / cloak ($C) so search for replacement
    equip.mesh.ReplaceAll("$H",object->helmGroup);
    equip.mesh.ReplaceAll("$B",object->BracerGroup);
    equip.mesh.ReplaceAll("$E",object->BeltGroup);
    equip.mesh.ReplaceAll("$C",object->CloakGroup);

    // Update any doll views registered for changes
    csArray<iPAWSSubscriber*> dolls = PawsManager::GetSingleton().ListSubscribers("sigActorUpdate");
    for (size_t i=0; i<dolls.GetSize(); i++)
    {
        if (dolls[i] == NULL)
            continue;
        pawsObjectView* doll = dynamic_cast<pawsObjectView*>(dolls[i]);

        if (doll == NULL)
            continue;
        if (doll->GetID() == playerID) // This is a doll of the updated object
        {
            iMeshWrapper* dollObject = doll->GetObject();
            if (dollObject == NULL)
            {
                Error2("Cannot update registered doll view with ID %d because it has no object", doll->GetID());
                continue;
            }
            psCharAppearance* p = doll->GetCharApp();
            p->Clone(object->CharAppearance());
            p->SetMesh(dollObject);
            if (equip.type == psEquipmentMessage::EQUIP)
            {
                p->Equip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture,equip.removedMesh);
            }
            else
            {
                p->Dequip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture,equip.removedMesh);
            }
        }
    }

    // Update the actor
    if (equip.type == psEquipmentMessage::EQUIP)
    {
        object->CharAppearance()->Equip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture,equip.removedMesh);
    }
    else
    {
        object->CharAppearance()->Dequip(slotname,equip.mesh,equip.part,equip.partMesh,equip.texture,equip.removedMesh);
    }
}
void psEntityLabels::SetObjectText(GEMClientObject* object)
{
    if ( !object )
    {
        Warning1( LOG_ANY, "NULL object passed..." );
        return;
    }

    int colour = entityColors[ENTITY_DEFAULT];  // Default color, on inanimate objects
    if ( object->IsAlive() )
    {
        int type = object->GetMasqueradeType();
        if (type > 26)
            type = 26;

        switch ( type )    
        {
            default:
            case 0: // player or unknown group
                colour = entityColors[ENTITY_PLAYER];
                break;

            case -1: // NPC
                colour = entityColors[ENTITY_NPC];
                break;
            case -3: // DEAD
                colour = entityColors[ENTITY_DEAD];
                break;

            case 10: // Tester
                colour = entityColors[ENTITY_TESTER];
                break;
            case 21: // GM1
                colour = entityColors[ENTITY_GM1];
                break;            

            case 22:
            case 23:
            case 24:
            case 25: // GM2-5
                colour = entityColors[ENTITY_GM25];
                break;

            case 26: // dev char
                colour = entityColors[ENTITY_DEV];
                break;
        }                    
    }

    // Is our object an actor?
    GEMClientActor* actor = dynamic_cast<GEMClientActor*>(object);

    // Grouped with have other color
    bool grouped = false;
    if (actor && actor->IsGroupedWith(celClient->GetMainPlayer()))
    {
      colour = entityColors[ENTITY_GROUP];
      grouped = true;
    }

    // White colour labels for invisible objects should overide all (for living objects)
    int flags = object->Flags();
    bool invisible = object->IsAlive() && (flags & psPersistActor::INVISIBLE);
    
    if ( invisible )
    {
        colour = 0xffffff;                    
    }

    psEffectTextRow nameRow;
    psEffectTextRow guildRow;

    nameRow.text = object->GetName();
    nameRow.align = ETA_CENTER;
    nameRow.colour = colour;
    nameRow.hasShadow = false;
    nameRow.hasOutline = true;
    nameRow.outlineColour = 0;

    if (actor && showGuild)
    {
        csString guild( actor->GetGuildName() );
        csString guild2( psengine->GetGuildName() );

        if ( guild.Length() )
        {
            // If same guild, indicate with color, unless grouped or invisible
            if (guild == guild2 && !invisible && !grouped)
                colour = entityColors[ENTITY_GUILD];

            guildRow.text = "<" + guild + ">";
            guildRow.align = ETA_CENTER;
            guildRow.colour = colour;
            guildRow.hasShadow = false;
            guildRow.hasOutline = true;
            guildRow.outlineColour = 0;
        }
    }

    // Apply
    psEffect* entityLabel = object->GetEntityLabel();
    if(!entityLabel)
    {
        // Weird case
        Error2("Lost entity label of object %s!",object->GetName());
        return;
    }

    psEffectObjTextable* txt = entityLabel->GetMainTextObj();
    if(!txt)
    {
        // Ill-modded effect
        Error1("Effect 'entitylabel' has no text object");
        return;
    }

    size_t nameCharCount = nameRow.text.Length();
    size_t guildCharCount = guildRow.text.Length();
    size_t maxCharCount = nameCharCount > guildCharCount ? nameCharCount : guildCharCount;
    float scale = sqrt((float)maxCharCount) / 4.0f;

    // Finally set the text, with a black outline
    if (guildRow.text.Length())
    {
        txt->SetText(2, &nameRow, &guildRow);
        scale *= 1.5f;
    }
    else
    {
        txt->SetText(1, &nameRow);
    }        

    entityLabel->SetScaling(scale, 1.0f);
}