Mirage Source http://www.miragesource.net/forums/ |
|
Open Shop on Attack http://www.miragesource.net/forums/viewtopic.php?f=210&t=2417 |
Page 1 of 1 |
Author: | Rezeyu [ Thu Aug 09, 2007 2:56 am ] |
Post subject: | Open Shop on Attack |
Well, basically, when you hit attack (whatever button that may be for you.) on a shopkeeper, it'll queue up the shop that has the same name as the NPC. Difficulty: Cut and Paste + For the love of all that is unholy, Understand. First off, find: Function CanAttackNpc Now there's a case with the four directions. Each one contains this code: Code: If Npc(NpcNum).Behavior <> NPC_BEHAVIOR_FRIENDLY And Npc(NpcNum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then CanAttackNpc = True Else Call PlayerMsg(Attacker, "You cannot attack a " & Trim(Npc(NpcNum).Name) & "!", BrightBlue) End If Simple enough, it finds out what the NPC's behavior is, and acts accordingly. Now, change it to this: Code: If Npc(NpcNum).Behavior <> NPC_BEHAVIOR_FRIENDLY And Npc(NpcNum).Behavior <> NPC_BEHAVIOR_SHOPKEEPER Then CanAttackNpc = True Else If Npc(NpcNum).Behavior = NPC_BEHAVIOR_SHOPKEEPER Then For i = 1 To MAX_SHOPS If Trim(Shop(i).Name) = Trim(Npc(NpcNum).Name) Then Call SendTrade(Attacker, i) End If Next i Else Call PlayerMsg(Attacker, "You cannot attack a " & Trim(Npc(NpcNum).Name) & "!", BrightBlue) End If End If Don't forget to Dim I. Basically, if the NPC is a shopkeeper, it runs through every shop in the I loop, and checks each shop's name to the NPC's name. If it matches, it calls the shop. Simple enough eh? So.. do that for all four directions. you might also want to remove the ability to call shops with /trade, and if you'd like, even remove the map's shop attribute, since you don't need it. Again, it's just something simple I added a long time ago, and I figure most people here have as well, but this should help some of the newbies, right? EDIT: almost forgot, you need to make sure the shop index is loaded when you have trade requests, or it'll call up the shop on the map. I'll post how later, but it's not that hard.. so you can always do it yourself. <hint, hint> |
Author: | Matt [ Thu Aug 09, 2007 3:32 am ] |
Post subject: | Re: Open Shop on Attack |
Should just save the shop number to the npc and skip the loop each time. It's smarter. |
Author: | Rezeyu [ Thu Aug 09, 2007 3:37 am ] |
Post subject: | Re: Open Shop on Attack |
I wasn't sure if it would be faster/less memory, since you'd still have to save a shop number to the NPC rec, and save/load it. |
Author: | Matt [ Thu Aug 09, 2007 4:02 am ] |
Post subject: | Re: Open Shop on Attack |
It's one number, one byte that would be loaded. More than a byte if you have higher than 255 shops, but w/e. What's loading one number as opposed to looping through 255 or more depending on your max shops? |
Author: | Rezeyu [ Thu Aug 09, 2007 4:38 am ] |
Post subject: | Re: Open Shop on Attack |
Alright, makes sense. =(^.^)= |
Author: | Matt [ Thu Aug 09, 2007 1:03 pm ] |
Post subject: | Re: Open Shop on Attack |
The tut isn't bad, but it needs to be updated. Maybe when I get back from my wedding today, I'll help you out. |
Author: | James [ Sat Aug 11, 2007 5:07 pm ] |
Post subject: | Re: Open Shop on Attack |
Yea, this was one of the first things I moved over to PW from my other sources, and I have the shop saved to the NPC. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |