Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mining NPC
Author Message
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #1
Mining NPC
i would like to know if it's possible to make a NPC that moves arround mining (make the anim of mining). I am kinda new so please be patience with me.

THank you very much.
05-05-2014 10:47 AM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #2
RE: Mining NPC
just create a random human npc and equip this pickaxe on his hand

Code:
[ITEMDEF i_pickaxe_anim]
ID=i_pickaxe

ON=@Equip
TIMER=5

ON=@Timer
CONT.ANIM 4 //I cant remember the mining animation number, keep trying numbers 0, 1, 2, 3, ...
TIMER=5
return 1
(This post was last modified: 05-05-2014 02:11 PM by Coruja.)
05-05-2014 02:11 PM
Find all posts by this user Like Post Quote this message in a reply
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #3
RE: Mining NPC
thats fine, but if it gets killed, will drop the item and every1 would have it Confused (rare pickaxe)
either way, would be cool if it stops mining after a while, walks around some time and starts again with the mining, that would be the loop ;D
(This post was last modified: 05-05-2014 02:51 PM by kn4tseb.)
05-05-2014 02:49 PM
Find all posts by this user Like Post Quote this message in a reply
karma
Moderator
****

Posts: 178
Likes Given: 17
Likes Received: 32 in 29 posts
Joined: Jul 2012
Reputation: 3



Post: #4
Mining NPC
You can give to the npc the pickaxe using, in his @Create, ITEMNEWBIE=i_pickaxe_anim. Doing this, it will be inlootable and if the npc is killed the item won't be dropped.
Alternatively you can do:
ITEM=i_pickaxe_anim
ATTR |= attr_newbie
In this way you give at the npc the pickaxe and add it the newbie (inloot) attr.

Also you can manipulate the TIMER, using TIMER={5 30}, so time between anims is a random number going from 5 to 30 and furthermore the npc has more time to walk around. If you want to force its walking around behaviour, in the wiki there are functions like WALK, RUN, MOVETO, GOTO or something similar, i don't remember precisely now, just give it a look!
(If you want to force the npc walking around i can expend more words on that, even if i think it's better do let it follow the default ai, which also make it walk around. Maybe we can work on the maximum distance it may reach from the spawn point, which is HOMEDIST).
(This post was last modified: 05-05-2014 10:12 PM by karma.)
05-05-2014 06:26 PM
Find all posts by this user Like Post Quote this message in a reply
Coruja
Sphere Developer
*****

Posts: 987
Likes Given: 5
Likes Received: 226 in 187 posts
Joined: Jul 2012
Reputation: 7

Dimension Shard

Post: #5
RE: Mining NPC
I posted the last script 1am when I was sleepy, here's a improved one
it will play the correct mining animation and prevent the npc walk while playing the anim. Also the item now has attr_newbie, will decay correctly if dropped on ground and wont give console errors if you pick up the pickaxe from the NPC hands

PS: to make it walk just set a world spawn of this npc instead add it using .add c_npc. If you doesnt have a GM tool (like axis) to create spawns, just .dupe another one and set .xMORE1=c_your_npc and .xMOREZ=6 (this is the max distance it will walk from spawn)
Code:
[ITEMDEF i_pickaxe_anim]
ID=i_pickaxe

ON=@Create
ATTR=attr_newbie

ON=@Equip
TIMER=1

ON=@Timer
IF (<CONT.ISCHAR>)
  CONT.TAG.NOMOVETILL=<eval <SERV.TIME>+15>
  CONT.ANIM 9
  TIMER=<R3,6>
  return 1
ENDIF
05-06-2014 02:04 AM
Find all posts by this user Like Post Quote this message in a reply
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #6
RE: Mining NPC
Thanks alot!
05-06-2014 02:22 AM
Find all posts by this user Like Post Quote this message in a reply
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #7
RE: Mining NPC
one more thing, npc wont start "mining" till someone @equip the item on it.... so even if it has the item on its hand, needs to be activated.
05-06-2014 04:15 AM
Find all posts by this user Like Post Quote this message in a reply
Alaric
Journeyman
*

Posts: 227
Likes Given: 7
Likes Received: 9 in 4 posts
Joined: Oct 2012
Reputation: 7



Post: #8
RE: Mining NPC
set on=@create timer 5 then... But i would personally attach everything on the npc, not the item.
(This post was last modified: 05-06-2014 07:29 AM by Alaric.)
05-06-2014 07:28 AM
Find all posts by this user Like Post Quote this message in a reply
kn4tseb
Master
**

Posts: 392
Likes Given: 45
Likes Received: 10 in 10 posts
Joined: May 2014
Reputation: 0



Post: #9
RE: Mining NPC
will try

Thanks again.
05-06-2014 08:22 AM
Find all posts by this user Like Post Quote this message in a reply
karma
Moderator
****

Posts: 178
Likes Given: 17
Likes Received: 32 in 29 posts
Joined: Jul 2012
Reputation: 3



Post: #10
Mining NPC
A better approach, as said by Alaric, would be to put in @Create of the char:
ITEM=i_pickaxe_anim
TIMER=5
So the timer will be set only if is the npc to equip the pickaxe.
If you do this you can avoid TIMER=1 in @Equip.

Btw, Coruja, i didn't know that tag, is there a guide or a list of these new tags? I've seen the new ones related to combat but not this
(This post was last modified: 05-06-2014 10:43 PM by karma.)
05-06-2014 07:03 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)