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-nmm7 (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-nmm7 (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-nmm7 (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
Odd issue with my potion drinking EVENT.
Author Message
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #1
Odd issue with my potion drinking EVENT.
I'm trying to get my potion drinking script to work, and the only way I can is with a little work around. But, the work around should *not* be required. I'm totally puzzled why it's acting the way it is.

The "Working" script with the work around, you'll notice I had to create a new potion, have the NPC drink that, then consume the original one:

Code:
ON=@GetHit
    IF (<RESTEST 1 i_potion_regeneration_health>) && (<HITPOINTS> < <STR>) && (<EVAL RAND(5)> == 1)
            SERV.NEWITEM i_potion_regeneration_health
            EMOTE drink a <NEW.NAME>!
            NEW.CONT=<findlayer.21.uid>
            USEITEM <NEW>
                 return 1
    ENDIF

What SHOULD work, but isn't. It's actually making the NPC's target attempt to drink the potion in the NPC's backpack.

Code:
ON=@GetHit
    IF (<RESTEST 1 i_potion_regeneration_health>) && (<HITPOINTS> < <STR>) && (<EVAL RAND(5)> == 1)
            EMOTE drink a <NEW.NAME>!
                 findid.i_potion_regeneration_health.useitem
                 return 1
    ENDIF

Any advice? Tongue

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
(This post was last modified: 09-18-2012 11:15 PM by Rayvolution.)
09-18-2012 11:14 PM
Find all posts by this user Like Post Quote this message in a reply
Mordaunt
Super Moderator
****

Posts: 1,237
Likes Given: 26
Likes Received: 55 in 43 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: Odd issue with my potion drinking EVENT.
Doesn't CONSUME make the item work like it has been used?

[Image: 2nis46r.jpg]
09-18-2012 11:34 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: #3
RE: Odd issue with my potion drinking EVENT.
I think because useitem(fired from an item) refers to the src, and in @gethit the src is the character that do the damage.

The workaround works because that USEITEM fires from the character that receives the damage.

You should try to do :
PHP Code:
ON=@GetHit
    
IF (<RESTEST 1 i_potion_regeneration_health>) && (<HITPOINTS> < <STR>) && (<EVAL RAND(5)> == 1)
            
USEITEM <findid.i_potion_regeneration_health//or something similar :P
              
return 
(This post was last modified: 09-19-2012 12:08 AM by darksun84.)
09-19-2012 12:07 AM
Find all posts by this user Like Post Quote this message in a reply
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #4
RE: Odd issue with my potion drinking EVENT.
(09-19-2012 12:07 AM)darksun84 Wrote:  I think because useitem(fired from an item) refers to the src, and in @gethit the src is the character that do the damage.

The workaround works because that USEITEM fires from the character that receives the damage.

You should try to do :
PHP Code:
ON=@GetHit
    
IF (<RESTEST 1 i_potion_regeneration_health>) && (<HITPOINTS> < <STR>) && (<EVAL RAND(5)> == 1)
            
USEITEM <findid.i_potion_regeneration_health//or something similar :P
              
return 

I tried that method also before posting, didn't work. Has the same effect; the attacker tried to use the NPC's potion in the NPC's pack. Sad

I also wanted to make sure it wasnt something totally wonky with my potions (they're completely custom) so I tested it on an i_candle instead of a potion, and when it fired my character (who was attacking the potion drinker) equipped the NPC's i_candle in his pack. lol. Tongue

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
(This post was last modified: 09-19-2012 02:07 AM by Rayvolution.)
09-19-2012 02:06 AM
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: #5
RE: Odd issue with my potion drinking EVENT.
I tried same trigger with default yellow potion and it works Shock
09-19-2012 03:04 AM
Find all posts by this user Like Post Quote this message in a reply
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #6
RE: Odd issue with my potion drinking EVENT.
very strange! When I get home, I'll try again. Maybe I typo'ed/goofed somewhere. I was writing that in the wee hours of the night Tongue

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
09-19-2012 03:59 AM
Find all posts by this user Like Post Quote this message in a reply
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #7
RE: Odd issue with my potion drinking EVENT.
IF (<RESTEST 1 i_potion_heal_minor>) && (<HITPOINTS> < (<STR>/2)) && (<EVAL RAND(5)> == 1)
EMOTE drink a <findid.i_potion_heal_minor.name>! // <--This works! (EDIT: I even removed the .name part and it'll display the UID of the potion it found in the character's pack.)
USEITEM <findid.i_potion_heal_minor>
return 1
ENDIF

Still doesn't work. Sad

Also tried:
findid.i_potion_heal_minor.useitem
findid.i_potion_heal_minor.use
USE <findid.i_potion_heal_minor>

Here's the entire code for everything related to the script..

The Event:
Code:
[EVENTS e_AI_Potion_Drinker]
ON=@GetHit
    IF (<RESTEST 1 i_potion_heal_minor>) && (<HITPOINTS> < (<STR>/2)) && (<EVAL RAND(5)> == 1)
            EMOTE drink a <findid.i_potion_heal_minor.name>!
            USEITEM <findid.i_potion_heal_minor>
                 return 1
    ENDIF

Potion itself:
Code:
[ITEMDEF I_POTION_HEAL_MINOR]
ID I_BOTTLE_SMALL_FULL
NAME Minor Heal Potion
TYPE T_POTION
VALUE
TDATA1 I_BOTTLE_SMALL_EMPTY
RESOURCES I_BOTTLE_SMALL_WATER,I_REAG_GINSENG 2
SKILLMAKE ALCHEMY 5.0
CATEGORY=Aetharia Magic Items
SUBSECTION=Potions
DESCRIPTION=Heal Minor
ON=@CREATE
COLOR 028
MORE1 S_HEAL_POTION
MORE2 30

[SPELL 805]
DEFNAME S_HEAL_POTION
NAME Heal
FLAGS SPELLFLAG_TARG_CHAR|SPELLFLAG_DIR_ANIM| SPELLFLAG_FX_TARG | SPELLFLAG_PLAYERONLY
RUNE_ITEM I_RUNE_ALCHEM_3
DURATION 2*60.0,4*60.0
ON=@EFFECT
IF <SRC.HITS> < <SRC.MAXHITS>
  SRC.HITS += <ARGO.dMORE2>
  IF <SRC.HITS> > <SRC.MAXHITS>
   SRC.HITS <SRC.MAXHITS>
  ENDIF
ENDIF

Changes to t_potion def:
Code:
[TYPEDEF T_POTION]
ON=@DCLICK
IF <TOPOBJ> != <SRC>
SRC.SYSMESSAGENEG <NAME> must be in your backpack.
RETURN 1
ENDIF

The test NPC with the event:
Code:
[CHARDEF c_m_alton_guard]
NAME=#NAMES_HUMANMALE the Alton City Guard
ID=BASE_C_ELF_MALE
DESIRES=i_gold,e_notoriety,t_magic
AVERSIONS=t_TRAP,t_eerie_stuff
TSPEECH=spk_human_prime
TSPEECH=jobGuard
TSPEECH=spk_needs
TSPEECH=spk_rehello
TSPEECH=spk_human_default
TEVENTS=e_Human_HearUnk
TEVENTS=e_Human_Needs
TEVENTS=e_Human_ConvInit
TEVENTS=e_Human_Greet
TEVENTS=e_Human_Space
TEVENTS=e_Human_Refuse
TEVENTS=e_Human_Environ
TEVENTS=e_AI_Guard
TEVENTS=e_AI_Friendly
TEVENTS=e_AI_Potion_Drinker
CATEGORY=Alton Civilized
SUBSECTION=Guards
DESCRIPTION=Guard (male)

ON=@Create
    NPC=brain_human
    COLOR=colors_skin
    STR={100 150}
    DEX={100 150}
    INT={51 65}
    DETECTINGHIDDEN={90.0 100.0}
    FORENSICS={90.0 100.0}
    FENCING={90.0 100.0}
    PARRYING={90.0 100.0}
    SWORDSMANSHIP={30.0 50.0}
    WRESTLING={90.0 100.0}
    MACEFIGHTING={90.0 100.0}
    MAGICRESISTANCE={90.0 100.0}
    TACTICS={90.0 100.0}
    ITEMNEWBIE=random_male_hair
    COLOR=colors_hair
    ITEMNEWBIE=random_facial_hair
    COLOR=match_hair    

ON=@NPCRestock
    ITEM=i_shield_heraldic_bronze
    ITEM=i_broadsword_bronze
    ITEM=i_ringmail_tunic_iron
    ITEM=i_ringmail_sleeves_iron
    ITEM=i_ringmail_gloves_iron
    ITEM=i_leather_gorget
    ITEM=i_cape
    COLOR=colors_blue
    ITEM=i_sash
    COLOR=colors_blue
    ITEM=i_boots_thigh
    ITEM=i_potion_heal_minor,3
    ITEM=t_coin_purse

I'm *completely* stumped. I'm sure it's just a syntax problem with findid though, but what's wrong with it, I have no idea. :/

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
(This post was last modified: 09-19-2012 09:03 AM by Rayvolution.)
09-19-2012 08:24 AM
Find all posts by this user Like Post Quote this message in a reply
Skul
Master
**

Posts: 413
Likes Given: 0
Likes Received: 19 in 15 posts
Joined: Jun 2012
Reputation: 9



Post: #8
RE: Odd issue with my potion drinking EVENT.
Maybe useitem does not accept an argument? Try using trysrc to do it.

"I ask a question to the answer I already know."

Marchadium :: http://www.marchadium.ca/ :: Join us!
09-19-2012 12:04 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: #9
RE: Odd issue with my potion drinking EVENT.
maybe on the typedef t_potion part

SRC it's considered attacker i guess, so as skul wrote you can use trysrc on useitem
09-20-2012 07:26 AM
Find all posts by this user Like Post Quote this message in a reply
Rayvolution
Journeyman
*

Posts: 135
Likes Given: 0
Likes Received: 2 in 2 posts
Joined: Jul 2012
Reputation: 1

Aetharia

Post: #10
RE: Odd issue with my potion drinking EVENT.
Hrm, what would be the correct syntax for TRYSRC? I've never used it before, and the syntaxes ived tried on the wiki aren't working Tongue

[Image: 4_Logo.png]
An MMORPG based on the Ultima Online engine.
Completely Custom Map, GUI, AI, Combat, Skills, Crafts, Art, Music and so much more.
http://aetharia.com - Home of Ambition!
09-20-2012 07:42 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


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