Mirage Source http://web.miragesource.net/forums/ |
|
Set NPC HP/EXP http://web.miragesource.net/forums/viewtopic.php?f=210&t=97 |
Page 1 of 1 |
Author: | Tutorial Bot [ Fri Jun 02, 2006 7:21 pm ] |
Post subject: | Set NPC HP/EXP |
Author: grimsk8ter11 Difficulty: 1/5 :: SERVER SIDE :: In modTypes, fin: Code: Type NpcRec Beneath, add: Code: MaxHP As Long GiveEXP As Long Find Sub ClearNPC(ByVal Index As Long), replace it with: Code: Sub ClearNpc(ByVal Index As Long) Npc(Index).Name = "" Npc(Index).AttackSay = "" Npc(Index).Sprite = 0 Npc(Index).SpawnSecs = 0 Npc(Index).Behavior = 0 Npc(Index).Range = 0 Npc(Index).DropChance = 0 Npc(Index).DropItem = 0 Npc(Index).DropItemValue = 0 Npc(Index).STR = 0 Npc(Index).DEF = 0 Npc(Index).SPEED = 0 Npc(Index).MAGI = 0 Npc(Index).MaxHP = 0 Npc(Index).GiveEXP = 0 End Sub In modGameLogic, find: Code: ' Calculate exp to give attacker Change it to: Code: ' Calculate exp to give attacker Exp = Npc(NpcNum).GiveEXP In modHandleData, find: Code: Save NPC Packet Replace with: Code: ' ::::::::::::::::::::: ' :: Save npc packet :: ' ::::::::::::::::::::: If LCase(Parse(0)) = "savenpc" Then ' Prevent hacking If GetPlayerAccess(Index) < ADMIN_DEVELOPER Then Call HackingAttempt(Index, "Admin Cloning") Exit Sub End If N = Val(Parse(1)) ' Prevent hacking If N < 0 Or N > MAX_NPCS Then Call HackingAttempt(Index, "Invalid NPC Index") Exit Sub End If ' Update the npc Npc(N).Name = Parse(2) Npc(N).AttackSay = Parse(3) Npc(N).Sprite = Val(Parse(4)) Npc(N).SpawnSecs = Val(Parse(5)) Npc(N).Behavior = Val(Parse(6)) Npc(N).Range = Val(Parse(7)) Npc(N).DropChance = Val(Parse(8)) Npc(N).DropItem = Val(Parse(9)) Npc(N).DropItemValue = Val(Parse(10)) Npc(N).STR = Val(Parse(11)) Npc(N).DEF = Val(Parse(12)) Npc(N).SPEED = Val(Parse(13)) Npc(N).MAGI = Val(Parse(14)) Npc(N).MaxHP = Val(Parse(15)) Npc(N).GiveEXP = Val(Parse(16)) ' Save it Call SendUpdateNpcToAll(N) Call SaveNpc(N) Call AddLog(GetPlayerName(Index) & " saved npc #" & N & ".", ADMIN_LOG) Exit Sub End If Find: Code: Sub SendEditNpcTo(ByVal Index As Long, ByVal NpcNum As Long) Replace with: Code: Sub SendEditNpcTo(ByVal Index As Long, ByVal NpcNum As Long) Dim Packet As String Packet = "EDITNPC" & SEP_CHAR & NpcNum & SEP_CHAR & Trim(Npc(NpcNum).Name) & SEP_CHAR & Trim(Npc(NpcNum).AttackSay) & SEP_CHAR & Npc(NpcNum).Sprite & SEP_CHAR & Npc(NpcNum).SpawnSecs & SEP_CHAR & Npc(NpcNum).MaxHP & SEP_CHAR & Npc(NpcNum).GiveEXP & SEP_CHAR & Npc(NpcNum).Behavior & SEP_CHAR & Npc(NpcNum).Range & SEP_CHAR & Npc(NpcNum).DropChance & SEP_CHAR & Npc(NpcNum).DropItem & SEP_CHAR & Npc(NpcNum).DropItemValue & SEP_CHAR & Npc(NpcNum).STR & SEP_CHAR & Npc(NpcNum).DEF & SEP_CHAR & Npc(NpcNum).SPEED & SEP_CHAR & Npc(NpcNum).MAGI & SEP_CHAR & END_CHAR Call SendDataTo(Index, Packet) End Sub Find "Sub SaveNpc(ByVal NpcNum As Long)" in modDatabase. Replace it with: Code: Sub SaveNpc(ByVal NpcNum As Long) Dim FileName As String FileName = App.Path & "\npcs.ini" Call PutVar(FileName, "NPC" & NpcNum, "Name", Trim(Npc(NpcNum).Name)) Call PutVar(FileName, "NPC" & NpcNum, "AttackSay", Trim(Npc(NpcNum).AttackSay)) Call PutVar(FileName, "NPC" & NpcNum, "Sprite", Trim(Npc(NpcNum).Sprite)) Call PutVar(FileName, "NPC" & NpcNum, "SpawnSecs", Trim(Npc(NpcNum).SpawnSecs)) Call PutVar(FileName, "NPC" & NpcNum, "Behavior", Trim(Npc(NpcNum).Behavior)) Call PutVar(FileName, "NPC" & NpcNum, "MaxHP", Trim(Npc(NpcNum).MaxHP)) Call PutVar(FileName, "NPC" & NpcNum, "GiveEXP", Trim(Npc(NpcNum).GiveEXP)) Call PutVar(FileName, "NPC" & NpcNum, "Range", Trim(Npc(NpcNum).Range)) Call PutVar(FileName, "NPC" & NpcNum, "DropChance", Trim(Npc(NpcNum).DropChance)) Call PutVar(FileName, "NPC" & NpcNum, "DropItem", Trim(Npc(NpcNum).DropItem)) Call PutVar(FileName, "NPC" & NpcNum, "DropItemValue", Trim(Npc(NpcNum).DropItemValue)) Call PutVar(FileName, "NPC" & NpcNum, "STR", Trim(Npc(NpcNum).STR)) Call PutVar(FileName, "NPC" & NpcNum, "DEF", Trim(Npc(NpcNum).DEF)) Call PutVar(FileName, "NPC" & NpcNum, "SPEED", Trim(Npc(NpcNum).SPEED)) Call PutVar(FileName, "NPC" & NpcNum, "MAGI", Trim(Npc(NpcNum).MAGI)) End Sub Find: Code: Sub LoadNpcs() Replace with: Code: Sub LoadNpcs() On Error Resume Next Dim FileName As String Dim I As Long Call CheckNpcs FileName = App.Path & "\npcs.ini" For I = 1 To MAX_NPCS Call SetStatus("Loading NPCs " & I & "/" & MAX_NPCS & " : " & (I / MAX_NPCS) * 100 & "%") frmLoad.pbarLoad.Min = I frmLoad.pbarLoad.Max = MAX_NPCS Npc(I).Name = GetVar(FileName, "NPC" & I, "Name") Npc(I).AttackSay = GetVar(FileName, "NPC" & I, "AttackSay") Npc(I).Sprite = GetVar(FileName, "NPC" & I, "Sprite") Npc(I).SpawnSecs = GetVar(FileName, "NPC" & I, "SpawnSecs") Npc(I).Behavior = GetVar(FileName, "NPC" & I, "Behavior") Npc(I).Range = GetVar(FileName, "NPC" & I, "Range") Npc(I).DropChance = GetVar(FileName, "NPC" & I, "DropChance") Npc(I).DropItem = GetVar(FileName, "NPC" & I, "DropItem") Npc(I).DropItemValue = GetVar(FileName, "NPC" & I, "DropItemValue") Npc(I).STR = GetVar(FileName, "NPC" & I, "STR") Npc(I).DEF = GetVar(FileName, "NPC" & I, "DEF") Npc(I).SPEED = GetVar(FileName, "NPC" & I, "SPEED") Npc(I).MAGI = GetVar(FileName, "NPC" & I, "MAGI") Npc(I).MaxHP = GetVar(FileName, "NPC" & I, "MaxHP") Npc(I).GiveEXP = GetVar(FileName, "NPC" & I, "GiveEXP") DoEvents Next I End Sub Find: Code: Function GetNpcMaxHP(ByVal NpcNum As Long) Replace with: Code: Function GetNpcMaxHP(ByVal NpcNum As Long) ' Prevent subscript out of range If NpcNum <= 0 Or NpcNum > MAX_NPCS Then GetNpcMaxHP = 0 Exit Function End If GetNpcMaxHP = Npc(NpcNum).MaxHP End Function :: CLIENT SIDE :: In frmNpcEditor, delete the labels next to Start HP and EXP Given (the ones that show their values). Next, open the code and find these: Code: Private Sub scrlSTR_Change() Code: Private Sub scrlDEF_Change() Make them look like this: Code: Private Sub scrlSTR_Change() lblSTR.Caption = STR(scrlSTR.Value) End Sub Private Sub scrlDEF_Change() lblDEF.Caption = STR(scrlDEF.Value) End Sub In modTypes, find: Code: Type NpcRec Add these somewhere in there: Code: MaxHP As Long GiveEXP As Long In modGameLogic, find: Code: Public Sub NpcEditorInit() Repalce with: Code: Public Sub NpcEditorInit() On Error Resume Next frmNpcEditor.picSprites.Picture = LoadPicture(App.Path & "\gfx\sprites.bmp") frmNpcEditor.txtName.Text = Trim(Npc(EditorIndex).Name) frmNpcEditor.txtAttackSay.Text = Trim(Npc(EditorIndex).AttackSay) frmNpcEditor.scrlSprite.Value = Npc(EditorIndex).Sprite frmNpcEditor.txtSpawnSecs.Text = STR(Npc(EditorIndex).SpawnSecs) frmNpcEditor.cmbBehavior.ListIndex = Npc(EditorIndex).Behavior frmNpcEditor.scrlRange.Value = Npc(EditorIndex).Range frmNpcEditor.txtChance.Text = STR(Npc(EditorIndex).DropChance) frmNpcEditor.scrlNum.Value = Npc(EditorIndex).DropItem frmNpcEditor.scrlValue.Value = Npc(EditorIndex).DropItemValue frmNpcEditor.scrlSTR.Value = Npc(EditorIndex).STR frmNpcEditor.scrlDEF.Value = Npc(EditorIndex).DEF frmNpcEditor.scrlSPEED.Value = Npc(EditorIndex).SPEED frmNpcEditor.scrlMAGI.Value = Npc(EditorIndex).MAGI frmNpcEditor.txtMaxHP.Text = Trim(Npc(EditorIndex).MaxHP) frmNpcEditor.txtGiveEXP.Text = Trim(Npc(EditorIndex).GiveEXP) frmNpcEditor.Show vbModal End Sub Find: Code: Public Sub NpcEditorOk() Replace with: Code: Public Sub NpcEditorOk() Npc(EditorIndex).Name = frmNpcEditor.txtName.Text Npc(EditorIndex).AttackSay = frmNpcEditor.txtAttackSay.Text Npc(EditorIndex).Sprite = frmNpcEditor.scrlSprite.Value Npc(EditorIndex).SpawnSecs = Val(frmNpcEditor.txtSpawnSecs.Text) Npc(EditorIndex).Behavior = frmNpcEditor.cmbBehavior.ListIndex Npc(EditorIndex).Range = frmNpcEditor.scrlRange.Value Npc(EditorIndex).DropChance = Val(frmNpcEditor.txtChance.Text) Npc(EditorIndex).DropItem = frmNpcEditor.scrlNum.Value Npc(EditorIndex).DropItemValue = frmNpcEditor.scrlValue.Value Npc(EditorIndex).STR = frmNpcEditor.scrlSTR.Value Npc(EditorIndex).DEF = frmNpcEditor.scrlDEF.Value Npc(EditorIndex).SPEED = frmNpcEditor.scrlSPEED.Value Npc(EditorIndex).MAGI = frmNpcEditor.scrlMAGI.Value Npc(EditorIndex).MaxHP = frmNpcEditor.txtMaxHP.Text Npc(EditorIndex).GiveEXP = frmNpcEditor.txtGiveEXP.Text Call SendSaveNpc(EditorIndex) InNpcEditor = False Unload frmNpcEditor End Sub In modClientTCP, find: Code: Sub SendSaveNpc(ByVal NpcNum As Long) Replace with: Code: Sub SendSaveNpc(ByVal NpcNum As Long) Dim Packet As String Packet = "SAVENPC" & SEP_CHAR & NpcNum & SEP_CHAR & Trim(Npc(NpcNum).Name) & SEP_CHAR & Trim(Npc(NpcNum).AttackSay) & SEP_CHAR & Npc(NpcNum).Sprite & SEP_CHAR & Npc(NpcNum).SpawnSecs & SEP_CHAR & Npc(NpcNum).MaxHP & SEP_CHAR & Npc(NpcNum).GiveEXP & SEPCHAR & Npc(NpcNum).Behavior & SEP_CHAR & Npc(NpcNum).Range & SEP_CHAR & Npc(NpcNum).DropChance & SEP_CHAR & Npc(NpcNum).DropItem & SEP_CHAR & Npc(NpcNum).DropItemValue & SEP_CHAR & Npc(NpcNum).STR & SEP_CHAR & Npc(NpcNum).DEF & SEP_CHAR & Npc(NpcNum).SPEED & SEP_CHAR & Npc(NpcNum).MAGI & SEP_CHAR & END_CHAR Call SendData(Packet) End Sub Find:(partial code) Code: ' ::::::::::::::::::::::: ' :: Update npc packet :: ' ::::::::::::::::::::::: Repalce with: Code: ' ::::::::::::::::::::::: ' :: Update npc packet :: ' ::::::::::::::::::::::: If (LCase(Parse(0)) = "updatenpc") Then n = Val(Parse(1)) ' Update the item Npc(n).Name = Parse(2) Npc(n).AttackSay = "" Npc(n).Sprite = Val(Parse(3)) Npc(n).SpawnSecs = 0 Npc(n).Behavior = 0 Npc(n).Range = 0 Npc(n).DropChance = 0 Npc(n).DropItem = 0 Npc(n).DropItemValue = 0 Npc(n).STR = 0 Npc(n).DEF = 0 Npc(n).SPEED = 0 Npc(n).MAGI = 0 Npc(n).MaxHP = 0 Npc(n).GiveEXP = 0 Exit Sub End If Find:(partial code) Code: ' ::::::::::::::::::::: ' :: Edit npc packet :: <- Used for item editor admins only ' ::::::::::::::::::::: Replace with: Code: ' ::::::::::::::::::::: ' :: Edit npc packet :: <- Used for item editor admins only ' ::::::::::::::::::::: If (LCase(Parse(0)) = "editnpc") Then n = Val(Parse(1)) ' Update the npc Npc(n).Name = Parse(2) Npc(n).AttackSay = Parse(3) Npc(n).Sprite = Val(Parse(4)) Npc(n).SpawnSecs = Val(Parse(5)) Npc(n).Behavior = Val(Parse(6)) Npc(n).Range = Val(Parse(7)) Npc(n).DropChance = Val(Parse(8)) Npc(n).DropItem = Val(Parse(9)) Npc(n).DropItemValue = Val(Parse(10)) Npc(n).STR = Val(Parse(11)) Npc(n).DEF = Val(Parse(12)) Npc(n).SPEED = Val(Parse(13)) Npc(n).MAGI = Val(Parse(14)) Npc(n).MaxHP = Val(Parse(15)) Npc(n).GiveEXP = Val(Parse(16)) ' Initialize the npc editor Call NpcEditorInit Exit Sub End If That's all! |
Author: | Sh4d0ws [ Fri Oct 19, 2007 8:31 pm ] |
Post subject: | Re: Set NPC HP/EXP |
In one of the packets on the client, your SEP_CHAR is missing an _ |
Author: | Robin [ Fri Oct 19, 2007 8:34 pm ] |
Post subject: | Re: Set NPC HP/EXP |
We have a Tutorial Bot? |
Author: | William [ Fri Oct 19, 2007 8:36 pm ] |
Post subject: | Re: Set NPC HP/EXP |
Yeah, I just dont know how it works. Cruzn said something about all the tutorials being stored in him. |
Author: | Rezeyu [ Fri Oct 19, 2007 10:58 pm ] |
Post subject: | Re: Set NPC HP/EXP |
grimsk8ter11 = Tutorialbot? |
Author: | Matt [ Fri Oct 19, 2007 11:02 pm ] |
Post subject: | Re: Set NPC HP/EXP |
No. His posts in here were just converted to the "bot". |
Author: | ZipZap [ Mon Jan 28, 2008 3:15 am ] |
Post subject: | Re: Set NPC HP/EXP |
' Calculate exp to give attacker Exp = Npc(NpcNum).GiveEXP Variable not defined. Any help? |
Author: | Anthony [ Mon Jan 28, 2008 4:21 am ] |
Post subject: | Re: Set NPC HP/EXP |
Is it saying NpcNum isn't defined? Thats sort of weird, make sure something like, Dim NpcNum as Long is at the top of the sub AttackNpc. |
Author: | ZipZap [ Mon Jan 28, 2008 10:39 pm ] |
Post subject: | Re: Set NPC HP/EXP |
I added that, but still same thing... I also removed Code: frmLoad.pbarLoad.Min = I frmLoad.pbarLoad.Max = MAX_NPCS Becuase it said: frmLoad.pbarLoad.Min = I frmLoad.pbarLoad.Max = MAX_NPCS Variable not defined... (But, would that make any diference?) I am using mirage source 3.0.3 Edit: Ahh, hah! There were two " ' Calculate exp to give attacker"s! I just went with the first one I saw. I put it in Sub AttackPlayer, when it was supposed to go in Sub AttackNpc. That pbarload that i deleted shouldn't mess anything up should it? |
Author: | ZipZap [ Tue Jan 29, 2008 1:25 am ] |
Post subject: | Re: Set NPC HP/EXP |
(Sorry for double-posting, please don't kill me. I won't do it again... My other post was just getting kinda jumbled up.) Has anyone else used this successfully? This messed my whole NPC system.. I can't attack with Ctrl now, and the stats don't save, or load up again correctly... |
Author: | Anthony [ Tue Jan 29, 2008 5:38 am ] |
Post subject: | Re: Set NPC HP/EXP |
Probably your not parsing information across properly would be the reason they aren't saving and loading right. The best thing I would suggest you do is go to your client, fine /editnpc and then follow every step through to the end back and forth from server to client and make sure all the data being sent is the same as the data being received. Then, when all thats right, make sure you Sub AttackNpc isn't all screwed up. By the sounds of things, it probably is . Compare it to a Vanilla MSE. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |