Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Exp System - Doesn't work from 0.56b to 0.56d
Author Message
Claus
Apprentice
*

Posts: 21
Likes Given: 2
Likes Received: 0 in 0 posts
Joined: Jan 2014
Reputation: 0



Post: #1
Exp System - Doesn't work from 0.56b to 0.56d
Hello everyone, i'm here for a "porting" problem between sphere 0.56b and 0.56d
I have this exp system
Quote:[DEFNAME levelSystem]
levelBase 1 //Incrementa di 1 tag.levelup, tag.levelUp tiene i livelli
levelCap 50
levelMultiplier 1000

[EVENTS e_exp_gain]
ON=@DEATHCORPSE
Ref1 = <argo.more2> // More 2 store the killer uid
IF (<Ref1.ISPLAYER>) && (<Ref1.tag0.levelUp> < <def.levelCap>)
LOCAL.EXP_GAIN = <calcNewExp <TAG0.EXP>,<ref1.tag.LevelUp>>
Ref1.TAG0.EXP += <dLOCAL.EXP_GAIN>
Ref1.LEVELUP //check if you have lvl up.
Ref1.SYSMESSAGE Hai guadagnato <dLOCAL.EXP_GAIN> punti esperienza.
RETURN 0
ENDIF

[FUNCTION levelup]
IF <TAG0.EXP> >= ((<TAG0.LEVELUP> @ 2) * <def.levelMultiplier>) // L'operatore @ è l'elevamento a potenza,if fa l'eval in automatico
SYSMESSAGE You have level up!
TAG0.EXP=0
TAG0.LEVELUP += <def.levelBase> //Aggiungi 1
EFFECT=3,i_fx_bless,6,15,1 //l'id dell'effetto non so se è giusto
STR += 5
DEX += 3
INT += 3
Anatomy += 25
Swordmanship += 25//qui mettiamo che al levelup, salgono le stat di un punto, potete anche mettere skill o altro..
RETURN 1
ELSE
SYSMESSAGE Hai bisogno di <EVAL (((<TAG0.LEVELUP> @ 2) * <def.levelMultiplier>)-<TAG0.EXP>)> punti per salire di livello.
ENDIF

[FUNCTION exp]
SYSMESSAGE Hai <dTAG0.EXP> punti esperienza e il tuo livello <dTAG0.LEVELUP>
//
IF (((<TAG0.LEVELUP> @ 2) * <def.levelMultiplier>)-<TAG0.EXP>) < 1
SYSMESSAGE Hai bisogno di 0 punti esperienza per salire di livello.
RETURN 1
ELSE
SYSMESSAGE You need <EVAL (((<TAG0.LEVELUP> @ 2) * <def.levelMultiplier>)-<TAG0.EXP>)> points of experience to level up.
RETURN 1
ENDIF
//////
[PLEVEL 1]
exp
levelup

[EOF]

and i apply to the every single NPC these parameters
TAG0.EXP = 5000 (the exp point i prefer for the kind of monster)
TEVENTS=e_exp_gain
and
ON=@deathcorpse
local.exp_gain = <calcNewExp <TAG0.EXP>,<ref1.tag.LevelUp>>

[FUNCTION calcNewExp]
if <argn2> < 5
argn1 -= 125
return <argn1>
endif
if <argn2> < 8
argn1 -= 150
return <argn1>
endif

here a example with skeleton

Quote:[CHARDEF 0900]
DEFNAME=c_m_skeletonarcher
NAME=Skeleton Archer
TAG0.EXP = 500
ID=c_SKELETON_W_AXE
CAN=MT_WALK|MT_RUN|MT_EQUIP
DAM=2,8
ARMOR=8
RESOURCES=8 i_reag_bone
FOODTYPE=
//ALIGNMENT=EVIL
//SHELTER==r_spooky
TEVENTS=e_undead
TEVENTS=e_exp_gain
CATEGORY=Monsters
SUBSECTION=Undeads
DESCRIPTION=Skeleton Archer


