Print Page | Close Window

Immune Status Effect

Printed From: Mirage Source
Category: Tutorials
Forum Name: Submitted Tutorials
Forum Discription: Tutorial submissions for MSE are posted here, waiting for approval
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=117
Printed Date: 20 December 2006 at 6:03pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Immune Status Effect
Posted By: Sync
Subject: Immune Status Effect
Date Posted: 11 February 2006 at 2:15pm
Originally posted by Falchion

I found this useful, it will turn your character invulnerable for 30 seconds. Let's begin client-side, shall we?

ModTypes - PlayerRec - Anywhere in the rec

Status As Byte


ModTypes - Sub ClearPlayer - Bottom of sub

Player(Index).Status = 0


Now, on to frmMirage. Add a new timer called tmrStatus with an interval of 1000. Make sure it is disabled. Double click said timer and add this as it's code.

Private Sub tmrStatus_Timer()
       Call SendData("status" & Player(MyIndex).Status)
End Sub


ModGameLogic - Sub GameInit - Before InitDirectX

frmMirage.tmrStatus.Enabled = True


Woohoo! Client-side finished. Pat yourself on the back and let's head server-side. This is where it's handled and checked whether or not the player can be attacked. Let's get to it.

ModTypes - PlayerRec - Anywhere in the rec

Status As Byte


ModGeneral - Declarations

Public ImmuneTime As Integer


ModGeneral - Sub InitServer - Top of sub

ImmuneTime = 30


ModServerTCP - Sub HandleData - Anywhere

' :::::::::::::::::::
    ' :: Status Packet ::
    ' :::::::::::::::::::
    If LCase(Parse(0)) = "status" Then
        ' Status number
        n = Val(Parse(1))
       
        If Player(index).Char(index).Status > 0 And ImmuneTime > 0 Then
             ImmuneTime = ImmuneTime - 1
        Else
             Player(index).Char(index).Status = 0
             ImmuneTime = 30
        End If
        Exit Sub
    End If



ModGameLogic - New Sub - Anywhere in the module

Function CanBeAttacked(ByVal Victim As Long) As Boolean
   CanBeAttacked = False
  
   ' Check for subscript out of range
   If IsPlaying(Victim) = False Then
       CanBeAttacked = False
       Exit Function
   End If

   ' Make sure they have more then 0 hp
   If GetPlayerHP(Victim) <= 0 Then
       CanBeAttacked = False
       Exit Function
   End If
  
   ' Make sure we dont attack the player if they are switching maps
   If Player(Victim).GettingMap = YES Then
       CanBeAttacked = False
       Exit Function
   End If
  
   If Player(Victim).Char(Victim).Status = 2 Then
       CanBeAttacked = False
   Else
       CanBeAttacked = True
   End If
End Function


Almost done! Two more things to go! Keep at it!

Function CanAttackPlayer, above this line:

' Make sure they are on the same map


Add this:

If CanBeAttacked(Victim) = False Then
      Call PlayerMsg(Attacker, GetPlayerName(Victim) & " is immune to all attacks!", BrightRed)
      Exit Function
End If


Function CanNPCAttackPlayer, above this line:

' Make sure we dont attack the player if they are switching maps


Add this:

If CanBeAttacked(Victim) = False Then
      Exit Function
End If


Now, how you trigger it is up to you. You can have a new spell type set their status to immune, have a potion do it, or something else. It's up to you to put this to use. I've done the hard stuff for you. I hope you use this and enjoy it. I know I will.



Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info