The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm6 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strange issue with NPC equipping item
Author Message
Soulless
Super Moderator
****

Posts: 335
Likes Given: 29
Likes Received: 49 in 27 posts
Joined: Jun 2012
Reputation: 12

Ye Olde Sphere

Post: #1
Strange issue with NPC equipping item
So, I have an NPC ive made and it has a trigger under it's chardef that is supposed to make it decide what item to equip during what circumstance
Here's the chunk of code that makes it decide what to do

Code:
on=@NPCActFight
if <argn1> <=2
  findid.i_axe.equip
  elseif <argn1> > 2
  findid.i_pumpkin_launcher.equip
endif

so what happens is that it actually equips the item on the player he is attacking. first it equips the bow on the player because he's typically more then 2 tiles away, then since he doesnt have anything in his hands he charges at the player, then when he's within 2 tiles it equips the axe onto the player.

am i using findid wrong? have I been away too long and lost my goddamn mind?

here's the whole thing chardef included

Code:
[CHARDEF c_headless_horseman]
ID=c_man
NAME=Headless Horseman
SOUND=snd_HUMAN_M_DIE_01
DAM=10,20
ARMOR=30
CAN=MT_WALK|MT_RUN|MT_EQUIP|MT_USEHANDS
DESIRES=i_gold,e_notoriety
// AVERSIONS=t_TRAP,t_eerie_stuff
// ALIGNMENT=EVIL

tspeech=spk_human_prime
tspeech=jobMageEvil
tspeech=spk_needs
tspeech=spk_rehello
tspeech=spk_human_default
//TEVENTS=monster_tag        //if you use these events, uncomment them
//TEVENTS=e_fame_karma_gain

ON=@Create
color=055555
str={450 500}
dex={300 350}
int={200 250}
PARRYING={85.0 98.0}
SWORDSMANSHIP={90.0 95.0}
ARCHERY={90.0 95.0}
WRESTLING={67.0 90.0}
MAGICRESISTANCE={90.0 98.0}
TACTICS={90.0 98.0}
POISONING={90.0 100.0}
NPC=brain_monster
FAME=8000
KARMA=-9999

ON=@NPCRestock
item=i_BLACKROCK_RINGMAIL_GLOVES
item=i_BLACKROCK_RINGMAIL_SLEEVES
item=i_BLACKROCK_RINGMAIL_TUNIC
item=i_BLACKROCK_RINGMAIL_LEGGINGS
item=i_CAPE
color=0053f
item=i_SASH
color=0053f
item=i_boots_calf
color=0053f
itemnewbie=i_axe
itemnewbie=i_pumpkin_launcher
item=i_potion_healgreat
item=i_potion_healgreat
item=i_potion_healgreat
item=i_potion_healgreat
item=i_potion_healgreat
item=random_jewel
item=random_jewel
item=random_jewel
item=random_jewel
item=i_gold,{400 1000}
item=i_mt_horse_tan
color=0455

on=@NPCActFight
if <argn1> <=2
  findid.i_axe.equip
  elseif <argn1> > 2
  findid.i_pumpkin_launcher.equip
endif
dorand 3
  sound 1001
  sound 1003
  sound 1004
enddo

Confused
(This post was last modified: 07-19-2017 02:28 PM by Soulless.)
07-19-2017 02:27 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 245
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: Strange issue with NPC equipping item
You have to do:
Code:
on=@NPCActFight
if <argn1> <=2
  equip <findid.i_axe>
elseif <argn1> > 2
  equip <findid.i_pumpkin_launcher>
endif

Using findid.i_axe.equip will cause the SRC to try to equip the weapon, and in @NpcActfight SRC is the player being attacked.
07-19-2017 06:01 PM
Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes darksun84's post
Soulless
Super Moderator
****

Posts: 335
Likes Given: 29
Likes Received: 49 in 27 posts
Joined: Jun 2012
Reputation: 12

Ye Olde Sphere

Post: #3
RE: Strange issue with NPC equipping item
Thank you my good man, and that you are, a very very good man
07-20-2017 02:32 AM
Visit this user's website 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)