Level System
Moderator: POL Developer
Level System
Good time of day. How to write a system of levels for the character, with the experience for killing monsters? If there is a claw or the sample script to show you.
Unfortunately I can not very consistent
Emulator POL97
Unfortunately I can not very consistent
Emulator POL97
Re: Level System
Check the npcdeath script... there you can add a function to give exp to the killer (CProp), and another function to check if player has reached next level (another CProp for level). You should set a config or just another function to check how much exp does the player need to reach next level.
I'd give you an example script but i have lost all my scripts
I'd give you an example script but i have lost all my scripts
Re: Level System
Thank you for the information. Still, I would like to see how it looks like the whole script.
Re: Level System
I want to do so in npcdesc.cfg
Sample:
In death.src need to add the following:
Or I have something wrong? If yes, how to Give. Emulator POL97
And if there is a claw scripts to send e-mail. Thx
Sample:
Code: Select all
Name IntrinsicWarior
Script :brainAI:brain
ObjType 0x289
Color 0
TrueColor 0
Gender 0
AR 25
RunSpeed 200
Alignment neutral
Category Examples
// Attributes
Strength 100
Intelligence 1
Dexterity 10
Wrestling 100
// Vitals
HITS 100
MANA 1
STAM 100
EXP 500
.................
.................
.................
Code: Select all
var EXP := CInt(GetObjProperty(corpse, "EXP"));
SetObjProperty(character, "expe", (expe + EXP));
And if there is a claw scripts to send e-mail. Thx
Re: Level System
Umm well yes thats a way to implant it... but you will need the killer reference.. and that would only give the exp to the last hit? nvm
** You have something wrong in the npcdesc, add exp as a CProp, check for a template in the file.
Maybe you could add a SysMessage to tell the player the exp that has earned.. no?
After adding the exp you should call a funciton to check if it has enought exp to reach the next level.. and to advance one level if it's so.
I'd say you to set a include file for the level "system"
for example (not tested at all):
** You have something wrong in the npcdesc, add exp as a CProp, check for a template in the file.
Maybe you could add a SysMessage to tell the player the exp that has earned.. no?
After adding the exp you should call a funciton to check if it has enought exp to reach the next level.. and to advance one level if it's so.
I'd say you to set a include file for the level "system"
for example (not tested at all):
Code: Select all
//levelSystem.inc
function checkExp(who, exp)
var level := GetObjProperty(who, "level");
var nextLevel := expTable(level);
if(exp < nextLevel)
return 0;
else
advanceLevel(who, level);
return 0;
endif
endfunction
function expTable(level)
var exp;
case( (level + 1) )
2: exp := 500;
3: exp := 800;
4: exp := 1200;
5: exp := 1500;
6: exp := 1800;
//...
endcase
return exp;
endfunction
function advanceLevel(who, level)
SetObjProperty(who, "exp", 0);
SetObjProperty(who, "level", (level + 1) );
SendSysMessage(who, "You have reached level "+(level + 1)+"!");
endfunction
Re: Level System
Hence in npcdesc.cfg you can set it?
But then that should be added to npcdeath.src?
Sorry, head not to know = (I can not understand even started re-teaching guide to scripting
Code: Select all
Name a grizzly bear
Script :ai_brain:brain
ObjType 0xD4
Color 0
TrueColor 0
Gender 0
STR 100
INT 40
DEX 105
HITS 100
MANA 0
STAM 105
AR 5
RunSpeed 55
WAR_Wrestling 65
Tactics 100
AttackAttribute WAR_Wrestling
AttackSpeed 30
AttackDamage 3d4
AttackHitSound 0xA6
AttackMissSound 0x239
DeathSound 0xA8
DamagedSound 0xA7
СProp exp 50
But then that should be added to npcdeath.src?
Sorry, head not to know = (I can not understand even started re-teaching guide to scripting
Re: Level System
I wouldn't add it as a CProp since it takes a lot more memory. The way you had it before was perfectly fine. Leave it as an entry in the cfg without the CProp and then read it straight from there with GetConfigInt();
leave npcdesc.cfg like that...
then in the script to read EXP, you would need this code implanted into your script...:
(I didn't test this, I just scripted this on the fly so mistakes are possible)
leave npcdesc.cfg like that...
Code: Select all
Name IntrinsicWarior
Script :brainAI:brain
ObjType 0x289
Color 0
TrueColor 0
Gender 0
AR 25
RunSpeed 200
Alignment neutral
Category Examples
// Attributes
Strength 100
Intelligence 1
Dexterity 10
Wrestling 100
// Vitals
HITS 100
MANA 1
STAM 100
EXP 500
(I didn't test this, I just scripted this on the fly so mistakes are possible)
Code: Select all
use cfgfile;
program npcdeath(corpse)
...
var npccfg := ReadConfigFile(":*:npcdesc");
var template := GetObjProperty(corpse, "npctemplate");
var elem := FindConfigElem(npccfg, template);
if (elem)
var expgain := GetConfigInt(elem, "EXP");
if (expgain)
// You'll have to set the person who last hit this NPC in all hitscripts and spell scripts.
var pcexp := GetObjProperty(who, "expe");
SetObjProperty(who, CInt(pcexp) + CInt(expgain));
SendSysMessage(who, "You have gained " + CStr(CInt(pcexp)) + " experience.");
endif
endif
...
endprogram
Re: Level System
Yes, thats the way
(Didn't tested it )
npcdeath.src
levelSystem.inc
npcdesc.cfg
(Didn't tested it )
npcdeath.src
Code: Select all
use cfgfile;
include :death:levelSystem; //Includes the inc file levelSystem (put it in the pkg "Death" in the folder includes)
program npcdeath(corpse)
...
var npccfg := ReadConfigFile(":*:npcdesc");
var template := GetObjProperty(corpse, "npctemplate");
var elem := FindConfigElem(npccfg, template);
if (elem)
var expgain := GetConfigInt(elem, "EXP");
if (expgain)
// You'll have to set the person who last hit this NPC in all hitscripts and spell scripts.
var pcexp := GetObjProperty(who, "expe");
SetObjProperty(who, "expe", CInt(pcexp) + CInt(expgain)); // There was an "error" here :P
SendSysMessage(who, "You have gained " + CStr(CInt(pcexp)) + " experience.");
checkExp(who, (expe + expgain)); // This checks if player reaches next level or not.
endif
endif
...
endprogram
Code: Select all
//levelSystem.inc
function checkExp(who, exp)
var level := GetObjProperty(who, "level");
if(!level)
SetObjProperty(who, "level", 1);
endif
var nextLevel := expTable(level);
if(exp < nextLevel)
return 0;
else
advanceLevel(who, level);
return 0;
endif
endfunction
function expTable(level)
var exp;
case( (level + 1) )
2: exp := 500;
3: exp := 800;
4: exp := 1200;
5: exp := 1500;
6: exp := 1800;
//...
endcase
return exp;
endfunction
function advanceLevel(who, level)
SetObjProperty(who, "expe", 0);
SetObjProperty(who, "level", (level + 1) );
SendSysMessage(who, "You have reached level "+(level + 1)+"!");
endfunction
Code: Select all
Name IntrinsicWarior
Script :brainAI:brain
ObjType 0x289
Color 0
TrueColor 0
Gender 0
AR 25
RunSpeed 200
Alignment neutral
Category Examples
// Attributes
Strength 100
Intelligence 1
Dexterity 10
Wrestling 100
// Vitals
HITS 100
MANA 1
STAM 100
EXP 500
Re: Level System
Sadahar, many thanks to you!
Know that I would do without you =)
Know that I would do without you =)
Re: Level System
By the way Sadahar, not whether you have a full tutorial on eScript?
The one that the site is not complete. Or I am wrong?
The one that the site is not complete. Or I am wrong?
Re: Level System
Umm the best way to learn is reading already done scripts
Re: Level System
That's how most of us learned. We sat and looked at other people's scripts and looked at the reference to all the commands in the documentation and the Object hierarchy to figure out what stuff does.
Re: Level System
Hmmm, with the compilation gives an error in the lines:
if (elem)
if (expgain)
var pcexp := GetObjProperty(who, "expe");
if (elem)
if (expgain)
var pcexp := GetObjProperty(who, "expe");
Code: Select all
program core_npcDeath(params)
var corpse := params[1];
TS_Death(corpse); // Will still get the PID from the corpse.
var npccfg := ReadConfigFile(":brainAI:npcdesc");
var template := GetObjProperty(corpse, "npctemplate");
var elem := FindConfigElem(npccfg, template);
if (elem)
var expgain := GetConfigInt(elem, "EXP");
if (expgain)
var pcexp := GetObjProperty(who, "expe");
SetObjProperty(who, "expe", CInt(pcexp) + CInt(expgain)); // There was an "error" here :P
SendSysMessage(who, "You have gained " + CStr(CInt(pcexp)) + " experience.");
checkExp(who, (expe + expgain)); // This checks if player reaches next level or not.
endif
Re: Level System
Variable "who" is not declared?
That's where I said its going to be a little harder. You have to find out through your scriptbase if there is a prop set for who last hit the NPC. If not, you have to go into all of your damaging scripts like hitscripts and spell scripts and add that. You'll likely need to set the serial number of the person who last hit the NPC as a prop then retrieve it from the corpse and set who to SystemFindObjectBySerial( *serial number of the last person to hit it* );
That's where I said its going to be a little harder. You have to find out through your scriptbase if there is a prop set for who last hit the NPC. If not, you have to go into all of your damaging scripts like hitscripts and spell scripts and add that. You'll likely need to set the serial number of the person who last hit the NPC as a prop then retrieve it from the corpse and set who to SystemFindObjectBySerial( *serial number of the last person to hit it* );
Re: Level System
CWO wrote:Variable "who" is not declared?
That's where I said its going to be a little harder. You have to find out through your scriptbase if there is a prop set for who last hit the NPC. If not, you have to go into all of your damaging scripts like hitscripts and spell scripts and add that. You'll likely need to set the serial number of the person who last hit the NPC as a prop then retrieve it from the corpse and set who to SystemFindObjectBySerial( *serial number of the last person to hit it* );
SystemFindObjectBySerial(who.serial, "LastHit");
?
Re: Level System
if you have a "LastHit" prop set to the NPC then this is easy. Although the format of it could be different. POL itself does not set this prop. This must be set by your scripts when the NPC is hit (within the hitscripts and spell scripts) Just put this before the var pcexp := GetObjProperty(who, "expe");
so you should end up with
Code: Select all
var lasthitserial := GetObjProperty(corpse, "LastHit");
var who := SystemFindObjectBySerial(lasthitserial);
so you should end up with
Code: Select all
var lasthitserial := GetObjProperty(corpse, "LastHit");
var who := SystemFindObjectBySerial(lasthitserial);
var pcexp := GetObjProperty(who, "expe");
Re: Level System
Property lastHit its not just the serialof the killer...
you must work out that dictionary, o struct, whatever it is xD
no?
you must work out that dictionary, o struct, whatever it is xD
no?
Re: Level System
OK I looked up the POL097 distro, the prop is "LastDamage" not "LastHit" and its a struct with a .serial member. Now IF and ONLY IF you're using the POL097 distro scripts (this is seperate from the emulator itself) it would be:
Code: Select all
var lasthit := GetObjProperty(corpse, "LastDamage");
var who := SystemFindObjectBySerial(lasthit.serial);
Re: Level System
Wonder why it gives an error on line when compiling:
if (elem)
if (expgain)
var pcexp: = GetObjProperty (who, "expe");
if (elem)
if (expgain)
var pcexp: = GetObjProperty (who, "expe");
Re: Level System
you're just giving lines. What is the actual error? It should be something like "variable who has not been declared" but the 2 lines I gave you in my last post should be put before that line where it gets the prop "expe" because I declared who on the second line.
Re: Level System
var pcexp: = GetObjProperty (who, "expe");
as I see You have a space between : and =
: = <-bad
:= <-good
as I see You have a space between : and =
: = <-bad
:= <-good
Re: Level System
CWO, Yesterday compile scripts such as error-free. But was the writing that can not read levelSystem.inc and when you add features Elem EXP 500 (CASE) in npcdesc.cfg, with the murder of a monster do not write that I got experience. Perhaps due to the fact that not work levelSystem.inc?
Re: Level System
Does someone working example scripts on this theme at least for POL95? Just want to understand the system of writing these scripts.
Re: Level System
found in your npcdeath.src
in your npcdesc.cfg every creature should have a property called EXP
That shall compile correctly. And you soon figure out how to handle it correctly...
Code: Select all
program core_npcDeath(params)
var corpse := params[1];
var lasthitserial := GetObjProperty( corpse, "LastHit" );
var who := SystemFindObjectBySerial( lasthitserial );
var npccfg := ReadConfigFile( ":*:npcdesc" );
var template := GetObjProperty( corpse, "npctemplate" );
var elem := FindConfigElem( npccfg, template );
if( elem )
var expgain := GetConfigInt( elem, "EXP" );
if ( expgain )
var mobile_exp := GetObjProperty( who, "XP" );
SetObjProperty( who, "XP", mobile_exp + expgain );
SendSysMessage( who, "You have gained "+ expgain +" experience.");
checkExp( who, ( mobile_exp + expgain ));
endif
Code: Select all
Name IntrinsicWarior
Script :brainAI:brain
ObjType 0x289
Color 0
TrueColor 0
Gender 0
AR 25
RunSpeed 200
Alignment neutral
Category Examples
// Attributes
Strength 100
Intelligence 1
Dexterity 10
Wrestling 100
// Vitals
HITS 100
MANA 1
STAM 100
EXP 500 // This creature gives 500exp
Code: Select all
//levelSystem.inc
function checkExp( who, exp )
var level := GetObjProperty( who, "level" );
var nextLevel := expTable( level );
if( exp < nextLevel )
return 0;
else
advanceLevel( who, level );
return 0;
endif
endfunction
function expTable( level )
var exp;
case( (level + 1) )
2: exp := 500;
3: exp := 800;
4: exp := 1200;
5: exp := 1500;
6: exp := 1800;
//...
endcase
return exp;
endfunction
function advanceLevel( who, level )
var previous_lvl := GetObjProperty( who, ''level'' );
var new_lvl := previous_lvl +1;
SetObjProperty( who, "XP", 0 );
SetObjProperty(who, "level", new_lvl );
SendSysMessage(who, "You have reached level "+new_lvl +"!");
endfunction