ON=@Create
NPC=brain_undead
STR=75
DEX={56 75}
INT={16 40}
ARCHERY=100.0
PARRYING={45.0 55.0}
MAGICRESISTANCE={45.0 60.0}
TACTICS={45.0 60.0}
WRESTLING={45.0 55.0}
FAME={100 2000}
KARMA={-1999 -4999}

ON=@NPCRestock
ITEM=i_bow
ITEM=rich_undead_backpack
ITEM=i_arrow,{10 70}
ITEM={ random_gold_pile 1 0 2 }
ITEM={ i_bone_chest 1 i_bone_leggings 1 i_bone_arms 1 i_bone_gloves 1 i_bone_helmet 1 0 5 }

ON=@deathcorpse
local.exp_gain = <calcNewExp <TAG0.EXP>,<ref1.tag.LevelUp>>

[FUNCTION calcNewExp]
if <argn2> < 5
argn1 -= 125
return <argn1>
endif
if <argn2> < 8
argn1 -= 150
return <argn1>
endif
if <argn2> < 10
argn1 -= 200
return <argn1>
endif
if <argn2> < 12
argn1 -= 250
return <argn1>
endif


This script work very well on 0.56b but in 0.56d i have some problem with the e_exp_gain event. When i kill a monster, the event don't start.
Can some1 help me?

