![]() |
Open Shop on Attack - Printable Version +- Mirage Engine (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Open Shop on Attack (/showthread.php?tid=1162) |
Open Shop on Attack - Rezeyu - 09-08-2007 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 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 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. Re: Open Shop on Attack - Matt - 09-08-2007 Should just save the shop number to the npc and skip the loop each time. It's smarter. Re: Open Shop on Attack - Rezeyu - 09-08-2007 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. Re: Open Shop on Attack - Matt - 09-08-2007 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? Re: Open Shop on Attack - Rezeyu - 09-08-2007 Alright, makes sense. =(^.^)= Re: Open Shop on Attack - Matt - 09-08-2007 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. |