Hi all,
after getting an old version of gcc finally and an there for old version of redhat SimpleMud was finally able to be compiled under linux. Since i am new to programming Muds i have been playing around with SimpleMUD and trying to understand how it works(which so far has gone very well). Now for fun i have been implementing new features like being randomly ported to some room if you give in a specific command or implementing new directions to walk etc.
I have been trying to get a pvp system on the basis of the attack system from SimpleMUD implemented and so far it hasn't been very successful. All what i can do right now is attack the first player in the room. my question is how can i pick a specific player that will be given in by the attacking player for example "attack Thorbenn" and then Thorbenn should be attacked.
Here is the code:
after getting an old version of gcc finally and an there for old version of redhat SimpleMud was finally able to be compiled under linux. Since i am new to programming Muds i have been playing around with SimpleMUD and trying to understand how it works(which so far has gone very well). Now for fun i have been implementing new features like being randomly ported to some room if you give in a specific command or implementing new directions to walk etc.
I have been trying to get a pvp system on the basis of the attack system from SimpleMUD implemented and so far it hasn't been very successful. All what i can do right now is attack the first player in the room. my question is how can i pick a specific player that will be given in by the attacking player for example "attack Thorbenn" and then Thorbenn should be attacked.
Here is the code:
void Game::PVP(const string& p_player )
{
Player& e = *m_player;
area r = e.CurrentRoom();
sint64 now = Game::GetTimer().GetMS();
std::list<player>::iterator itr;
for (itr = r->Players().begin(); itr != r->Players().end(); itr++)
{
Player& p = **itr;
break;
} // end of for loop
Player& p = **itr;
int damage;
if( e.Weapon() == 0 )
{
damage = BasicLib::RandomInt( 1, 3 );
e.NextAttackTime() = now + seconds( 1 );
}
else
{
damage = BasicLib::RandomInt( e.Weapon()->Min(), e.Weapon()->Max() );
e.NextAttackTime() = now + seconds( e.Weapon()->Speed() );
}
if( BasicLib::RandomInt( 0, 99 ) >= e.GetAttr(ACCURACY) - p.GetAttr( DODGING ) )
{
Game::SendRoom(newline + yellow + e.Name() + " slashes at " + p.Name() +
" but misses!", e.CurrentRoom() );
return;
}
damage += e.GetAttr(STRIKEDAMAGE);
damage -= p.GetAttr( DAMAGEABSORB );
if( damage < 1 )
damage = 1;
p.AddHitpoints( -damage );
Game::SendRoom(newline + red + e.Name() + " hits " + p.Name() + " and inflicts " +
tostring( damage ) + " damage!", e.CurrentRoom() );
if( p.HitPoints() <= 0 )
PlayerKilled( p.ID() );
}