Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ MUDs
➜ General
➜ Implementing new functions to SimpleMUD
Implementing new functions to SimpleMUD
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Thorbenn
(25 posts) Bio
|
Date
| Mon 28 Nov 2011 06:00 PM (UTC) Amended on Wed 30 Nov 2011 11:13 AM (UTC) by Thorbenn
|
Message
| 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:
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() );
}
| Top |
|
Posted by
| Nick Gammon
Australia (23,070 posts) Bio
Forum Administrator |
Date
| Reply #1 on Tue 29 Nov 2011 08:06 PM (UTC) |
Message
| |
Posted by
| Thorbenn
(25 posts) Bio
|
Date
| Reply #2 on Wed 30 Nov 2011 11:10 AM (UTC) Amended on Wed 30 Nov 2011 11:12 AM (UTC) by Thorbenn
|
Message
| yes it is the same question :) sorry. The reason why i opened a thread is because maybe someone would more likely react to this than the one with the header how to get the mud to compile.
what i would like to know is how to get the name of the player when someone types the command and then the name. this is where i have troubles understanding how it gets the name. because the method which is used to whisper something to someone does something similar but doesn't work in the attack method.
is it possible by Players() to see if it where a player at the position of itr that gets counted higher in the for loop? i get the number that is input for the position of the player and then this player is attacked.
the question would be there again how do i read the input number and save it to an helping integer that then is looked for in the for loop.
for example
somehow get the input
int number= input;
for (itr = r->Players().begin(); itr != r->Players().end(); itr++)
{
if(itr==input)
{
break;
}
}
in a way like this just how to get the input is my question | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
12,151 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top