[RP] Block

Status
Not open for further replies.

Kieren

The OGz
Aug 4, 2010
2,957
752
Look for 'internal int _breakTime;'. After that add:
PHP:
internal bool _isBlocking;

Look for 'private Thread workoutDosLooper;'. After that add:
PHP:
private Thread blockCooldown;

Look for 'private void punchCoolDown()'. After that void add:
PHP:
private void blockCoolDown()
        {
            int iCount = 0;
            try
            {
                while (true)
                {
                    using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                    {
                        iCount++;
                        if (iCount > 15)
                        {
                            blockCooldown = null;
                            blockCooldown.Abort();
                        }
                        Thread.Sleep(1000);
                    }
                }
            }
            catch
            {
                Thread.CurrentThread.Abort();
                blockCooldown = null;
            }
        }

Add this void:
PHP:
private void stopBlocking()
        {
            Thread.Sleep(3000);
            Room.sendSaying(roomUser, "*moves out of defensive stance*");
            _isBlocking = false;
            roomUser.walkLock = false;
            ThreadStart blockCdStarter = new ThreadStart(blockCoolDown);
            blockCooldown = new Thread(blockCdStarter);
            blockCooldown.Priority = ThreadPriority.Lowest;
            blockCooldown.Start();
        }
Add this command:
PHP:
#region :block
                    case "block":
                        {
                            if (blockCooldown != null)
                            {
                                _isBlocking = true;
                                Room.sendSaying(roomUser, "*goes into a defensive stance to sustain impact*");
                                roomUser.walkLock = true;
                                stopBlocking();
                            }
                            else
                            {
                                Room.sendWhisper(roomUser, _Username, "You must wait to go into block stance again");
                            }
                            break;
                        }
                    #endregion
After 'int hit = str_mod * hit_dif_0 + hit_dif_1;' put:
PHP:
if (User._isBlocking == true)
                                                        {
                                                            User.Room.sendShout(User.roomUser, "*blocks the hit of " + _Username + "*");
                                                            if (hit <= 10)
                                                                hit = 0;
                                                            else
                                                                hit = hit - 10;
                                                        }

Before 'Room.sendShout(roomUser, "*Swings at " + args[1] + ", causing " + hit + " damage*");' add:
PHP:
if (hit > 0)

Credits: ProffAwesome

(No screen shots were released, sorry)

Details: This command is to block any target that tries the :hit command for RP hotels.
 

Kieren

The OGz
Aug 4, 2010
2,957
752
If you look closely to the code it actually gives it away you can go :block when fighting but when you throw a punch your block will go and you will not be able to go :block again for a while.
 
Status
Not open for further replies.

Users who are viewing this thread

Top