| Mirage Source http://web.miragesource.net/forums/ |
|
| Question about attacking http://web.miragesource.net/forums/viewtopic.php?f=201&t=300 |
Page 1 of 2 |
| Author: | halla [ Tue Jul 18, 2006 7:32 pm ] |
| Post subject: | Question about attacking |
Where is the code where it finds out if the player is beside the NPC so he is able to attack. Im adding something where you click a NPC and it brings up a form, but where I had it I could click anywhere it would bring up the form. So wheres this code so I can place it in there and it will only bring up the Form when I click the NPC and im right beside him. |
|
| Author: | Rian [ Tue Jul 18, 2006 7:45 pm ] |
| Post subject: | |
Search the server side code for this: Your target is now and that should find you the right stuff. You'll then need to send a packet to the client to bring the form up |
|
| Author: | Gilgamesch [ Tue Jul 18, 2006 7:46 pm ] |
| Post subject: | |
its in playersearch i think..the packet s: "search" (server side) thats where a player or npc is been targetted, so you need to add: if getplayerx(index) = MapNpc(Player bla bla target code thingy).x - 1 or getplayerx(index) = MapNpc(Player bla bla target code thingy).x +1 and getplayery(index) = MapNpc(Player bla bla target code thingy)y. -1 or getplayery(index) = MapNpc(Player bla bla target code thingy)y. +1 then your code thats just out of my midn..i am really tiered right now, if you cant find it or need some help just post it here bye |
|
| Author: | halla [ Wed Jul 19, 2006 2:33 am ] |
| Post subject: | |
Thanks guys I will look into it. I was looking client side think that was my problem. I found it... I was just ysing.... Code: frmBattle.Visible = True
but sine that forms on the client not server it wont compile. I added it to the packet so it would send that to client to do when it targets... So is there another way to do this or what am I doing wrong. |
|
| Author: | Matt [ Thu Jul 20, 2006 1:27 am ] |
| Post subject: | |
I'm not sure what you're trying to do. I assume, you are sending a packet to the server to start a battle, and when the server recieves that packet, trying to open the form client side, by calling the function server side? If so, just send a packet back to the client, and send a variable with a value, and do an if check or something, that if the parse = 1 then frmbattle.visible = true If that's what you're trying to do, I don't really understand your posts all that much, sorry if I'm wrong. ^_^ |
|
| Author: | halla [ Thu Jul 20, 2006 8:26 pm ] |
| Post subject: | |
well I added a code where you right click a npc and you attack it. I want it where when you click the npc that you open up a form. I had it working but it would open the form when I click anywhere thats why I wanted to know about just when I click npc |
|
| Author: | Classified [ Thu Jul 20, 2006 9:06 pm ] |
| Post subject: | |
Do it all client side.. but only open the form if there is an NPC on that tile. |
|
| Author: | halla [ Fri Jul 21, 2006 1:06 am ] |
| Post subject: | |
Yeah I was trying to find where it targets the npc and I was lead to the server side. Which I did find it but when I put that in it said the form wasnt there. |
|
| Author: | halla [ Fri Jul 21, 2006 4:00 am ] |
| Post subject: | |
What did I do wrong here I think it shold work but when I click NPC it targets thembut doesnt open the Form... heres code. Server: Code: ' Check for an npc For i = 1 To MAX_MAP_NPCS If MapNpc(GetPlayerMap(Index), i).Num > 0 Then If MapNpc(GetPlayerMap(Index), i).x = x And MapNpc(GetPlayerMap(Index), i).y = y Then ' Change target Player(Index).Target = i Player(Index).TargetType = TARGET_TYPE_NPC BattleOpen = 1 Call PlayerMsg(Index, "Your target is now a " & Trim(Npc(MapNpc(GetPlayerMap(Index), i).Num).Name) & ".", Yellow) Else BattleOpen = 0 Exit Sub End If End If Next i Exit Sub End If CLIENT SIDE: Code: ' Open Battle Form If BattleOpen = 1 Then frmBattle.Visible = True Else frmBattle.Visible = False End If Also I have on each... Code: Dim BattleOpen As Long
|
|
| Author: | Dark Echo [ Fri Jul 21, 2006 9:23 am ] |
| Post subject: | |
I think grim wrote a really good tutorial for clicking, and i think theres also a good tutorial on npc name on hover.. Have you tried looking at those? |
|
| Author: | Matt [ Fri Jul 21, 2006 12:33 pm ] |
| Post subject: | |
Server - Code: ' Check for an npc For i = 1 To MAX_MAP_NPCS dim packet as string ' Might already be defined, don't know, if so, delete this If MapNpc(GetPlayerMap(Index), i).Num > 0 Then If MapNpc(GetPlayerMap(Index), i).x = x And MapNpc(GetPlayerMap(Index), i).y = y Then ' Change target Player(Index).Target = i Player(Index).TargetType = TARGET_TYPE_NPC BattleOpen = 1 Call PlayerMsg(Index, "Your target is now a " & Trim(Npc(MapNpc(GetPlayerMap(Index), i).Num).Name) & ".", Yellow) Else BattleOpen = 0 packet = "Battle" & Sep_Char & BattleOpen & Sep_Char & End_Char Call SendData(Index, packet) Exit Sub End If End If Next i Exit Sub End If Client - Code: If LCase(Parse(0)) = "battle" Then
' Open Battle Form BattleOpen = Val(Parse(1)) If BattleOpen = 1 Then frmBattle.Visible = True Else frmBattle.Visible = False End If That should work, if not, it's not something hard to fix. Good luck. |
|
| Author: | halla [ Fri Jul 21, 2006 7:46 pm ] |
| Post subject: | |
Thanks I will work at it All good so far except... Code: If LCase(Parse(0)) = "battle" Then
When trying to compile Client highlights Parse there and says Argument not optional. Also on client I changed SendData to SendDataTo I will keep looking into it but if you know whats wrong before I find it please post. Thanks for all the help so far. |
|
| Author: | Matt [ Fri Jul 21, 2006 8:55 pm ] |
| Post subject: | |
Put that in handle data, I believe, where all the other packets are. It should work then. |
|
| Author: | halla [ Fri Jul 21, 2006 10:43 pm ] |
| Post subject: | |
oh my bad I put it in the gameloop thought it would have to go there guess im wrong EDIT: well I still had to fix some more stuff but I got it working. Thanks for all the help. If anyone wants the working code for some reason let me know and I will post. |
|
| Author: | Matt [ Sat Jul 22, 2006 1:01 pm ] |
| Post subject: | |
Well, a packet was added, therefore, handle data would be the choice place. Congrats on getting it to work. ^_^ |
|
| Page 1 of 2 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|