Raised This Month: $12 Target: $400
 3% 

How To: Make a perfect NPC


Post New Thread Reply   
 
Thread Tools Display Modes
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 09-03-2010 , 10:16   Re: How To: Make a perfect NPC
Reply With Quote #191

Quote:
Originally Posted by Guppy488 View Post
How do i make a Store Owner Using this?anyone care to teach? Willing To Learn,Private Message me thx.
Set up your npc like you want it to be, then register_touch("npc_classname", "player", "Fwd_Touch_Npc");
And start making your menu and stuff in there.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
dstopgunner
Senior Member
Join Date: Oct 2007
Old 09-03-2010 , 14:25   Re: How To: Make a perfect NPC
Reply With Quote #192

need help someone..
to make it bleed when i shootz it

PHP Code:
register_event("Damage","Damage","be","2!0","3=0"
(Side question , which file under include can i find the event damage flags , conditions etc)

PHP Code:
public Damage(ent)
{
 
client_print(0,print_chat,"[TEST] Damage recieved by entity.")
 new 
classname[32]
 
pev(entpev_classnameclassname31)
 
 new 
origin[3]
 
get_user_origin(ent,origin)
 new 
hitpointweapon
 get_user_attacker
(ent,weapon,hitpoint)
 if(
equal(classname"NPC"))
 {
  switch(
hitpoint)
  {
   case 
1:
   {
    
get_user_origin(ent,origin,1)
   }
   case 
2:
   {
    
origin[2] += 25
   
}
   case 
3:
   {
    
origin[2] += 10
   
}
   case 
4:
   {
    
origin[2] += 10
    origin
[0] += 5
    origin
[1] += 5
   
}
   case 
5:
   {
    
origin[2] += 10
    origin
[0] -= 5
    origin
[1] -= 5
   
}
   case 
6:
   {
    
origin[2] -= 10
    origin
[0] += 5
    origin
[1] += 5
   
}
   case 
7:
   {
    
origin[2] -= 10
    origin
[0] -= 5
    origin
[1] -= 5
   
}
  }
  
client_print(0,print_chat,"[TEST] Making blood.")
  
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  
write_byte(TE_BLOODSPRITE)
  
write_coord(origin[0])
  
write_coord(origin[1])
  
write_coord(origin[2])
  
write_short(blood)
  
write_short(blood)
  
write_byte(78)
  
write_byte(10)
  
message_end()
  
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  
write_byte(TE_BLOODSPRITE)
  
write_coord(origin[0])
  
write_coord(origin[1])
  
write_coord(origin[2])
  
write_short(blood)
  
write_short(blood)
  
write_byte(78)
  
write_byte(12)
  
message_end()
  
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  
write_byte(TE_BLOODSPRITE)
  
write_coord(origin[0])
  
write_coord(origin[1])
  
write_coord(origin[2])
  
write_short(blood)
  
write_short(blood)
  
write_byte(78)
  
write_byte(15)
  
message_end()
 }

Both test messages dont come out when i shoot it



and another question , how do i make a dying animation for it when it just dissappears when it reaches 0 hp after i shoot it alot

Last edited by dstopgunner; 09-03-2010 at 14:47.
dstopgunner is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 09-03-2010 , 16:13   Re: How To: Make a perfect NPC
Reply With Quote #193

Quote:
Originally Posted by dstopgunner View Post
PHP Code:
register_event("Damage","Damage","be","2!0","3=0"
(Side question , which file under include can i find the event damage flags , conditions etc)
I don't know if Damage is called when you shoot an npc, I guess you could try with Ham_TakeDamage.

Damage event flags.
http://wiki.alliedmods.net/Half-Life..._Events#Damage
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
dstopgunner
Senior Member
Join Date: Oct 2007
Old 09-03-2010 , 16:21   Re: How To: Make a perfect NPC
Reply With Quote #194

okay ill try it later on , how about the dying animations? how do i do it when it just dissappears at 0hp
dstopgunner is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 09-03-2010 , 22:07   Re: How To: Make a perfect NPC
Reply With Quote #195

I'm not sure, but i think you can hook Ham_Killed like this.

Code:
RegisterHam(Ham_Killed, "npc_classname", Fwd_Ham_Killed);
block that, play the animation, and then remove the npc.

I'm not sure about this though. If my pc wasn't broken i would test it myself.
I'm on an old laptop now, it can't even run cs like it should.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
dstopgunner
Senior Member
Join Date: Oct 2007
Old 09-04-2010 , 01:17   Re: How To: Make a perfect NPC
Reply With Quote #196

appreciated if any1 can help +rep
tried hooking death and takedamage by HAM

PHP Code:
 RegisterHam(Ham_TakeDamage"npc_lychon""hook_TakeDamage")
 
RegisterHam(Ham_Killed"npc_lychon""Fwd_Ham_Killed"); 
did i make any error/mistake?

PHP Code:
public Fwd_Ham_Killed(ent)
{
 new 
classname[32]
 
pev(entpev_classnameclassname31)
 if(!
is_user_alive(ent) && equal(classname"npc_lychon"))
 {
  
client_print(0,print_chat,"[TEST] NPC DIED.")
  
entity_set_int(ent,EV_INT_sequence,random_num(9,10))
  return 
PLUGIN_HANDLED
 
}
 return 
PLUGIN_CONTINUE

the test npc died message didnt appear and the NPC still disappears once its HP reach 0 and i cant make any death animation =/

PHP Code:
public hook_TakeDamage(ent)
{
 
client_print(0,print_chat,"[TEST] Damage recieved by entity.")
 new 
classname[32]
 
pev(entpev_classnameclassname31)
 
 new 
origin[3]
 
get_user_origin(ent,origin)
 new 
hitpointweapon
 get_user_attacker
(ent,weapon,hitpoint)
 if(
equal(classname"npc_lychon"))
 {
  switch(
hitpoint)
  {
   case 
1:
   {
    
get_user_origin(ent,origin,1)
   }
   case 
2:
   {
    
origin[2] += 25
   
}
   case 
3:
   {
    
origin[2] += 10
   
}
   case 
4:
   {
    
origin[2] += 10
    origin
[0] += 5
    origin
[1] += 5
   
}
   case 
5:
   {
    
origin[2] += 10
    origin
[0] -= 5
    origin
[1] -= 5
   
}
   case 
6:
   {
    
origin[2] -= 10
    origin
[0] += 5
    origin
[1] += 5
   
}
   case 
7:
   {
    
origin[2] -= 10
    origin
[0] -= 5
    origin
[1] -= 5
   
}
  }
  
client_print(0,print_chat,"[TEST] Making blood.")
  
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  
write_byte(TE_BLOODSPRITE)
  
write_coord(origin[0])
  
write_coord(origin[1])
  
write_coord(origin[2])
  
write_short(blood)
  
write_short(blood)
  
write_byte(78)
  
write_byte(10)
  
message_end()
  
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  
write_byte(TE_BLOODSPRITE)
  
write_coord(origin[0])
  
write_coord(origin[1])
  
write_coord(origin[2])
  
write_short(blood)
  
write_short(blood)
  
write_byte(78)
  
write_byte(12)
  
message_end()
  
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  
write_byte(TE_BLOODSPRITE)
  
write_coord(origin[0])
  
write_coord(origin[1])
  
write_coord(origin[2])
  
write_short(blood)
  
write_short(blood)
  
write_byte(78)
  
write_byte(15)
  
message_end()
 }

both test damage recieve and blood making messages didnt appear


and I try to make it think and show knifing animation , havnt coded the damage yet but it has some errors.
im trying to make it knife the nearest person next to it

PHP Code:
public npc_think(ent)
{
 new 
npcorigin[3]
 
get_user_origin(entnpcorigin)
 
 new 
closestTarget 0Float:closestDistanceFloat:distanceFloat:closestOrigin[3], Float:playerOrigin[3]
 for (new 
1<= MAX_PLAYERSi++) 
 {
  if (!
is_user_connected(i) || !is_user_alive(i)) // temporarily dont check team:
   
continue
  
get_user_origin(iplayerOrigin)
  
distance vector_distance(npcoriginplayerOrigin)
  
closestOrigin playerOrigin
  
if (distance closestDistance || closestTarget == 0
  {
   
closestTarget i
   closestDistance 
distance
  
}
 }
 if (
closestTarget) {
  new 
rand random_num(1,3)
  {
   switch(
rand)
   {
    case 
1:{entity_set_int(ent,EV_INT_sequence,5);} // making animation but didnt see any
    
case 2:{entity_set_int(ent,EV_INT_sequence,6);}
    case 
3:{entity_set_int(ent,EV_INT_sequence,7);}
   }
  }
 }

I didnt see the animation

Last edited by dstopgunner; 09-04-2010 at 01:20.
dstopgunner is offline
Guppy488
Member
Join Date: Jul 2010
Location: Guppy's Scripting Lab
Old 09-04-2010 , 04:20   Re: How To: Make a perfect NPC
Reply With Quote #197

Quote:
Originally Posted by drekes View Post
Set up your npc like you want it to be, then register_touch("npc_classname", "player", "Fwd_Touch_Npc");
And start making your menu and stuff in there.
can you help me by using twlight's code? i don't know how to make a menu too..not sure about menus and "fwd_touch_npc"
Guppy488 is offline
Freedom
Member
Join Date: Jun 2010
Location: Turkey/Istanbul
Old 09-05-2010 , 13:15   Re: How To: Make a perfect NPC
Reply With Quote #198

how can I set npcs animations?
Freedom is offline
Send a message via MSN to Freedom
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 09-05-2010 , 19:34   Re: How To: Make a perfect NPC
Reply With Quote #199

Quote:
Originally Posted by Guppy488 View Post
can you help me by using twlight's code? i don't know how to make a menu too..not sure about menus and "fwd_touch_npc"
There's a tutorial on how to make menu's in this section by Emp`
And Fwd_Touch_Npc is called when someone touches your npc.

Quote:
Originally Posted by Freedom View Post
how can I set npcs animations?
Quote:
Originally Posted by Twilight Suzuka View Post
5.
Ok, now lets give it a default animation.

Code:
      entity_set_float(ent,EV_FL_animtime,2.0)      
   entity_set_float(ent,EV_FL_framerate,1.0) 
   entity_set_int(ent,EV_INT_sequence,0);
Note: Sets the frameRate (framerate for ent), animation time (max time for an animation, and sequence (the actual animation). You do not really need animtime, but I think better safe then sorry.
Just change the EV_INT_sequence to the sequence you want.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 09-05-2010 at 19:37.
drekes is offline
Send a message via MSN to drekes
Freedom
Member
Join Date: Jun 2010
Location: Turkey/Istanbul
Old 09-06-2010 , 01:47   Re: How To: Make a perfect NPC
Reply With Quote #200

Quote:
Originally Posted by drekes View Post
Just change the EV_INT_sequence to the sequence you want.
thx a lot =)
Freedom is offline
Send a message via MSN to Freedom
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 14:11.


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