Unfortunately I can not very consistent
Emulator POL97
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));
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
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
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 500Code: 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
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
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
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* );
Code: Select all
var lasthitserial := GetObjProperty(corpse, "LastHit");
var who := SystemFindObjectBySerial(lasthitserial);Code: Select all
var lasthitserial := GetObjProperty(corpse, "LastHit");
var who := SystemFindObjectBySerial(lasthitserial);
var pcexp := GetObjProperty(who, "expe");
Code: Select all
var lasthit := GetObjProperty(corpse, "LastDamage");
var who := SystemFindObjectBySerial(lasthit.serial);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 ));
endifCode: 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 500expCode: 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