[excuse me for grammatical mistake, i don't speak eng very well]
09-08-2019 10:08 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: #2
RE: Exp System - Doesn't work from 0.56b to 0.56d
What trigger is not being called? The @DeathCorpse on NPC c_m_skeletonarcher or the @DeathCorpse on event e_exp_gain?

---------------------

PS: note that REF1 is missing here
Code:
ON=@deathcorpse
local.exp_gain = <calcNewExp <TAG0.EXP>,<ref1.tag.LevelUp>>
this will throw a console error because you're calling REF1.something on a REF1 that doesn't exist. Probably this is what you're trying to do:
Code:
ON=@deathcorpse
REF1=<ARGO.MORE2>  //MORE2 store the killer uid
local.exp_gain = <calcNewExp <TAG0.EXP>,<ref1.tag.LevelUp>>
09-09-2019 01:18 PM
Find all posts by this user Like Post Quote this message in a reply
Claus
Apprentice
*

Posts: 21
Likes Given: 2
Likes Received: 0 in 0 posts
Joined: Jan 2014
Reputation: 0



Post: #3
RE: Exp System - Doesn't work from 0.56b to 0.56d
(09-09-2019 01:18 PM)Coruja Wrote:  What trigger is not being called? The @DeathCorpse on NPC c_m_skeletonarcher or the @DeathCorpse on event e_exp_gain?

---------------------

PS: note that REF1 is missing here
Code:
ON=@deathcorpse
local.exp_gain = <calcNewExp <TAG0.EXP>,<ref1.tag.LevelUp>>
this will throw a console error because you're calling REF1.something on a REF1 that doesn't exist. Probably this is what you're trying to do:
Code:
ON=@deathcorpse
REF1=<ARGO.MORE2>  //MORE2 store the killer uid
local.exp_gain = <calcNewExp <TAG0.EXP>,<ref1.tag.LevelUp>>


still not working, and console not gives error. With 0.56B there isn't problem, and the script works very well, but not on 0.56d.
I think i will return to 0.56b for now.
thank you
09-09-2019 11:42 PM
Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

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



Post: #4
RE: Exp System - Doesn't work from 0.56b to 0.56d
You probably have not enabled the experience system in the 56d .ini Big Grin
09-10-2019 03:08 AM
Find all posts by this user Like Post Quote this message in a reply
Claus
Apprentice
*

Posts: 21
Likes Given: 2
Likes Received: 0 in 0 posts
Joined: Jan 2014
Reputation: 0



Post: #5
RE: Exp System - Doesn't work from 0.56b to 0.56d
(09-10-2019 03:08 AM)darksun84 Wrote:  You probably have not enabled the experience system in the 56d .ini Big Grin

vero, ma anche nel 56b non l'ho attivato e li il sistema funziona.
Probabilmente il 56D invece ne ha bisogno. mo provo

eng: true, but also in my 56b ini the system is not activated, but the script works. Maybe in 56D this is a necessary condition.

Also if i try to run this script i have this error in console: ERROR:(sphere_exp_system.scp,9)Undefined symbol '' and the simbol is &&. How can i change it? Maybe the problem is here, but i don't know how can i change this operator.
(This post was last modified: 09-11-2019 12:33 AM by Claus.)
09-11-2019 12:14 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: #6
RE: Exp System - Doesn't work from 0.56b to 0.56d
The best way to find any error on any code is debugging it. You just need to insert a random message/log on the code to check if the line is being reached, check if an trigger/function is being called, check an tag value, formula result, etc

So to check if the trigger @DeathCorpse is being called you just need to do something like this
Code:
ON=@DeathCorpse
SERV.LOG trigger @deathcorpse called
This will thrown an debug message on console, so if it show the message = trigger called, otherwise no message = trigger not called

The same can be used to check what is this "undefined symbol" on line 9. Symbol is not only characters like &&, but everything that can make sphere read the line incorrectly
Eg: if you write "IF (<something> > 5)" where <something> is a null value, sphere will read this line as "IF ( > 5)" and will throw "undefined symbol" error because it doesn't know what means <something>

Since this line 9 only use REF1 and DEF.LevelCap, probably this should be an empty REF1 or empty DEF.LevelCap. Again, to check what's wrong you just need to debug it
Code:
ON=@DeathCorpse
REF1=<ARGO.MORE2>
SERV.LOG the REF1 value is "<REF1>" (<REF1.NAME>) and DEF.LevelCap value is "<DEF.LevelCap>"
09-11-2019 10:39 AM
Find all posts by this user Like Post Quote this message in a reply
Claus
Apprentice
*

Posts: 21
Likes Given: 2
Likes Received: 0 in 0 posts
Joined: Jan 2014
Reputation: 0



Post: #7
RE: Exp System - Doesn't work from 0.56b to 0.56d
ok the @deathcorpse trigger is called both script (monster and exp system)
12:30:(sphere_exp_system.scp,8)trigger @deathcorpse called
12:30:(sphere_monsters.scp,56)trigger @deathcorpse called

for the string
Quote:SERV.LOG the REF1 value is "<REF1>" (<REF1.NAME>) and DEF.LevelCap value is "<DEF.LevelCap>"
if i put it in this way

Quote:ON=@DEATHCORPSE
Ref1 = <argo.more2> // More 2 store the killer uid
SERV.LOG the REF1 value is "<REF1>" (<REF1.NAME>) and DEF.LevelCap value is "<DEF.LevelCap>"
IF (<Ref1.ISPLAYER>) && (<Ref1.tag0.levelUp> < <def.levelCap>)

LOCAL.EXP_GAIN = <calcNewExp <TAG0.EXP>,<ref1.tag.LevelUp>>
Ref1.TAG0.EXP += <dLOCAL.EXP_GAIN>
Ref1.LEVELUP //check if you have lvl up.
Ref1.SYSMESSAGE Hai guadagnato <dLOCAL.EXP_GAIN> punti esperienza.
RETURN 0
ENDIF

i have this

Quote:ERROR:(sphere_exp_system.scp,9)Undefined symbol ''

Also i tried to change the simbols && with AND and i have this message

Quote:the REF1 value is "0" (0) and DEF.LevelCap value is ""

Also, i tried to set "Ref1 == <argo.more2>" to see what error console gives to me and there is
Quote:ERROR:(sphere_exp_system.scp,9)Undefined symbol '' ['= 0ffffffff']
13:51:(sphere_monsters.scp,56)trigger @deathcorpse called

The value 0ff... is the same that i can find in the killed monster at the voice more2, so the killer uid (me) is stored in a certain way.
(This post was last modified: 09-12-2019 04:10 AM by Claus.)
09-11-2019 08:45 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: #8
RE: Exp System - Doesn't work from 0.56b to 0.56d
I guess you found the problem. After debug the code you got this
Code:
the REF1 value is "0" (0) and DEF.LevelCap value is ""

So REF1 doesn't exist and DEF.LevelCap is a null value, and this will make sphere read this next line
Code:
IF (<Ref1.ISPLAYER>) && (<Ref1.tag0.levelUp> < <def.levelCap>)
as
Code:
IF () && ( < )
As you can see, there's no error on "&&" but without REF1 and DEF.LevelCap values the code will get completely messed and will return "undefined symbol" console error

Anyway, the trigger @DeathCorpse is called after the char is already dead and with the corpse on ground. Since your script don't need the corpse, you can replace @DeathCorpse with @Death, which is called ~before~ the char die, and this will probably make the code set the REF1 value correctly
Code:
[EVENTS e_exp_gain]
REF1=<ATTACKER.MAX>  // give experience to the attacker that caused most damage
IF (<REF1>)
   ...
ENDIF

Also don't forget that sphere already have an native EXP/LEVEL system which works without any script required, and you can enable and customize it just changing some few settings on sphere.ini. Since your script is really simple, maybe it's better just use the sphere EXP/LEVEL system instead
09-12-2019 05:06 AM
Find all posts by this user Like Post Quote this message in a reply
Claus
Apprentice
*

Posts: 21
Likes Given: 2
Likes Received: 0 in 0 posts
Joined: Jan 2014
Reputation: 0



Post: #9
RE: Exp System - Doesn't work from 0.56b to 0.56d
(09-12-2019 05:06 AM)Coruja Wrote:  Also don't forget that sphere already have an native EXP/LEVEL system which works without any script required, and you can enable and customize it just changing some few settings on sphere.ini. Since your script is really simple, maybe it's better just use the sphere EXP/LEVEL system instead

I think I'll use it if I want to continue on 0.56d, but I didn't understand how to "use it". I explain, activating the system from sphere.ini is very easy, but once in play how does it "spin"? In other words, how is the monster experience assigned? How do players know how much exp they have and what level they are? But above all how do I set that at levelup it gives, for example, 5 strenght?

I tried to find a guide but I couldn't find it

In any case, thanks for the support
09-12-2019 08:27 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: #10
RE: Exp System - Doesn't work from 0.56b to 0.56d
The internal engine just have the basics, like internal <EXP> and <LEVEL> properties and some basic actions like raise EXP when kill monsters, gain messages, etc. But you can customize almost everything using scripts

1st step is set the EXP/LEVEL settings on sphere.ini

Next you must add EXP on all NPCs based on their status
Code:
[EVENTS e_exp_npcs] // don't forget to set e_exp_npcs on EventsPet (sphere.ini) to add this event automatically on all NPCs
ON=@Create
EXP=<eval (<STR>+<DEX>+<INT>) / 2> // or any other custom formula

To do custom actions on exp/level gain you just need to do the same thing using @ExpChange / @ExpLevelChange triggers
Code:
[EVENTS e_exp_players] // don't forget to set e_exp_players on EventsPlayers (sphere.ini) to add this event automatically on all players
ON=@ExpChange
// ARGO = the character that was killed (if the experience change originated from a kill)
// ARGN1 = amount of exp being changed (can be negative)
// ARGN2 = boolean (0/1) to show/hide default gain messages

ON=@ExpLevelChange
// ARGN1 = amount of level being changed (can be negative)
STR += 5

To view your current EXP/LEVEL you just need to use <EXP> or <LEVEL> on any dialog or create an simple function to show it as message
Code:
[PLEVEL 1]
showexp

[FUNCTION showexp] //don't use 'exp' or 'level' names on the function, it will conflict with internal <EXP> and <LEVEL> functions
SRC.SYSMESSAGE You're on level <LEVEL> (<EXP> exp)

And to customize default messages you just need to edit these messages on sphere_msgs.scp, or use the event above to disable these default messages and show your own custom message
09-12-2019 12:05 PM
Find all posts by this user Like Post Quote this message in a reply
[+] 1 user Likes Coruja's post
Post Reply 


Forum Jump:


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