Modcraft - The community dedicated to quality WoW modding!

Wrath of the Lich King Modding => Miscellaneous => Topic started by: Bardh on June 12, 2015, 10:49:32 am

Title: [SOLVED] [QUESTION] NPC Ranged Attack
Post by: Bardh on June 12, 2015, 10:49:32 am
Hi guys, I begun making some new npc's for 3.3.5a, I use HeidiSQL,I wanted to make a NPC which would use ranged weapons and attack from  a specific range, what I've seen in creature_template there is no column which would edit the attack range of the unit, I equipped my new npc with a gun on creature_equip_template, I changed the unit ranged attack power and dmg, but it didn't seem to work. I looked for any tutorials or anyone addressing the same problem but mainly they were only for Arcemu.
I wanted to ask if anyone knows if this can be fixed using HeidiSQL or does it require scripting.I use trinity core and as far as I heard trinity core uses C++ and I have just begun learning it.

Thanks  :D

p.s English is not my native.
Title: Re: [QUESTION] NPC Ranged Attack
Post by: Kaev on June 12, 2015, 03:48:12 pm
You have to edit the range of the specific model. You can find that in creature_model_info.
bounding_radius = Melee range
combat_reach = Ranged range
Title: Re: [QUESTION] NPC Ranged Attack
Post by: Bardh on June 12, 2015, 04:49:55 pm
I arrived to change the range from which the npc attacks but it doesn't uses the weapon(gun), he attacks without weapons like he would on melee.Is there any way you could help me with this?
Title: Re: [QUESTION] NPC Ranged Attack
Post by: Kaev on June 12, 2015, 05:21:02 pm
Hm, i never did that, but i think you could add the auto attack spell to the creature. That could work. :s
Did you equip a ranged weapon? (correct id and stuff)
I also found something ranged related at the Predefined SAI templates (http://collab.kpsn.org/display/tc/smart_scripts) section, you could take a look at that. Sadly i never user SAI scripts too. :/
You could also run through the world and search an creature which will attack you from range, copy that and try if it works.
Good luck, would be nice if you could tell us what you exactly did, when something will work. :P
Title: Re: [QUESTION] NPC Ranged Attack
Post by: Bardh on June 12, 2015, 07:53:37 pm
So I finally arrived to make my npc attack with a ranged power......but with a little cost.Even though in HeidiSQL I tried to copy and paste the values from a creature who would attack me with ranged weapon it didn't work, so I had to replace an existing creature and change its values that I need like name,hp or dmg he deals,and like this somehow getting rid of that creature. So  its like I didn't do anything except that changed its name,apperance and other stats, which wouldn't be very useful to edit an NPC instead of creating a new one but its the only thing I can do right now.

Thanks again for the great answers!
Title: Re: [QUESTION] NPC Ranged Attack
Post by: Amaroth on June 12, 2015, 09:32:18 pm
This is my way how to create ranged archer NPCs for TC2 (btw, ignore... like everything Kaev wrote, most of it isn't correct for this issue - just that note about SAI was right). I won't write this completely step by step, because I want you to check structures of thos DBs and to do it at least a little bit on your own. But feel free to ask if you get lost.:


creature_template - nothing unusual to do here, just use SmartAI as ScriptNamer

creature_equip_template - 3rd column is for ranged weapon, use 1st and 2nd for meelee weapons (f.i. sword and little shield maybe?)

smart_scripts:
- you need to make NPC shoot (find some Shoot spell - I use 6660, action_type for casting a spell is 21) when target is in range (event_type 9)
>> enter min and max range and repeat time in seconds


OPTIONAL:
creature_template_addon - in bytes2 fill 2 as value (ranged weapon is show, meelee are sheathed, for opposite ou can use value 1)

Enter another smart scripts for NPC to force it stay on place while shooting. You can also either make NPC chase player with meelee weapon if player gets into meelee with NPC and then start running, or you can give NPC possibility to start shooting at him again. You also don't want NPCs to stay on place when they are under attacks from bigger distance than their shoot range is. You also will want to give NPC possibility to return to its original post after combat.

For all of this just toy a little bit with scripts which use range (event_type 9), update in combat (event_type 1) and update out of combat (event_type 2), allow combat movement action (action_type 21). GL.
Title: Re: [QUESTION] NPC Ranged Attack
Post by: MR. Farrare on June 12, 2015, 09:45:07 pm
or for an easy lazy way change from smartai to archerai and put auto shot spell id in spell 1 or any shooting spell id   :)
Title: Re: [QUESTION] NPC Ranged Attack
Post by: Bardh on June 12, 2015, 11:00:06 pm
Thanks for the answer and help, it is my first time using smartscripts and I though I would run in problems I think I'm doing everything correct and then it doesn't work. So I followed you guide, event type-9 and also min and max distance i supposed were in yards like ingame,and the action type you said 21 was for casting a spell while as far as I saw 21 was for combat movement and 11 was for casting a spell and at the target type I wasn't very clear if I should let it be 0 or any other values,btw I changed the script name and Ai name to SmartAI(creature_template)

ALSO MR.Farrare guide on change AiName to ArcherAI worked very well(what I was looking for),but still I would like to know more about smartscript and why it didn't work. Thanks to you all! :D
Title: Re: [QUESTION] NPC Ranged Attack
Post by: Makpptfox on June 12, 2015, 11:06:32 pm
Let the ScriptName blank.

And add ONLY the AI name on the creature to SmartAI.

For the npc, you have to add him an working ranged weapon, and for the target just set 2 (Victim).

When he will agro, he'll just use the spell.


Here's an exemple of one of my ranged npc. (It's a gunner dwarf)

(http://puu.sh/imuCm/4187189cb4.png)

The spell used is 71927 but it's just because i'm lazy and use the spell_bonus_damage to change the damage of the NPC, any other ranged spell will work.
Title: Re: [QUESTION] NPC Ranged Attack
Post by: Bardh on June 12, 2015, 11:33:12 pm
Thanks guys I arrived to make an NPC firing with a gun from a distance, and using an axe when your close to him, I didn't learn only how to make this but also i learned about the smartscript which sounded very interesting for me, again thanks to you all :D  :)  :D  :)  :D  :)  :D  :)
Title: Re: [SOLVED] [QUESTION] NPC Ranged Attack
Post by: Amaroth on June 13, 2015, 02:10:25 am
Great. I suppose you already found out which targets to use? Victim for NPCs attacked target, self for, well, self? I was still glad to encourage you to learn something new, that was main purpouse :).
Title: Re: [SOLVED] [QUESTION] NPC Ranged Attack
Post by: MR. Farrare on June 15, 2015, 03:47:00 pm
Quote from: "Amaroth"
Great. I suppose you already found out which targets to use? Victim for NPCs attacked target, self for, well, self? I was still glad to encourage you to learn something new, that was main purpouse :).
but you can still help many by doing a good tut
Title: Re: [SOLVED] [QUESTION] NPC Ranged Attack
Post by: Amaroth on June 15, 2015, 10:24:02 pm
I've got quite a lot of work with my last exam which is goig to be on 18th and I also want to finish my czech tutorials first. There are huge amounts (about 70 points on ToDo) I want to do for my project. Well, I am quite busy, as you can see :D. Writing a few smartass comments per day doesn't hurt me so much, but full tutorial for SAI, while I still consider myself quite a beginner with SAI...