KDawg08 Posted December 11, 2008 Author Share Posted December 11, 2008 Hey i am using a code that is old but the newer one doesn't work for me… I'm running on EE 2.7 but i'm trying to get my random NPC's i choose to Script 1 to chat with a random answer from Words.iniHere is the script``` Case 1 Dim Words Words=Rand(10,1) Call playermsg(index, GetVar("Words.ini", "Words", ""& Words &""), WHITE) Exit Sub```I have set all values in my npc as 1 as told before. But when i hit CTRL to talk to the npc it comes up with a blank response…Basically if i type something and hit enter mine shows up, but when i try to get the NPC to respond via CTRL(Talk Control) it just gives me a blank space...Any suggestions?Here is what i did in Words.ini[Words]Words1= Test1Words2= Test2Words3= Test3(I did this up to 10) Link to comment Share on other sites More sharing options...
DarkMazer Posted December 11, 2008 Share Posted December 11, 2008 Rand(10, 1) should be Rand(1, 10). It works the first way in TE, but it was changed to the second way in EE.Also,GetVar("Words.ini", "Words", ""& Words &"")should beGetVar("Words.ini", "Words", "Words" & Words) Link to comment Share on other sites More sharing options...
KDawg08 Posted December 11, 2008 Author Share Posted December 11, 2008 That worked perfectly thank you…now it says stuff like...```Hello*Crys*I lost my bracelet somewhere.```How do i get it to show up like this…for example... NPC's NAME IS NPC1```NPC1: HelloNPC1: *Crys*NPC1: I lost my bracelet somewhere.```Basically make it show the npc's name before the text? Link to comment Share on other sites More sharing options...
DarkMazer Posted December 12, 2008 Share Posted December 12, 2008 You got me curious about this. So far, I can tell that GetNpcName(NPCNum) is used to get the NPC's name, and GetMapNpcNum(mapnum, NPCindex) is used to get the NPC's number for the GetNpcName command, but I can't figure out how to get the NPC's index on that map, since it's not included in Sub ScriptedNpc, and attacking a scripted NPC won't make it your target, apparently…If anyone has any ideas on the last bit, feel free to step in here. Link to comment Share on other sites More sharing options...
KDawg08 Posted December 12, 2008 Author Share Posted December 12, 2008 @DarkMazer:> You got me curious about this. So far, I can tell that GetNpcName(NPCNum) is used to get the NPC's name, and GetMapNpcNum(mapnum, NPCindex) is used to get the NPC's number for the GetNpcName command, but I can't figure out how to get the NPC's index on that map, since it's not included in Sub ScriptedNpc, and attacking a scripted NPC won't make it your target, apparently…> > If anyone has any ideas on the last bit, feel free to step in here.Lol sweet i don't feel like a loner now :) Link to comment Share on other sites More sharing options...
balliztik1 Posted December 12, 2008 Share Posted December 12, 2008 It's a long process to determine the NPC, but it's possible.Get the x and y coordinate of the space you are facing, run the coordinates against the coords of each of the NPCs on the map. If there is a match, get that NPC's index and plug in in through the GetNPCName function.I'll throw some code down here in a sec.```x = GetPlayerX(index)y = GetPlayerY(index)m = GetPlayerMap(index)Select Case GetPlayerDir(index)Case 0 y = y - 1Case 1 y = y + 1Case 2 x = x - 1Case 3 x = x + 1End Selectz = 1Do While z < 16If GetNPCX(m, z) = x ThenIf GetNPCY(m, z) = y ThenNpcName = GetNpcName(GetMapNpcNum(m, z))End IfEnd Ifz = z + 1Loop```As a side note, it's an easy addition to the source to add an NPCNum parameter. I did this to my ScriptedNPC and ScriptedItems to make things more versatile. Link to comment Share on other sites More sharing options...
KDawg08 Posted December 12, 2008 Author Share Posted December 12, 2008 Where would I put that code, and that's what's suppose to make my NPC's name show up when they talk? Link to comment Share on other sites More sharing options...
balliztik1 Posted December 12, 2008 Share Posted December 12, 2008 No, that merely sets the variable. You'd still have to add that variable to the message. This would all go in ScriptedNpcs.Like so:```Case 1x = GetPlayerX(index)y = GetPlayerY(index)m = GetPlayerMap(index)Select Case GetPlayerDir(index)Case 0 y = y - 1Case 1 y = y + 1Case 2 x = x - 1Case 3 x = x + 1End Selectz = 1Do While z < 16 If GetNPCX(m, z) = x Then If GetNPCY(m, z) = y Then NpcName = GetNpcName(GetMapNpcNum(m, z)) End If End If z = z + 1LoopWords=Rand(1,10)Call playermsg(index, Trim(NpcName) & ": " & GetVar("Words.ini", "Words", "Words"& Words), WHITE)Exit Sub``` Link to comment Share on other sites More sharing options...
KDawg08 Posted December 12, 2008 Author Share Posted December 12, 2008 so with this script it'll be Case 1 as it is now, BUT the extra case #'s on there are for each seperate NPC? and they walk around so… would that be a problem also? Link to comment Share on other sites More sharing options...
Akselj Posted December 12, 2008 Share Posted December 12, 2008 @KDawg08:> so with this script it'll be Case 1 as it is now, BUT the extra case #'s on there are for each seperate NPC? and they walk around so… would that be a problem also?The "extra cases", as you call them, is for "Select Case GetPlayerDir(index)" Link to comment Share on other sites More sharing options...
DarkMazer Posted December 12, 2008 Share Posted December 12, 2008 @KDawg08:> so with this script it'll be Case 1 as it is now, BUT the extra case #'s on there are for each seperate NPC? and they walk around so… would that be a problem also?They're nested select case statements. The ones on the inside don't affect the ones on the outside at all.The script executes the moment you hit them with an attack, so the only reasons this script shouldn't work are if you're attacking them from a distance, or if your server has really bad lag. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now