martine94 Posted February 18, 2008 Share Posted February 18, 2008 So okey here it comes. I recently started to learn scripting (again) and this time more seriously. I've checked some tutorials on wiki but haven't found so many tutorials. Anyways if i wanted to make an assassin go around in town like usual with basic packages , But when a player comes near him , about 20 meters he he will attack. How would that script look like? ... Help is appreciated and if you have any good tutorials I'd be even more happy. Link to comment Share on other sites More sharing options...
Vagrant0 Posted February 18, 2008 Share Posted February 18, 2008 So okey here it comes. I recently started to learn scripting (again) and this time more seriously. I've checked some tutorials on wiki but haven't found so many tutorials. Anyways if i wanted to make an assassin go around in town like usual with basic packages , But when a player comes near him , about 20 meters he he will attack. How would that script look like? ... Help is appreciated and if you have any good tutorials I'd be even more happy. 20 meters is quite a bit of distance in game... Almost half a cell. You may want to use packaging so that the assassin tries to travel closer to the player before starting to attack. Most of what you want to do is really with packaging. You'll want to get a set routine for the assassin, then set a travel to player package with conditions that are getdistance to player <= 2040 and some other condition if you want this to only happen durring a specific quest stage. You may also want to set some time or day limits to that travel package so that you can better control where (based on the NPC's routine packages) and when he will attack. You will want to have the travel package at the top of the list, and all the routine packages below that. This will make it so that the assassin will move closer to the player before starting combat, making it seem more sudden, rather than having to cross a great distance and probably get killed by guards and other NPCs along the way. The only bit of scripting would look something like ref self short stage begin gamemode set self to getself if self.getpackagetarget == player set stage to 1 endif if stage == 1 if self.getdistance player <= 256 start combat player set stage to 0 elseif self.getdistance player >= 2200 set stage to 0 endif endif end The reason why you might want to use some sort of controlling stage before checking distance is so that the script runs smoother, and is less likely to misfire at times that it wouldn't make sense (like when the NPC is sleeping). The way it is currectly scripted is that it will only initiate the attack if the package the NPC is using is the player and the NPC gets close to the player. It will also reset the script if the player moves out of range of the travel package before combat begins so that the distance checks aren't being run constantly. Link to comment Share on other sites More sharing options...
martine94 Posted February 18, 2008 Author Share Posted February 18, 2008 Thanks a lot vagrant. That helped a lot :) I guess i'm heading back to the wiki tutorials now , I have a long way to go. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.