• Npc Programming. Animations.
    20 replies, posted
Hello guys, excuse me, may be this question was before me. I'd like to program new Npc for Garry's mod, found many info, but I cannot understand how to program animations. I know that many people create Dinosaurs, Dragons, anything and use custom animations, but I didn't found any reference to using custom animation. Only function "SetAutomaticFrameAdvance( bUsingAnim )". How it works? Sorry for my bad English ^_^
You have to animate the model and get the keyvalue of the QC(or w/e its called) file, and den use the "PlaySequence" function on the entity with the given model, and the keyvalue of the desired animation.
Key Value? Is it name what you give to animation, when you compile it? Where I should write it? I looked code of snpcs and in "int" file they doesn't write anything about sequence.
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetSequence]Entity:SetSequence[/url] for the keyvalues, just look into the Valve wiki about the "QC" file, or decompile an model from the garrysmod_dir.vpk, and look into its QC file as an example. [editline]30th July 2015[/editline] as an example, I just got this from the "male_gestures.mdl": [CODE]$Sequence "g_placeholderapexArms" { "male_gestures_anims\g_placeholderapexArms.smd" fadein 0.2 fadeout 0.2 hidden fps 30 weightlist "weights_g_placeholderapexArms" }[/CODE] [editline]30th July 2015[/editline] and heres a topic from Valve about it: [URL="https://developer.valvesoftware.com/wiki/$sequence"]https://developer.valvesoftware.com/wiki/$sequence[/URL]
Okay, I'll try this! Thank you! I think some questions will come later.. Aaa! Any movement discribes in models! I understood now! Thank you very much!
No problem ^-^
Well, I made the model with animations, it wasn't hard, but now I ran into a problem: How to program him? I looked guide "Nextbot Creation", but there is nothing how to force npc shoot. Someone uses Schedule, but I found only for a melee attacks:( Thanks a lot! I hope you help me ^^ [IMG]http://cs624427.vk.me/v624427204/36f92/DvGneWQWomk.jpg[/IMG]
Nextbot shooting is indeed rarely talked about, tbh I actually dont know myself how to do it, some people talked about giving the NPC a weapon etc, so you'd literally have to code the weapons of this NPC, and cut them off of the models, and make the "wires" the hands, and position the weapon on them when giving them.
[QUOTE=whitestar;48345876]Nextbot shooting is indeed rarely talked about, tbh I actually dont know myself how to do it, some people talked about giving the NPC a weapon etc, so you'd literally have to code the weapons of this NPC, and cut them off of the models, and make the "wires" the hands, and position the weapon on them when giving them.[/QUOTE] lmao no for a roller droid you'd just do a fire function that creates the bullets in front of its arm bones aiming towards the intended target then play the fire animation/make sounds etc coding the weapon as a seperate entity then hackily attaching it back to the droid is just awful and wasteful
I dont know dat was possible >-<
Okey, I think it will use functions LookUpBone, GetBone, FireBullets and Fire, right? How to use last one?:)
[QUOTE=Corteziwe;48346619]Okey, I think it will use functions LookUpBone, GetBone, FireBullets and Fire, right? How to use last one?:)[/QUOTE] fire? fire would be a function you create yourself that gets triggered from within the NPCs logic core when it has a valid target within range and is facing in the right general direction apart from that yeah your on the right track
I cannot understand, how to code fire function :c
[code] if directionIsNearDirectionOfTarget then --create bullets end [/code]
[QUOTE=jaooe;48381714][code] if directionIsNearDirectionOfTarget then --create bullets end [/code][/QUOTE] omg, I spend a lot of time to translate and understand Gmod functions. I thought that in function "Attack", I should set up bullets and use function FireBullets, but when I try to use it in RunBehaviour, game freezes. Can you give some examples? Cause I really cannot understand, how it works :c
Wouldn't recommend using nextbots but I'll make this simple for you: First you are gonna want to run a trace from the entities position to the enemy position Next you need to identify that the enemy is visible using the trace code Once that's done just copy paste a bullet code from a swep if you can't make one yourself. I'd recommend using CurTime() to set up the delay between shots
Sorry, I was busy last months. I try to create these on Vj Base and it's works, but my NPC isn't moving. I think this problem in my qc file, but I cannot find where. Maybe you know? I think it is in $sequence with ACT_RUN and ACT_WALK: $modelname "starwars_models\Droideka\droideka.mdl" $scale "0.4" $model "droideka" "Droideka_ref.smd" $root "root" $origin 0.00 0.00 0.00 -90.00 $autocenter $eyeposition 0.00 0.00 70.00 $surfaceprop combine_metal $illumposition -0.000 0.000 96.000 $cdmaterials "starwars_models\Droideka" $sequence Idle_1 "Droideka_idle_breath" loop ACT_IDLE 3 fps 30.00 node n_idle $sequence Idle_2 "Droideka_idle_breath2" loop ACT_IDLE 1 fps 30.00 node n_idle $sequence summoned "Droideka_unfold" ACT_ARM 1 fps 30.00 $sequence Die_1 "Droideka_death" ACT_DIESIMPLE 1 fps 30.00 $sequence Turn_45_L "Droideka_TurnLeft" loop ACT_TURNLEFT45 -1 fps 30.00 $sequence Turn_45_R "Droideka_TurnRight" loop ACT_TURNRIGHT45 -1 fps 30.00 $sequence walk "Droideka_WalkForward" loop ACT_WALK 1 fps 30.00 $sequence combatwalk "Droideka_WalkForward" loop ACT_COMBATWALK -1 fps 30.00 $sequence attack "Droideka_fire" ACT_RANGE_ATTACK1 -1 fps 30.00 $sequence run "Droideka_RunForward" ACT_RUN 1 fps 30.00 $sequence ragdoll "Droideka_ragdoll" ACT_DIERAGDOLL 1 fps 30.00 $collisionjoints "Droideka_Phys" { $mass 90.0 $inertia 5.00 $damping 0.01 $rotdamping 1.50 $rootbone "root" $noselfcollisions $jointconstrain "clavicle_L" x limit -18.00 18.00 0.00 $jointconstrain "clavicle_L" y limit 0.00 0.00 0.00 $jointconstrain "clavicle_L" z limit -19.00 19.00 0.00 $jointconstrain "clavicle_R" x limit -18.00 18.00 0.00 $jointconstrain "clavicle_R" y limit 0.00 0.00 0.00 $jointconstrain "clavicle_R" z limit -19.00 19.00 0.00 $jointconstrain "elbow_L1" x limit 0.00 0.00 0.00 $jointconstrain "elbow_L1" y limit -74.00 25.00 0.00 $jointconstrain "elbow_L1" z limit 0.00 0.00 0.00 $jointconstrain "elbow_L1" x limit 0.00 0.00 0.00 $jointconstrain "elbow_L1" y limit -74.00 25.00 0.00 $jointconstrain "elbow_L1" z limit 0.00 0.00 0.00 $jointconstrain "elbow_L2" x limit 0.00 0.00 0.00 $jointconstrain "elbow_L2" y limit -73.00 73.00 0.00 $jointconstrain "elbow_L2" z limit 0.00 0.00 0.00 $jointconstrain "elbow_R" x limit 0.00 0.00 0.00 $jointconstrain "elbow_R" y limit -74.00 25.00 0.00 $jointconstrain "elbow_R" z limit 0.00 0.00 0.00 $jointconstrain "elbow_R2" x limit 0.00 0.00 0.00 $jointconstrain "elbow_R2" y limit -73.00 73.00 0.00 $jointconstrain "elbow_R2" z limit 0.00 0.00 0.00 $jointconstrain "headAngle" x fixed 0.00 0.00 0.00 $jointconstrain "headAngle" y fixed -26.00 26.00 0.00 $jointconstrain "headAngle" z fixed 0.00 0.00 0.00 $jointconstrain "headExtend" x fixed 0.00 0.00 0.00 $jointconstrain "headExtend" y Fixed 0.00 0.00 0.00 $jointconstrain "headExtend" z Fixed 0.00 0.00 0.00 $jointconstrain "headHinge_B" x Fixed 0.00 0.00 0.00 $jointconstrain "headHinge_B" y Fixed 0.00 0.00 0.00 $jointconstrain "headHinge_B" z Fixed 0.00 0.00 0.00 $jointconstrain "headHinge_F" x Fixed 0.00 0.00 0.00 $jointconstrain "headHinge_F" y Fixed 0.00 0.00 0.00 $jointconstrain "headHinge_F" z Fixed 0.00 0.00 0.00 $jointconstrain "headHingeBase_B" x Fixed 0.00 0.00 0.00 $jointconstrain "headHingeBase_B" y Fixed 0.00 0.00 0.00 $jointconstrain "headHingeBase_B" z Fixed 0.00 0.00 0.00 $jointconstrain "headHingeBase_F" x Fixed 0.00 0.00 0.00 $jointconstrain "headHingeBase_F" y Fixed 0.00 0.00 0.00 $jointconstrain "headHingeBase_F" z Fixed 0.00 0.00 0.00 $jointconstrain "headPlate" x Fixed 0.00 0.00 0.00 $jointconstrain "headPlate" y Fixed 0.00 0.00 0.00 $jointconstrain "headPlate" z Fixed 0.00 0.00 0.00 $jointconstrain "hip_B" x limit 0.00 0.00 0.00 $jointconstrain "hip_B" y limit -73.00 26.00 0.00 $jointconstrain "hip_B" z limit 0.00 0.00 0.00 $jointconstrain "hip_L" x limit -40.00 40.00 0.00 $jointconstrain "hip_L" y limit -45.00 45.00 0.00 $jointconstrain "hip_L" z limit 0.00 0.00 0.00 $jointconstrain "hip_R" x limit -40.00 40.00 0.00 $jointconstrain "hip_R" y limit -45.00 45.00 0.00 $jointconstrain "hip_R" z limit 0.00 0.00 0.00 $jointconstrain "knee_B" x limit 0.00 0.00 0.00 $jointconstrain "knee_B" y limit -34.00 43.00 0.00 $jointconstrain "knee_B" z limit 0.00 0.00 0.00 $jointconstrain "knee_L" x limit 0.00 0.00 0.00 $jointconstrain "knee_L" y limit -34.00 43.00 0.00 $jointconstrain "knee_L" z limit 0.00 0.00 0.00 $jointconstrain "knee_R" x limit 0.00 0.00 0.00 $jointconstrain "knee_R" y limit -34.00 43.00 0.00 $jointconstrain "knee_R" z limit 0.00 0.00 0.00 $jointconstrain "neck" x fixed 0.00 0.00 0.00 $jointconstrain "neck" y fixed 0.00 0.00 0.00 $jointconstrain "neck" z fixed 0.00 0.00 0.00 $jointconstrain "neckHinge" x Fixed 0.00 0.00 0.00 $jointconstrain "neckHinge" y Fixed 0.00 0.00 0.00 $jointconstrain "neckHinge" z Fixed 0.00 0.00 0.00 $jointconstrain "pistonBicep_L" x Fixed 0.00 0.00 0.00 $jointconstrain "pistonBicep_L" y Fixed 0.00 0.00 0.00 $jointconstrain "pistonBicep_L" z Fixed 0.00 0.00 0.00 $jointconstrain "pistonBicep_R" x Fixed 0.00 0.00 0.00 $jointconstrain "pistonBicep_R" y Fixed 0.00 0.00 0.00 $jointconstrain "pistonBicep_R" z Fixed 0.00 0.00 0.00 $jointconstrain "pistonForearm_L" x Fixed 0.00 0.00 0.00 $jointconstrain "pistonForearm_L" y Fixed 0.00 0.00 0.00 $jointconstrain "pistonForearm_L" z Fixed 0.00 0.00 0.00 $jointconstrain "pistonForearm_R" x Fixed 0.00 0.00 0.00 $jointconstrain "pistonForearm_R" y Fixed 0.00 0.00 0.00 $jointconstrain "pistonForearm_R" z Fixed 0.00 0.00 0.00 $jointconstrain "shoulder_L" x limit -13.00 30.00 0.00 $jointconstrain "shoulder_L" y limit -76.00 76.00 0.00 $jointconstrain "shoulder_L" z limit 0.00 0.00 0.00 $jointconstrain "shoulder_R" x limit -13.00 30.00 0.00 $jointconstrain "shoulder_R" y limit -76.00 76.00 0.00 $jointconstrain "shoulder_R" z limit 0.00 0.00 0.00 $jointconstrain "Spine1" x limit 0.00 0.00 0.00 $jointconstrain "Spine1" y limit -55.00 55.00 0.00 $jointconstrain "Spine1" z limit 0.00 0.00 0.00 $jointconstrain "Spine2" x limit 0.00 0.00 0.00 $jointconstrain "Spine2" y limit -55.00 55.00 0.00 $jointconstrain "Spine2" z limit 0.00 0.00 0.00 $jointconstrain "Spine3" x fixed 0.00 0.00 0.00 $jointconstrain "Spine3" y fixed -55.00 55.00 0.00 $jointconstrain "Spine3" z fixed 0.00 0.00 0.00 }
For walking it's ACT_WALK and for running it's ACT_RUN. But you need to also make walk frames inside the model or QC, I don't really know howto make one. Add me on Steam, there is an animator that knows how to make fully working walk frames, I'll. Steam: DrVrej
[QUOTE=vrej;49285833]For walking it's ACT_WALK and for running it's ACT_RUN. But you need to also make walk frames inside the model or QC, I don't really know howto make one. Add me on Steam, there is an animator that knows how to make fully working walk frames, I'll. Steam: DrVrej[/QUOTE] I sent invitation to you
[QUOTE=Corteziwe;49285946]I sent invitation to you[/QUOTE] Alright
As I understand, when I create ACT_RUN or ACT_WALK I should save any animations with a moving root bone and save it with the name like "walk_*direction*" , right? I've got only four direction: forward, backward, right, left, is it okay? And if I understand right, forward is North direction [IMG]https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Compass_Rose_English_Northeast.svg/600px-Compass_Rose_English_Northeast.svg.png[/IMG]
Sorry, you need to Log In to post a reply to this thread.