• Pill Framework
    36 replies, posted
[QUOTE=Lol-Nade;23748580]Umm a dumb question, I tried to my best of abilities create a hunter pill, and when I went to test it out it didn't show up in my weapons folder. [code] Including Actions Including Base Action Action action_base successfully registered! including action_antlion Action action_antlion successfully registered! including action_headcrab Action action_headcrab successfully registered! including action_hunter Couldn't include file 'pills\pill_hunter\actions.lua' (File not found) Achievements disabled: Steam not running. Achievements disabled, ignoring achievement progress for GMA_BADCODER Hook 'PFW_LOADPILLS' Failed: addons\pill_framework\lua\autorun\shared.lua:126: bad argument #1 to 'gsub' (string expected, got nil)[/code][/QUOTE] Does your actions file have ACTION.Base = "action_base" at the top? [editline]09:22PM[/editline] In fact, post your actions file.
[QUOTE=grea$emonkey;23748674]Does your actions file have ACTION.Base = "action_base" at the top?[/QUOTE] Yeah, I do Edit: I don't actually know how to create actions for the hunter, I'm pretty new with this stuff. So I just kinda copied the actions from the headcrab :( Edit2: Scratch that I now understand what I'm doing, I'm currently trying to map out the actions in action_plan. I found your helpful documentation hidden in the addons folder.
[QUOTE=Lol-Nade;23748853]Yeah, I do Edit: I don't actually know how to create actions for the hunter, I'm pretty new with this stuff. So I just kinda copied the actions from the headcrab :([/QUOTE] Add me on steam. I'll help you out. [editline]10:12PM[/editline] Here is an actions tutorial I wrote. A little lengthy, but it's all pretty important. [code] HOW ACTIONS WORK: It occurred to me that the only clean, for-sure way to make a character entity act correctly under all circumstances, is to simply program every circumstance! Writing your actions file: Step 1: Planning Do not start writing your actions file until you know exactly what you'll be doing. A. Make a list of actions for your pill. Anything that effects the player and/or character entity in terms of movement or appearence classifies as an Action. For example: Idle Walk Run Attack B. Now for every item on your list, make a list of actions that you want it to be able to transition to from it. For example: Idle Walk Run Attack Walk Idle Run Attack Run Idle Walk Attack Attack Idle Walk Run In this particular case, every action can transition to any of the others. C. Now write it as a list in terms of transitions: Idle -> Walk Idle -> Run Idle -> Attack Walk -> Idle Walk -> Run Walk -> Attack Run -> Idle Run -> Walk Run -> Attack Attack -> Idle Attack -> Walk Attack -> Run Sometimes you may have a transition that requires a different action in place first. Lets change our list a little. Idle -> Walk Idle -> Run Walk -> Idle -> Attack Walk -> Idle Walk -> Run Walk -> Attack Idle -> Run -> Idle Walk -> Run -> Walk Run -> Attack Walk -> Idle -> Attack -> Idle Attack -> Walk Attack -> Run Walk -> In this example, we cannot go directly from idle to run; we need to use walk as a medium to go between them. In addition, we need to be in idle before we can attack, so walk is also used as a medium for that. When we program this out, it will make more sense. Step 2: Setting up Okay, now we set up our actions.lua file. A. Writing your ACTION.Begin function. This function is called whenever the pill weapon is pulled out. Use it to decide which action to start with give the player's current circumstances. NOTE: In actions whenever we have "ply, ent" as arguments, ply is the player, and ent is the character entity. Use player:SetAction( action ) to set their initial action. Example: function ACTION:Begin( ply, ent ) if ply:KeyDown( IN_FORWARD ) or ply:KeyDown( IN_BACK ) or ply:KeyDown( IN_MOVELEFT ) or ply:KeyDown( IN_MOVERIGHT ) then ply:SetPillAction( "Walk" ) else ply:SetPillAction( "Idle" ) end end B. Writing the ACTION.RenderCharacterEntity function. The RenderCharacterEntity function is for general rendering, and is optional. Used for render properties that are present across more than one action. Good for stuff like setting render angles/origin. You could use it for things like setting head angles on the character ent to the player's head angles. Example: function ACTION:RenderCharacterEntity( ply, ent ) local ang = ply:GetAngles() if ply:OnGround() then ang.pitch = 0 -- Just to be sure that it doesn't follow the player's view pitch. end ent:SetRenderAngles( ang ) ent:SetRenderOrigin( ply:GetRenderOrigin() ) end Step 3: Writing A. Creating a new action For every action you listed write a line like this: ACTION.Actions.<MyAction> = {} This sets up a table for that action. This table will have a series of functions that are used to perform the action. B. Adding methods to your action. You only need two functions in this table, one of which is required. The ACTION.Actions.<MyAction>:ShouldPerform( ply, ent ) method is required in every action. ShouldPerform is the MOST IMPORTANT METHOD. It determines whether we are allowed to use the current action. Writing your ShouldPerform functions: ShouldPerform takes two arguments: ply (the player to perform it on) and ent (their character entity). The main purpose of ShouldPerform is for detouring actions. This method is automatically called whenever you use player.SetPillAction and then in an internal Think method to see if it should be changed at any given moment. The Think method is only called for the player's current action. If ShouldPerform returns false in player.SetPillAction, the action you tried to set will not get set, however, any actions you detoured to in ShouldPerform will get set. This means you could have a chain of detours by trying to set an action whose conditions were not met. If you set up your list of transitions right, there will always be an action that can be linked to your current one, and there will be no disputes over which one to change to. If you didn't, you'll have a leak in your transition flow, and something will not get set properly. When it returns false, the action it's associated with will not be performed. You should return true as a blanket statement to ensure the action is performed. When a condition is met to change actions, use player:SetPillAction( action ) method in it and return false. This is where that action list you made in Step 1 comes in. Here's how Idle would translate: ACTION.Actions.Idle = {} function ACTION.Actions.Idle:ShouldPerform( ply, ent ) if ply:KeyDown( IN_ATTACK ) then ply:SetPillAction( "Attack" ) return false -- We want Attack to take priority. end if ply:KeyDown( IN_FORWARD ) or ply:KeyDown( IN_BACK ) or ply:KeyDown( IN_MOVELEFT ) or ply:KeyDown( IN_MOVERIGHT ) then ply:SetPillAction( "Walk" ) return false -- We don't need to add anything for running since we need to be walking first anyways. end return true -- Blanket statement telling us to perform this when everything else has passed. end function ACTION.Actions.Idle:Render( ply, ent ) -- A lot of models use this as their idle animation ent:SetSequence( ent:LookupSequence( "Idle01" ) ) end That's why you need to plan it before writing it. Now you can add one or more of the following. CalcView( ply, origin, angles, fov ) Only use this if you want a special calcview for this action Clientside only. Move( ply, move ) Works just like the normal move hook. Shared. CharacterEntityMove( ply, ent, phys, delta ) This is called inside the character entity PhysicsSimulate method. This is only called if PILL.UseCharacterEntityMovement is true. Serverside only. CreateMove( ply, ucmd ) Modifies client input before it's performed (IN_* Keys, View Angle control, etc.). Clientside only. Render( ply, ent ) Use this for setting animations and general rendering of the character entity. Clientside only. Think( ply, ent ) This is called from the weapon Think method. Shared. If you've written all your actions out, you're done! Step 4: DONE! If you've written everything out correctly and to your plans, it should work like a charm. [/code]
yeah I found that tutorial, I'm working on it now. Finding it a little difficult though, I'll try and hit you up on Steam if it ever updates. I gave up @_@ Someone else please take up the task of making a hunter pill
This Framework is great! but I have some questions about the creation of the pills, I'm going to create a ''pill_strider'' but the question I want to bring you this: what you need to edit the lua file to display a model strider? you'll excuse me, but I'm a beginner with these things, I'm going to learn very well the process for future creations :smile:
I managed to bring up the model of the strider, strider but when I become the model appears below the soil line. any ideas?
Awesome :D
Sorry, you need to Log In to post a reply to this thread.