Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Class Change not Working


Sessumaru
 Share

Recommended Posts

```

':: Text Color Code ::
'Black = 0
'Blue = 1
'Green = 2
'Cyan = 3
'Red = 4
'Magenta = 5
'Brown = 6
'Grey = 7
'DarkGrey = 8
'BrightBlue = 9
'BrightGreen = 10
'BrightCyan = 11
'BrightRed = 12
'Pink = 13
'Yellow = 14
'White = 15

':: Mini Scripting Explanation :: 
'Writing with ' before it are comments and do not do anything.
'Subs are mini packages of code that run as a group from top to bottom
'You can run subs by calling them. ie call onattack(index) and index would be a player number.
'Dims are boxes for storing data in. You say dim MYSTUFF, then MYSTUFF = "thisword", and you could use MYSTUFF where ever you needed the text "thisword"
'Different commands have different pieces of info you must give to them. See the scripting forum for more help.

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs whenever a new character is created.
'  Warning: This is intended for creating new values, etc. only.
'  The player is NOT logged into the game when this runs, so commands
'  such as PlayerMsg will NOT work

Sub OnNewChar(index, charNum)
        Dim CharName

                CharName = GetPlayerName(index)

                If Len(CharName) >= 12 Then
                    Call SetPlayerName(index, left(CharName, 12))
                End If 
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub is used to run timed events based off the server time. 
Sub TimedEvent(Hours,Minutes,Seconds)     
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    ' If minutes are zero then
If minutes = 0 Then
' If seconds are also zero then
If seconds = 0 Then
' Tell the admins to come check out the forums
Call adminmsg("Dear admins: Dont forget to vote for Krusade Online. We need your support and fresh interest via the vote sites to keep the engine alive and updates continuing...", 14)
End If
End If

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs every time the player hits the ctrl key and attacks.
Sub OnAttack(index)

x = GetPlayerX(index)
y = GetPlayerY(index)
m = GetPlayerMap(index)
Select Case GetPlayerDir(index)
Case 0
y = y - 1
Case 1
y = y + 1
Case 2
x = x - 1
Case 3
x = x + 1
End Select

If GetVar("OneTimeVars.ini", Cstr(m), Cstr(x) & "_" & Cstr(y)) = "1" Then
Call CheckChestStackable(index, x, y)
End If

If GetVar("OneTimeVars.ini", Cstr(m), Cstr(x) & "_" & Cstr(y)) = "0" Then
Call CheckChestNonStackable(index, x, y)
End If

If GetVar("OneTimeVars.ini", Cstr(m), Cstr(x) & "_" & Cstr(y)) = "2" Then
Call CheckChestEquipment(index, x, y)
End If

z = 1
Do While z < 16
If GetNPCX(m, z) = x Then
If GetNPCY(m, z) = y Then
If GetMapNpcHP(m, z) > 0 and GetMapNpcHP(m, z) <> 32767 Then
Call SpellAnim(4, m, x, y)
Exit Sub
End If
End If
End If
z = z + 1
Loop

Call CastCheck(index)

End Sub

'This subs checks all conditions for fishing.
'After checking, it feeds the needed data to the catching sub.
Sub CastCheck(index)

'Get the x and y coordinates of the tile that the player is facing.
x = GetPlayerX(index)
y = GetPlayerY(index)
Select Case GetPlayerDir(index)
  Case 0
    y = y - 1
  Case 1
    y = y + 1
  Case 2
    x = x - 1
  Case 3
    x = x + 1
End Select

'If the player isn't facing a fishable tile, there's no
'need to continue checking. Exit the sub.
If GetVar("scripts\fishing\tiles.ini", CStr(GetPlayerMap(index)) & "_" & CStr(x) & "_" & CStr(y), "Fishable")  = "" Then
  Exit Sub
End If

'If the player doesn't have a weapon equipped, they can't possibly
'be holding their rod. Exit the sub.
If GetPlayerWeaponSlot(index) = 0 Then
  Call PlayerMsg(index, "You need to equip a rod!", 4)
  Exit Sub
End If

'If the player doesn't have a bait selected, exit the sub.
If GetVar("scripts\fishing\players.ini", GetPlayerName(index), "Bait") = "" Then
  Call PlayerMsg(index, "You need to select a bait!", 4)
  Exit Sub
Else
Bait = GetVar("scripts\fishing\players.ini", GetPlayerName(index), "Bait")
End If

'Since they do have a weapon, we check to see if it's a rod.
'Multiple rods are usable.
Maxrods = CLng(GetVar("scripts\fishing\Rods.ini", "Constants", "MaxRods"))
rod = 1
Do While rod <= Maxrods
  If GetPlayerInvItemNum(index, GetPlayerWeaponSlot(index)) = CLng(GetVar("scripts\fishing\Rods.ini", CStr(rod), "Item")) Then
    Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "Rod", CStr(rod))
    Exit Do
  End If
  rod = rod + 1
Loop

'If rod looped all the way through to no avail, they don't have a rod.
'Exit the sub.
If rod = Maxrods + 1 Then
  Exit Sub
End If

'If bait looped all the way through to no avail, they don't have a bait.
'Exit the sub.
If bait = Maxbait + 1 Then
  Exit Sub
End If

'All checks are complete. Feed the data to the catching sub.
Call PlayerMsg(index, "You cast out your line...", 15)
Call SetTimer("CatchCheck " & index & "," & x  & "," & y & "," & bait, 1000)

End Sub

Sub CatchCheck(index, xx, yy, bait)

'Get the x and y coordinates of the tile that the player is facing.
x = GetPlayerX(index)
y = GetPlayerY(index)
Select Case GetPlayerDir(index)
  Case 0
    y = y - 1
  Case 1
    y = y + 1
  Case 2
    x = x - 1
  Case 3
    x = x + 1
End Select

'If the player has moved or turned since the last check, they are no longer fishing.
'Exit the sub and remove the timer
If xx <> x Or yy <> y Then
Call RemoveTimer("CatchCheck " & index & "," & x & "," & y & "," & bait)
  Exit Sub
End If

'The map
m = GetPlayerMap(index)
'The variable uses for looping
check = GetVar("scripts\fishing\players.ini", GetPlayerName(index), "check")
'The bait item number
baitnum = CLng(GetVar("scripts\fishing\Bait.ini", CStr(bait), "Item"))

If check = "" Then
  Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "level", "1")
  Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "exp", "0")
  check = 1
End If

check = CLng(check)

'The player's fishing level and exp
level = CLng(GetVar("scripts\fishing\players.ini", GetPlayerName(index), "level"))
exp = CLng(GetVar("scripts\fishing\players.ini", GetPlayerName(index), "exp"))

'If this is the first check, set up some variables
If check = 1 Then

'Fish variables
Maxfish = CLng(GetVar("scripts\fishing\tiles.ini", CStr(GetPlayerMap(index)) & "_" & CStr(x) & "_" & CStr(y), "MaxFish"))

'Check for level requirement to choose which fish the player might randomly get.
Temp = Maxfish
Do While Temp > 0
  LevelReq = CLng(GetVar("scripts\fishing\fish.ini", GetVar("scripts\fishing\tiles.ini", CStr(GetPlayerMap(index)) & "_" & CStr(x) & "_" & CStr(y), "Fish" & CStr(Temp) & "Num"), "LevelReq"))
  If LevelReq > level Then
    Maxfish = Maxfish - 1
  Else
  Exit Do
  End If
  Temp = Temp - 1
Loop 
Fish = Rand(1, Maxfish)
BaseRoll = Rand(1, 80)
Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "CurrentFish", CStr(Fish))
Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "CurrentChance", CStr(BaseRoll))
End If

BaseRoll = CLng(GetVar("scripts\fishing\players.ini", GetPlayerName(index), "CurrentChance"))
Fish = CLng(GetVar("scripts\fishing\players.ini", GetPlayerName(index), "CurrentFish"))
FishNum = CLng(GetVar("scripts\fishing\tiles.ini", CStr(GetPlayerMap(index)) & "_" & CStr(x) & "_" & CStr(y), "Fish" & CStr(Fish) & "Num"))

'Chance variables and equation

LevelBonus = (level - CLng(GetVar("scripts\fishing\fish.ini", CStr(Fish), "LevelReq"))) * 5
RodBonus = CLng(GetVar("scripts\fishing\rods.ini", GetVar("scripts\fishing\players.ini", GetPlayerName(index), "Rod"), "Bonus"))
Chance = Int((Baseroll - LevelBonus - RodBonus) / (check / 20))
TargetChance = CLng(GetVar("scripts\fishing\tiles.ini", CStr(GetPlayerMap(index)) & "_" & CStr(x) & "_" & CStr(y), "Fish" & CStr(Fish) & "Chance"))

If Chance <= TargetChance Then                                               
  Call PlayerMsg(index, "...and you catch a " & trim(GetItemName(FishNum)) & "!", 15)
Call Quest_Give_Item(index, FishNum, 0)
Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "CurrentFish", "")
Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "check", "1")
Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "CurrentChance", "0")
Exp = Exp + CLng(GetVar("scripts\fishing\fish.ini", CStr(Fish), "Exp"))
Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "Exp", Exp)
If CLng(GetVar("scripts\fishing\players.ini", GetPlayerName(index), "Exp")) > CLng(GetVar("scripts\fishing\experience.ini", "experience", Level)) Then
Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "level", Level + 1)
Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "Exp", Exp -  CLng(GetVar("scripts\fishing\experience.ini", "experience", Level)))
  End If
Call RemoveTimer("CatchCheck " & index & "," & x & "," & y & "," & bait)
  Exit Sub
End If

If check = 20 Then
Call RemoveTimer("CatchCheck " & index & "," & x & "," & y & "," & bait)
Call PlayerMsg(index, "...But the fish aren't biting.", 15)
Exit Sub
End If

check = check + 1
Call PutVar("scripts\fishing\players.ini", GetPlayerName(index), "check", check)
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when any player presses the PageUp key
Sub HotScript1(index)                                           
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'Call SetPlayerSPeed(index, 10)

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when any player presses the Delete key
Sub HotScript2(index)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim diceroll

'Rolling dice script

'diceroll becomes a Random number between 1 and 6
'diceroll=Rand(6,1)
'Call Mapmsg(GetPlayerMap(index), GetPlayerName(index) & " rolls a " & 'Int(diceroll) & " (1-6)", 15)
'Call CustomMenuShow(index, "custom", "\GUI\CUSTOM\test.bmp", 0)
'Call CustomMenuClose(index)

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when players press the End key
Sub HotScript3(index)                                             
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' Telling players the game time
Call playermsg(index, "The time is " & getservertimehour() & ":" & getservertimeminute() & ":" & getservertimesecond() , 14)

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when players press the PageDown key
Sub HotScript4(index)                                           
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' Example of finding an empty inventory slot and giving the player 1 of item 1 :
'If giveplayeritem(index, 1, 1, 0) = 1 Then
'Call playermsg(index,"You magically have one more gold piece.", 10)
'Else
'Call playermsg(index,"Your bag feels too heavy for more gold.", 12)
'End If

' Examples of using text bubbles :
'Call textbubble(index, 1, "These Are",GetPlayerMap(index), 4, 4, 10)
'Call textbubble(index, 2, "All Scripted",GetPlayerMap(index), 6, 6, 10)
'Call textbubble(index, 3, "Text Bubbles",GetPlayerMap(index), 8, 8, 10)
'Call textbubble(index, 4, "Only This",GetPlayerMap(index), 10, 10, 10)
'Call textbubble(index, 5, "Player Sees!",GetPlayerMap(index), 12, 12, 10)
'Call maptextbubble(20, "All players would see this one though.",GetPlayerMap(index), 4, 10, 14)
'Call textbubble(index, 6, "It does have limits in size, three lines is max.",GetPlayerMap(index), 2, 12, 12)

' Example of making a shop run :
'Call goshopping(index,1)

' Example of changing the players guild :
'Call setplayerguildname(index,"Bobzor!")
'Call setplayerguildaccess(index, 1)
'Call sendplayerdata(index)

' Example of changing the spawn type of a map to spawn an NPC, useful for bosses :
'Call ScriptSpawnNpc(15,GetPlayerMap(index),GetPlayerX(index), GetPlayerY(index),1)

' Example of spawning an item on a map just as though it had been dropped :
'Call Spawnitemonmap(GetPlayerMap(index),GetPlayerX(index), GetPlayerY(index),1,15,0)

' Example of locking a player so they cant move :
'Call lockplayer(index,1)

' Example of showing or hiding paperdoll:
'Call HidePlayerPaperdoll(index)
'Call ShowPlayerPaperdoll(index)

' Example of setting player pet:
'Call SetPlayerPet(index, 1)

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when something on a custom menu is clicked. 
Sub MenuScripts(index, Clicked_Index, Menu_Type)         
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Dim field_message
Dim menu_title
menu_title = getplayermenuclicktitle(index)
field_message = getplayermenuclickmsg(index)

' Figure out what type of button was clicked ie picture, textbox, label.
Select Case Menu_Type

Case 1
' PICTURE WAS CLICKED
' Player has clicked a picture box whos number is clicked_index on the custom menu named menu_title
Call playermsg(index, "Clicked  picture number " & clicked_index & " on the menu named " & menu_title, 14)

Case 2
' FIELD WAS CLICKED   
' Player has clicked a text field OK button whos number is clicked_index on the custom menu named menu_title.
Call playermsg(index, "Clicked  field number " & clicked_index & " on the menu named " & menu_title & ". The field text was " & field_message, 14)

Case 3
' LABEL WAS CLICKED
' Player has clicked a label button whos number is clicked_index on the custom menu named menu_title
Call playermsg(index, "Clicked  label number " & clicked_index & " on the menu named " & menu_title, 14)

End Select

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when a player logs into the game.
Sub JoinGame(index) 
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

On Error Resume next
Dim GameName
Dim MOTD
Dim firstjoin

' Load the gamename from the data.ini file into the variable named GameName
GameName = Trim(GetVar("Data.ini", "CONFIG", "GameName"))
' Load the message of the day from the motd.ini file into the variable named MOTD
MOTD = GetVar("motd.ini", "MOTD", "Msg")

    ' Send a global message that he/she joined
    If GetPlayerAccess(index) <= ADMIN_MONITER Then
    ' If the player has less or equal access then a monitor then tell all players they joined
        Call GlobalMsg(GetPlayerName(index) & " has joined " & GameName & "!", 7)
    Else
    ' If the player has greater access then a moniter tell everyone an admin has joined
        Call GlobalMsg("Administrator " & GetPlayerName(index) & " has joined " & GameName & "!", 14)
    End If

    ' Send the player a welcome to the GameName we loaded up earlier
    Call PlayerMsg(index, "Welcome to " & GameName & "!", 15)

    ' Send motd
    If Trim(MOTD) <> "" Then
    ' If MOTD isnt blank then tell the joining player the message loaded earlier
        Call PlayerMsg(index, "MOTD: " & MOTD, 11)
    End If

    ' Check if game is scrolling or non scrolling and change accordingly
If IsScrolling() = 1 Then

    ' Check numbers arent beyond the limits for the map size
If getbootx(index) <= 30 and getbootx(index) >= 0 and getbooty(index) <= 30 and getbooty(index) >= 0 Then
' If numbers are legitimate, warp the player
Call Playerwarp(Index, getbootmap(index), getbootx(Index), getbooty(Index))
End If

Else

    ' Check numbers arent beyond the limits for the map size
If getbootx(index) <= 19 and getbootx(index) >= 0 and getbooty(index) <= 14 and getbooty(index) >= 0 Then
' If numbers are legitimate, warp the player
Call Playerwarp(Index, getbootmap(index), getbootx(Index), getbooty(Index))
End If

End If

' Check for very first join and if it is set the player as server owner and with access level 5

firstjoin = "" & getvar("data.ini", "config", "owner")
If firstjoin = "" Then
Call setplayeraccess(index, 5)
Call playermsg(index, "Congratulations, you have joined your Eclipse server and been given creator ststus. Press F1 to begin editing.", 14)
Call putvar("data.ini", "config", "owner", trim(getplayername(index)) )
End If

'Send Whos Online
Call SendWhosOnline(index)

If GetVar("Data\Core\" & GetPlayerName(index) & ".ini","Join", "First") = "No" Then
Exit Sub
End if

Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss1", "")
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss2", "")
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss3", "")
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss4", "")
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss5", "")
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss6", "")
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss7", "")
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss8", "")
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss9", "")
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss10", "")
Call PutVar("Data\Core\" & GetPlayerName(index) & ".ini", "Join", "First", "No")

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when a player logs out of the game
Sub LeftGame(index)                                             
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim GameName
Dim n
If GetVar("accounts\" & GetPlayerLogin(index) & ".ini", "CHAR" & GetPlayerCharNum(index), "Status") = 1 Then
Call PutVar("Scripts\Command.ini", "TEMP", "Text" & index, "/away")
Call Commands(index)
End If
' Load the gamename from the data.ini file into the variable named GameName
GameName = Trim(GetVar("Data.ini", "CONFIG", "GameName"))

    ' Check if game is scrolling or non scrolling and change accordingly
If IsScrolling() = 1 Then

    ' Check numbers arent beyond the limits for the map size
If getbootmap(index) > 0 and getbootx(index) <= 30 and getbootx(index) >= 0 and getbooty(index) <= 30 and getbooty(index) >= 0 Then
' If numbers are legitimate, warp the player
Call Playerwarp(Index, getbootmap(index), getbootx(Index), getbooty(Index))
End If

Else

    ' Check numbers arent beyond the limits for the map size
If getbootmap(index) > 0 and getbootx(index) <= 19 and getbootx(index) >= 0 and getbooty(index) <= 14 and getbooty(index) >= 0 Then
' If numbers are legitimate, warp the player
Call Playerwarp(Index, getbootmap(index), getbootx(Index), getbooty(Index))
End If

End If

    ' Send a global message that he/she left
    If GetPlayerAccess(index) <= 1 Then
    ' If the player has less or equal access then a moniter then tell all players they left
        Call GlobalMsg(GetPlayerName(index) & " has left " & GameName & "!", 7)
    Else
    ' If the player has greater access then a moniter then tell all players the administrator has left
        Call GlobalMsg("Administrator " & GetPlayerName(index) & " has left " & GameName & "!", 15)
    End If

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when a new character is created.
' This is really only intended for PutVar and GetVar calls.
Sub OnNewChar(index, charnum)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when a players experience exceeds the next level requirement.                                                               
Sub PlayerLevelUp(index)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim I   
Dim D
Dim C

    ' Calculating the number of points to give to players and setting exp to appropriate amounts.
    C = 0
    Do While GetPlayerExp(index) => GetPlayerNextLevel(index)   
        D = GetPlayerExp(index) - GetPlayerNextLevel(index)
        Call SetPlayerLevel(index, GetPlayerLevel(index) + 1)
        I = Int(GetPlayerSpeed(index) / 10)
        If I < 1 Then I = 1
        If I > 3 Then I = 3

        Call SetPlayerPoints(index, GetPlayerPoints(index) + I)
        Call SetPlayerExp(index, D)     
        C = C + 1
    Loop 

    ' Optional section currently disabled for broadcasting when players level up.
    ' If C > 1 Then
        ' Call GlobalMsg(GetPlayerName(index) & " has gained " & C & " levels!", 6)
    ' Else
        ' Call GlobalMsg(GetPlayerName(index) & " has gained a level!", 6)     
    ' End If   

' Tells the player how many points they have to distribute
    Call BattleMsg(index, "You have " & GetPlayerPoints(index) & " stat points.", 9, 0) 
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when a player uses one of the points given on an attribute to level up.
Sub UsingStatPoints(index, PointType)                           
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' Decide which point type was clicked and run different things accordingly.
Select Case PointType

    Case 0
    ' STRENGTH WAS CLICKED +
    ' Gives you a set max
        If GetPlayerSTR(index) + 1 > 1000 Then
        Call BattleMsg(index, "You have maxed your strength!", 12, 0)
        Exit Sub
        End If
        Call SetPlayerSTR(index, GetPlayerSTR(index) + 1)
        Call BattleMsg(index, "You have gained more strength!", 15, 0)

    Case 1
    ' DEFENCE WAS CLICKED +
    ' Gives you a set max
        If GetPlayerDEF(index) + 1 > 1000 Then
        Call BattleMsg(index, "You have maxed your defence!", 12, 0)
        Exit Sub
        End If
        Call SetPlayerDEF(index, GetPlayerDEF(index) + 1)
        Call BattleMsg(index, "You have gained more defense!", 15, 0)

Case 2
    ' MAGIC WAS CLICKED +
    ' Gives you a set max
        If GetPlayerMAGI(index) + 1 > 1000 Then
        Call BattleMsg(index, "You have maxed your magic!", 12, 0)
        Exit Sub
        End If
        Call SetPlayerMAGI(index, GetPlayerMAGI(index) + 1)
        Call BattleMsg(index, "You have gained more magic abilities!", 15, 0)

    Case 3
    ' SPEED WAS CLICKED +
    ' Gives you a set max
        If GetPlayerSpeed(index) + 1 > 1000 Then
        Call BattleMsg(index, "You have maxed your speed!", 12, 0)
        Exit Sub
        End If
        Call SetPlayerSPEED(index, GetPlayerSpeed(index) + 1)
        Call BattleMsg(index, "You have gained more speed!", 15, 0)

End Select

' Remove one point after the sub in question is done
Call SetPlayerPoints(index, GetPlayerPoints(index) - 1)
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when a player steps onto a scripted tile
Sub ScriptedTile(index, Script)                                 
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' Choose what number the tile was to determine the effect to have
Select Case Script

    Case 0
        If GetPlayerLevel(index) < 4 Then
            Call PlayerMsg(index,"You need to be level 4 to enter the subterrane", 7)
Else
Call PlayerWarp(index, 17, 10, 13)
        End If

Case 1
        If GetPlayerLevel(index) < 6 Then
            Call PlayerMsg(index,"You need to be level 6 to enter the Ezmeral Pass", 7)
Else
Call PlayerWarp(index, 28, 9, 13)
        End If

Case 2
  Call Baron_Uber_skills(index)

'<><><><><>

Case 3
  Call Baron_Stam_regain(index)

Case 4  'class change
Dim PlayerLv
Dim PlayerClass
PlayerLv = GetPlayerLevel(index)
PlayerClass = GetPlayerClass(index)

If PlayerLv => 10 then
  If PlayerClass <= Class0 then
  Call PlayerMsg(index, "You are now a Sorceror!", 10)
  Call SetPlayerClass(index, Class2)
  End If
  Else
  Call PlayerMsg(index, "You must be Level 10 to become a Sorceror!", 12)
  End If

Case 5  'class change
Dim PlayerLv
Dim PlayerClass
PlayerLv = GetPlayerLevel(index)
PlayerClass = GetPlayerClass(index)

If PlayerLv => 10 then
  If PlayerClass <= Class0 then
  Call PlayerMsg(index, "You are now a Priest!", 10)
  Call SetPlayerClass(index, Class4)
  End If
  Else
  Call PlayerMsg(index, "You must be Level 10 to become a Sorceror!", 12)
  End If

Case 6  'class change
Dim PlayerLv
Dim PlayerClass
PlayerLv = GetPlayerLevel(index)
PlayerClass = GetPlayerClass(index)

If PlayerLv => 10 then
  If PlayerClass <= Class1 then
  Call PlayerMsg(index, "You are now a Sorceror!", 10)
  Call SetPlayerClass(index, Class2)
  End If
  Else
  Call PlayerMsg(index, "You must be Level 10 to become a Sorceror!", 12)
  End If

End Select
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when a player clicks on an OnClick tile
Sub OnClick(index, script)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' Determine which script to run
Select Case script

Case 0
Call PlayerMsg(index, "You clicked a tile!", 15)

End Select
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Bit outdated, use custom menus, This sub runs when a player chooses yes or no on a player prompt.
Sub PlayerPrompt(index, Prompt, Value)
If Prompt = 6 Then
    Select Case Value
        Case 0
x = 1
Do While x <= 24
If GetPlayerInvItemNum(index, x) = itemnum Then
If GetPlayerInvItemValue(index, x) >= Value Then
CheckforItem = "True"
Exit Do
End If
End If
x = x + 1
Loop
If x < 25 Then
Call Quest_Take_Item(index, 1, 25)
Call PlaySound(index, "Inn.WAV")
Call SetPlayerHP(index, GetPlayerMaxHp(index))
Call SetPlayerMP(index, GetPlayerMaxMp(index))
Call PlayerMsg(index, "You feel rejuvenated", 15)
Else
Call PlayerMsg(index, "You don't have enough gold!", 4)
End If
    End Select
Else
    Select Case Value
        Case 0
'Do nothing
Exit Sub
    End Select
End If
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Bit outdated, use custom menus, it will be easier and far more secure. Handles query box responses.
Sub QueryBox(index, Prompt) 
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Value = GetVar("responses.ini","Responses",Cstr(index))
End Sub

Sub TimedEvent(hours, minutes, seconds)

If hours=5 and minutes=5 and seconds=10 Then
Call globalmsg("This is a timed broadcast at time 05:05:10", 14)
End If

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs every time a player drops an item
Sub OnItemDrop(index, map, itemnum, itemval, itemdur, item_index, inv_slot)
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' If player is an admin tell them all about the item they dropped
If GetPlayerAccess(index)>=3 Then
Call playermsg(index, "Drop Info - num: " & itemnum & " val: " & itemval & " dur: " & itemdur, 14)
Call playermsg(index, "Item Index " & item_index & " was dropped from slot " & inv_slot & " onto map " & map, 14)
End If   

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs each time a player changes map
Sub OnMapLoad(index)     
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Dim map
map=GetPlayerMap(index)

' Example of a map script:

' If map = 52 Then
' Call playermsg(index, "You see the goblin shaman eye you warily as you enter his tent", 12)
' End If

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs whenever you kill an NPC. Good for boss kill checkers, 'monster trackers etc

Sub onNPCdeath(index, map, NPC_Num, NPC_index)

If GetPlayerLevel( Index) > 48 then
Call SetPlayerLevel( Index, 1)
End if

If NPC_num = 16 Then
If GetVar("Data\Boss\" & GetPlayerName(index) & ".ini","Quest", "Boss1") = "Dead" Then
Exit Sub
End if

If giveplayeritem(index, 32, 0, 0) = 1 then
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss1", "Dead")
Call BattleMsg(index, "You killed the Goblin Lord! Now bring his head back to the miner to claim your reward!", 12, 0)
Else
Call BattleMsg(index, "You don't have enough inventory space to carry the Goblin Lord's head!", 12, 0)
Call BattleMsg(index, "Make some room and kill him again!", 12, 0)

End If
End If

If NPC_num = 28 Then
If GetVar("Data\Boss\" & GetPlayerName(index) & ".ini","Quest", "Boss2") = "Dead" Then
Exit Sub
End if

If giveplayeritem(index, 66, 0, 0) = 1 then
Call PutVar("Data\Boss\" & GetPlayerName(index) & ".ini", "Quest", "Boss2", "Dead")
Call BattleMsg(index, "You killed the Skeleton Lord! Now bring his head back to the Gravedigger to claim your reward!", 12, 0)
Else
Call BattleMsg(index, "You don't have enough inventory space to carry the Skeleton Lord's head!", 12, 0)
Call BattleMsg(index, "Make some room and kill him again!", 12, 0)

End If
End If

i = 1
Do While i <= Int(GetVar("data.ini", "MAX", "MAX_PLAYERS"))
If GetPlayerMap(i) = GetPlayerMap(index) Then
Call PlaySound(i, Cstr(NPC_Num) & ".wav")
End If
i = i + 1
Loop

Call BattleMsg(index, "You killed a " & getnpcname(NPC_Num), 12, 0)
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub runs when a player is killed by another. Death occurs as normal externally to this script.
Sub onPVPdeath(attacker,victim)                                 
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Call GlobalMsg(GetPlayerName(Victim) & " has been killed by " & GetPlayerName(Attacker), 12)
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' This sub handles deaths in an arena. It has been preconfigured to warp to the map x y coords in the arena tile editor and heal the player who died.
Sub onARENAdeath(attacker,victim)                               
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Dim map
Dim x
Dim y
Dim data1
Dim data2
Dim data3
map=GetPlayerMap(victim)
x=GetPlayerX(victim)
y=GetPlayerY(victim)
Call GlobalMsg(GetPlayerName(Victim) & " has been defeated in the arena by " & GetPlayerName(Attacker), 12)
Call setplayerhp(victim, getplayermaxhp(victim))
Call setplayermp(victim, getplayermaxmp(victim))
Call sendHp(victim)
Call sendMP(victim)
data1 = GetTileData1(map, x, y)
data2 = GetTileData2(map,x,y)
data3 = GetTileData3(map,x,y)
Call playerwarp(victim, data1, data2, data3)
End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub ScriptedSpell(index, Script)                                 
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Select Case Script

    Case 0
        ' Example of a scripted spell.
        Call MapMsg(GetPlayerMap(index), GetPlayerName(index) & "'s spell fizzles.", 12)

Case 1
'FIRE NOVA

m = GetPlayerMap(index)
x = GetPlayerX(index)
y = GetPlayerY(index)

Call SpellAnim(5, m, x + 1 , y + 1)
Call SpellAnim(5, m, x + 1 , y - 1)
Call SpellAnim(5, m, x - 1 , y + 1)
Call SpellAnim(5, m, x - 1 , y - 1)
Call SpellAnim(5, m, x + 1 , y)
Call SpellAnim(5, m, x - 1 , y )
Call SpellAnim(5, m, x , y + 1)
Call SpellAnim(5, m, x , y - 1)

z = 1
Do While z < 16
If GetMapNpcHP(m, z) > 0 and GetMapNpcHP(m, z) <> 32767 Then
Call SetMapNpcTarget(m, z, Index)
xd = GetplayerX(m, z)-x
yd = GetplayerY(m, z)-y
D = abs(sqr(xd*xd + yd*yd))
If D < 2 Then
Call SetMapNpcHP(m, z, GetMapNpcHP(m, z) - 5)
End If
End If
z = z + 1
Loop

End Select

End Sub

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub ScriptedNPC(index, Script)
On Error Resume next
Dim status
Dim start_msg
Dim questing_msg
Dim end_msg
Dim completed_msg
Dim has_needed
Dim need_count
Dim give_count
Dim slot
Dim count
Dim found
Dim number
Dim durability
Dim value
Dim experience
Dim name

Select Case Script
    Case 0

        If getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "Start_Msg") <> "" Then

          If getvar("scripts\charextras\" & GetPlayerName(index) & ".ini", "QUEST", GetPlayerMap(index) ) < 0 Then
          Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", "QUEST", GetPlayerMap(index), 0 )
          End If

        status = getvar("scripts\charextras\" & GetPlayerName(index) & ".ini", "QUEST", GetPlayerMap(index))
        name=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "name")

        Select Case status

          Case 0
          start_msg=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "Start_Msg")
          Call playermsg(index, name & " : " & start_msg, 15)
          Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", "QUEST", GetPlayerMap(index), 1 )

            Case 1

                need_count=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "need_count")
                count=1     
                slot=1
                has_needed=0

                'CHECK FOR ITEMS

                Do While count<=Int(need_count)
                number=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", count & "_need_num")
                value=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", count & "_need_val")
                slot=1

                  Do While slot < 25   
                      If Int(getplayerinvitemnum(index,slot))=Int(number) Then
                        If Int(getplayerinvitemvalue(index, slot))>=Int(value) Then
                        has_needed=has_needed+1
                        slot=25
                        End If 
                      End If
                  slot=slot+1
                  Loop

                count=count+1
                Loop

                'ACTUALLY TAKE ITEMS

                If has_needed >= Int(need_count) Then
                has_needed=1
                count=1

                  Do While count<=Int(need_count)
                  number=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", count & "_need_num")
                  value=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", count & "_need_val")
                  slot=1         
                  Do While slot < 25   
                  If Int(getplayerinvitemnum(index,slot))=Int(number) Then
                  If Int(getplayerinvitemvalue(index, slot))>=Int(value) Then
                  Call quest_Take_Item(index, number, value)
                  Call Battlemsg(index, name & " removed an item from your inventory.", 15, 0)
                  slot=25
                  End If 
                  End If
                  slot=slot+1
                  Loop
                  count=count+1
                  Loop

                Else
                has_needed=0
                End If

                'CHECK IF ITEMS WERE TAKEN

              If has_needed = 0 Then
              questing_msg=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "Questing_Msg")
              Call playermsg(index, name & " : " & questing_msg, 15)
              Else
              end_msg=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "end_Msg")
              Call playermsg(index, name & " : " & end_msg, 15)
              Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", "QUEST", GetPlayerMap(index), 2 )
              Call scriptedNPC(index, 0)
              End If 

            Case 2

            'GIVE THE ITEMS AS REWARD, DONT UNLESS ENOUGH SPACE, IF GIVEN BECOME 3
            'GET NUMBER OF FREE SLOTS

            slot=1
            count=0

            Do While slot < 25
                If Int(getplayerinvitemnum(index,slot))=0 Then
                count=count+1
                End If           
            slot=slot+1
            Loop 

            'CHECK ENOUGH SPACE FOR ITEMS BEING GIVEN

            give_count=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "give_count")
            If Int(count)>=Int(give_count) Then

            'GIVE ITEMS

            count=1

            Do While Int(count)<=Int(give_count)

            number=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", count & "_num")
            value=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", count & "_val")           
            durability=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", count & "_dur")
            If int(value) > 0 Then
            balliztikvariable = 0
            slot = 1
              Do While slot < 25
                  If Int(getplayerinvitemnum(index,slot))=int(number) Then
                      Call setplayerinvitemvalue(index, Int(slot), GetPlayerInvItemValue(index, Int(slot)) + Int(value))
                      Call sendinventoryupdate(index, slot)
                      slot=25
                      balliztikvariable = 1
                      Call Battlemsg(index, name & " gives you an item.", 15, 0)
                    End If           
              slot=slot+1
              Loop
            count=count+1
            If balliztikvariable = 0 Then
                        slot=1       
              Do While slot < 25
                  If Int(getplayerinvitemnum(index,slot))=0 Then
                      Call setplayerinvitemdur(index, Int(slot), Int(durability))
                      Call setplayerinvitemvalue(index, Int(slot), Int(value))
                      Call setplayerinvitemnum(index, Int(slot), Int(number))
                      Call sendinventoryupdate(index, slot)
                      slot=25
                      Call Battlemsg(index, name & " gives you an item.", 15, 0)
                    End If           
              slot=slot+1
              Loop
            count=count+1
            End If
            Else         
            slot=1       
              Do While slot < 25
                  If Int(getplayerinvitemnum(index,slot))=0 Then
                      Call setplayerinvitemdur(index, Int(slot), Int(durability))
                      Call setplayerinvitemvalue(index, Int(slot), Int(value))
                      Call setplayerinvitemnum(index, Int(slot), Int(number))
                      Call sendinventoryupdate(index, slot)
                      slot=25
                      Call Battlemsg(index, name & " gives you an item.", 15, 0)
                    End If           
              slot=slot+1
              Loop
            count=count+1
            End If
            Loop
            'ADVANCE TO COMPLETELY FINISHED QUEST

            Call putvar("scripts\charextras\" & GetPlayerName(index) & ".ini", "QUEST", GetPlayerMap(index), 3)
            experience=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "experience")
            Call battlemsg(index, "Quest Completed! " & experience & " experience gained!", 14, 0)
            experience=experience+GetPlayerExp(index)
            Call SetPlayerExp(index, Int(experience))
            Call PlayerLevelUp(index)
            Call sendplayerdata(index)

            'MESSAGE FOR NO SPACE

            Else
            space_msg=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "space_msg")
            Call playermsg(index, name & " : " & space_msg, 15)
            End If

            'MESSAGE FOR COMPLETED QUEST

            Case 3
            completed_msg=getvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "completed_msg")
            Call playermsg(index, name & " : " & completed_msg, 15)     

        End Select

        Else
        'ADD REST OF VARIABLES NEEDED TO QUICK GENERATE INI'S AND CREDIT

        Call playermsg(index, "No quest found, generating generic quest sript under server\mapextras\" & GetPlayerMap(index) & ".ini", 14)
        'Call playermsg(index, "This script was coded by Baron, http://barony.deviantart.com", 14)
        'Call Playermsg(index, "This script is free to use on any server, but this credit must not be removed.", 14)

        Call putvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "Start_Msg", "Bring me item X!")
        Call putvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "Questing_Msg", "Have item X yet?")
        Call putvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "End_Msg", "Have item X yet?")     
        Call putvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "Completed_Msg", "Thanks for item X!")
        Call putvar("scripts\mapextras\" & GetPlayerMap(index) & ".ini", "QUEST", "Space_Msg", &qu
```
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...