Raised This Month: $ Target: $400
 0% 

Walking NPC's


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AlexanderM
Junior Member
Join Date: Dec 2007
Old 10-03-2008 , 08:11   Walking NPC's
Reply With Quote #1

Hi All

I have a little problem, with creating a NPC, that can walk.
I made my NPC over the tutorial Twilight Suzuka (http://forums.alliedmods.net/showthread.php?t=11756) created, but I just didn't get what he meant about 'EngFunc_RunPlayerMove'.

I have used the some time searching the forum, but I couldn't really find some explanation. Maby it's just me that didn't read the tutorial right, I don't know

So my help request in short is, how do you use 'EngFUnc_RunPlayerMove', or how do you make a NPC walk.


(Please C&P the Example Code this into your thread, showing how I could make my NPC walk)
Example Code:
Code:
/* Zombie Attack! By Alexander Mathiasen. */

#include <amxmodx>
#include <engine>
#include <fakemeta>

#define PLUGIN    "Zombie Attack!"
#define AUTHOR    "Alexander Mathiasen"
#define VERSION    "1.0"



public plugin_init()
{
    register_plugin("Zombie Attack!", "1.0", "Alexander Mathiasen")

    register_think("npc_zombie", "zombie_think");
    //register_cvar("za_zombie_health", "100.0");
    register_clcmd(".create", "zombie_spawn");
}

/**/
public plugin_precache()
{
    /**/
    precache_model("/models/zombie attack/zombie.mdl");
    precache_model("/models/zombie attack/p_knife.mdl");
}

public zombie_spawn(id)
{
    /* Creates a new Float 'origin'. */
    new Float: origin[3];
    
    /* Get Players Cordinates. */
    entity_get_vector(id, EV_VEC_origin, origin);
    
    /* Creates a new Variable 'eZombie' to store the entity to. */
    new eZombie = create_entity("info_target");
    
    /**/
    zombie_knife(eZombie);
    
    /* Moves Player. */
    entity_set_origin(eZombie, origin);
    origin[2] += 300.0;
    entity_set_origin(id, origin);
    
    /* Makes the Entity 'eZombie' able to take damage. */
    entity_set_float(eZombie, EV_FL_takedamage, 1.0)
    
    /* Sets the Health of the Zombie 'eZombie' to the Cvar 'za_zombie_health'. */
    entity_set_float(eZombie, EV_FL_health, 250.0);
    
    /* Sets the Classname of the Entity 'eZombie' to 'npc_zombie'. */
    entity_set_string(eZombie, EV_SZ_classname, "npc_zombie");
    
    /* Sets the Model of the Entity 'eZombie'. */
    entity_set_model(eZombie, "/models/zombie attack/zombie.mdl");
    
    /* Makes the Entity 'eZombie' solid. */
    entity_set_int(eZombie, EV_INT_solid, 2);
    
    entity_set_byte(eZombie,EV_BYTE_controller1, 125);     
    entity_set_byte(eZombie,EV_BYTE_controller2, 125);     
    entity_set_byte(eZombie,EV_BYTE_controller3, 125);     
    entity_set_byte(eZombie,EV_BYTE_controller4, 125);
    
    /* Creates 2 Floats to store the size of the entity. */
    new Float:maxs[3] = {16.0,16.0,36.0}
    new Float:mins[3] = {-16.0,-16.0,-36.0}
    
    /* Sets the Entity 'eZombie' minimum size to the Float 'mins', 
     * and the maximum size to the Float 'maxs'.. */
    entity_set_size(eZombie, mins, maxs);
    
    /* ... */
    entity_set_float(eZombie, EV_FL_animtime, 2.0);
    /* ... */
    entity_set_float(eZombie, EV_FL_framerate, 1.0);
    /* ... */
    entity_set_int(eZombie, EV_INT_sequence, 0);
    
    
    /* Makes the zombie think every 1/100 second. 
     * (Calls this block of code again, like 'this.Invalidate()' in C#. */
    entity_set_float(eZombie, EV_FL_nextthink, halflife_time() + 0.01);

    
    return 1;
}

public zombie_think(id)
{
    
    /* Makes the zombie think every 1/100 second. 
     * (Calls this block of code again, like 'this.Invalidate()' in C#. */
    entity_set_float(id, EV_FL_nextthink, halflife_time() + 0.75);
    
}

public zombie_knife(ent)
{

    /* Creates a new Variable 'eWeapon' that holds on the Entity 'eWeapon'. */
    new eWeapon = create_entity("info_target");

    /* Gives the Entity 'eWeapon' a name 'npc_knife'. */
    entity_set_string(eWeapon, EV_SZ_classname, "npc_knife");
    
    /* Tells the Entity to follow a other Entity. */
    entity_set_int(eWeapon, EV_INT_movetype, MOVETYPE_FOLLOW);
    
    /* Makes the Entity Non Solid, meaning that you can go through.*/
    entity_set_int(eWeapon, EV_INT_solid, SOLID_NOT);
    
    /* This is the Entity the Entity 'eWeapon' should follow. */
    entity_set_edict(eWeapon, EV_ENT_aiment, ent);
    
    /* Gives the Entity a Model. */
    entity_set_model(eWeapon, "/models/zombie attack/p_knife.mdl");
    
}
Sorry for all wrong or none comented code, would like to hear everything i understanded wrong there to

Thanks in advance, Alexander M
__________________
Uhm... More Pizza...
______________________________
| Home | Search | Google | Steam |

Last edited by AlexanderM; 10-03-2008 at 08:59.
AlexanderM is offline
Old 10-03-2008, 12:43
AlexanderM
This message has been deleted by Exolent[jNr]. Reason: Don't bump until 2 weeks have passed since last post.
Orangutanz
Veteran Member
Join Date: Apr 2006
Old 10-04-2008 , 03:50   Re: Walking NPC's
Reply With Quote #2

EngFUnc_RunPlayerMove is for bots, if your not desigining a bot (which your not) then ignore this.
EngFunc_WalkMove is for monsters. Search HLSDK how to use etc.
__________________
|<-- Retired from everything Small/Pawn related -->|
You know when you've been Rango'd
Orangutanz is offline
AlexanderM
Junior Member
Join Date: Dec 2007
Old 10-04-2008 , 08:55  
Reply With Quote #3

So I missed something Thank you for the help Orangutanz

EDIT:

Just one more question. You said 'HL SDK', program or website?
Again thanks for the help

EDIT 2:

Hmmm... I've played a little around with the enfunc(EngFunc_WalkMove)...
Im not sure about what they mean about 'Yaw' and 'iMode', my zombie is still standing the same place, that I spawned him :S

Code:
      //const ENTITY, Float:yaw, Float:distance, iMode
      engfunc(EngFunc_WalkMove, id, 0.5, 50.0, WALKMOVE_NORMAL);
Could you please post an example?

Alexander
__________________
Uhm... More Pizza...
______________________________
| Home | Search | Google | Steam |

Last edited by Exolent[jNr]; 10-31-2008 at 11:13. Reason: If you have the last post in a topic, edit it. Don't post another.
AlexanderM is offline
Old 10-31-2008, 10:26
Mazzerin
This message has been deleted by Exolent[jNr]. Reason: Don't act as a moderator if you are not one.
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-09-2008 , 18:12   Re: Walking NPC's
Reply With Quote #4

I've been doing some testing, and the yaw is the angle referenced to the X axis of the model for the NPC to be running.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode