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
Tags....
Author Message
Lincoln
Apprentice
*

Posts: 11
Likes Given: 13
Likes Received: 0 in 0 posts
Joined: Apr 2016
Reputation: 0



Post: #1
Tags....
Hello All,

I am trying to make a system that when a monster is killed it applies a tag to an item...
So with every monster killed the tag on the item increases...

Any suggestions on how I would accomplish this?
I really do struggle with tags, not sure why
11-25-2016 12:51 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: #2
RE: Tags....
Simple Example:
PHP Code:
[ITEMDEF i_monster_counter]
ID i_crystal_green
NAME
Monster counter
type 
t_script

ON
=@Create
color 
colors_all

ON
=@Dclick
src
.sysmessage @100 You have killed <dtag0.monsterKillmonsters.
return 
1

[EVENTS e_monster_kill]
ON=@Kill
ref1 
= <findid.i_monster_counter>
if (<
ref1>)
      
ref1.tag0.monsterKill += 1
      sysmessage 
@100 Your monster counter is increasedis now <ref1.dtag0.monsterKill>
      return 
0
endif
//This will install the e_monster_kill event on the player.
//For removing the event type .events -e_monster_kill.
[FUNCTION testMonster]
events +e_monster_kill
src
.sysmessage @100 Monster kill event installed

In some line of code:
PHP Code:
sysmessage @100 Your monster counter is increasedis now <ref1.dtag0.monsterKill
I add the prefix d before the tag, that means display the result in decimal (instead of hexdecimal), it's a shortcut for avoiding writing <eval <ref1.tag0.monsterKill>>

Difference betweeen TAG,TAG0:
TAG0 just tell Sphere to set to 0 the value of the TAG when the TAG is accessed AND the TAG doesn't have any value.
Example:
PHP Code:
[function testApples]
sysmessage  I have <tag0.applesapples//Output will be: I have 0 apples.
sysmessage I have <tag.applesapples.  //Output will be: I have apples.   
tag.apples 2
sysmessage  I have 
<tag0.applesapples//Output will be: I have 02 apples.
sysmessage I have <tag.applesapples.  //Output will be: I have 02 apples. 
//The following line will clear the tag.
tag.apples 
It's important to use TAG0 when checking the tag value.
PHP Code:
[FUNCTION checkApples]
//This will throw an error in the console if the tag is empty.
//By using tag0 you can avoid the error.
if <tag.apples> > 1
    say I have at least an apple
.
else
    
say I have no apples.
endif 
(This post was last modified: 11-25-2016 03:12 AM by darksun84.)
11-25-2016 02:46 AM
Find all posts by this user Like Post Quote this message in a reply
Lincoln
Apprentice
*

Posts: 11
Likes Given: 13
Likes Received: 0 in 0 posts
Joined: Apr 2016
Reputation: 0



Post: #3
RE: Tags....
Thanks for the response Darksun!

However,
The tag on the i_monster_counter would only increase if the player had the event correct?

I would prefer not to add an event to the player, but rather add it to the monster
so that ON=@DEATH of the monster the tag on i_monster_counter increases, if that makes any sense...
Could I still use the same example that you provided?

Really appreciate the help
11-25-2016 03:45 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: #4
RE: Tags....
You have to use @DeathCorpse instead @Death
With this trigger the event will look a little different

PHP Code:
[EVENTS e_monster_kill]
ON=@DeathCorpse
ref1 
= <argo.more2// <argo> holds the uid of the corpse while more2 the uid of the character that killed it.
ref2 = <ref1.findid.i_monster_counter>
if (<
ref2>)
      
ref2.tag0.monsterKill += 1
      ref1
.sysmessage @100 Your monster counter is increasedis now <ref2.dtag0.monsterKill>
      return 
0
endif 
(This post was last modified: 11-25-2016 05:07 AM by darksun84.)
11-25-2016 05:07 AM
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)