Jump to content

Attack notification


Recommended Posts

Ok and I guess there is no way to set a global variable kind of in JS that holds the user's player id. Then this can be used to check in parts of the JS code ?

What I need is something like bool doesEntityBelongToPlayer(entityid, player id)

I see some of the components call back to the script like:


virtual bool MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)
{
return m_Script.Call<bool>("MoveToTargetRange", target, minRange, maxRange);
}

Maybe if such a function is there in JS that messages.js is using, I could call back there.

Edited by madmax
Link to comment
Share on other sites

I see this in ICmpPlayerManager


/**
* Player manager. This maintains the list of players that exist in the game.
*/
class ICmpPlayerManager : public IComponent
{
public:
virtual void AddPlayer(entity_id_t ent) = 0;
virtual int32_t GetNumPlayers() = 0;
virtual entity_id_t GetPlayerByID(int32_t id) = 0;
DECLARE_INTERFACE_TYPE(PlayerManager)
};

Will try to use it. But then what the user's player id...hmm Maybe it's always 0 or 1 ?

Edited by madmax
Link to comment
Share on other sites

Yes I have the player id now. Hopefully in a multiplayer it will return the player id of the current user's player correctly


case MT_EntityAttacked:
{
const CMessageEntityAttacked& data = static_cast<const CMessageEntityAttacked&> (msg);
if (!g_Game)
break;
int player = g_Game->GetPlayerID();
m_Active = true;
m_X = data.x;
m_Z = data.z;
m_PingEntity = true;
m_PingCount = MAX_PING_FRAMES;
LOGWARNING(L"E:%d, Message received of Attack ! x:%d, z:%d", data.entity, data.x, data.z);
break;
}

Now to verify if the attacked entity belongs to this player. Is it possible to pass the player who was attacked from JS ? Then all I would need to do is a simple comparison.

Edited by madmax
Link to comment
Share on other sites

ok committed the change: https://github.com/l...e56deb19968385d

We do not use the x & z values currently, but they seems to be rather high :


WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166)
WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875)
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166)
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166)
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)
WARNING: User Player:1: Message received of Attack on entity 136 of player 1 at (5811604, 8604536)
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798)

Are they being passed as this high from JS or is it a conversion problem I wonder.

Edited by madmax
Link to comment
Share on other sites

Looks awesome! Only tiny problem I can find is that the ping time seems way too long. The blinking should at most continue a few secs after the entity is no longer being hit.

Are they being passed as this high from JS or is it a conversion problem I wonder.

Hmm. I'm not sure, but I think they are that high. These are 'pixel' or sub-tile positions, not coarse terrain tile positions.

Link to comment
Share on other sites

ok. Whats the time parameter. Is it the number of turns ?


WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:4800
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:5000
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:5000
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:5200
WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:5400
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:5400
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:5400
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:5800
WARNING: User Player:1: Message received of Attack on entity 136 of player 1 at (5811604, 8604536), time:6800
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:7000
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:7200
WARNING: User Player:1: Message received of Attack on entity 33 of player 1 at (5765249, 8206359), time:7400
WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:7400
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:7400
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:7600
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:9000
WARNING: User Player:1: Message received of Attack on entity 89 of player 1 at (7070392, 7018728), time:9200
WARNING: User Player:1: Message received of Attack on entity 135 of player 1 at (5695624, 8374201), time:9400
WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:9400
WARNING: User Player:1: Message received of Attack on entity 35 of player 1 at (5777253, 7678798), time:11000
WARNING: User Player:1: Message received of Attack on entity 33 of player 1 at (5765249, 8206359), time:11400
WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:11400
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:11400
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:11400
WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:11400
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:12600
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:13200
WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:13400
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:13400
WARNING: User Player:1: Message received of Attack on entity 88 of player 1 at (7054144, 7241875), time:15400
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:15400
WARNING: User Player:1: Message received of Attack on entity 87 of player 1 at (7027570, 7654166), time:15400
Engine exited successfully on 2013-04-06 at 15:22:29 with 363 message(s), 0 error(s) and 32 warning(s).

Link to comment
Share on other sites

I seem to be getting an issue where the 'dots' turn black for a while before they begin blinking:

D3PghLd.gif

(Three frames depicted; match start, dot turns black, dot begins blinking.)

Any idea what that might be?

Edited by zoot
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...