I had found a topic of someone else asking the same thing i am after,
http://forums.polserver.com/viewtopic.php?f=7&t=2640
I was following on what *Edwards said,
found in your npcdeath.src
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
in your npcdesc.cfg every creature should have a property called EXP
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
That shall compile correctly. And you soon figure out how to handle it correctly...
when i go to Ecompile my npcdeath.src , I'm getting this Error
Code: Select all
EScript Compiler v1.09
Copyright (C) 1994-2007 Eric N. Swanson
Compiling: C:/.../.../.../pol/pkg/mobiles/death/npcdeath.src
Variable npc_cfg has not been declared on line 45.
Error ecompiliing statement at C:/.../.../.../pol/pkg/mobiles/death/npcdeath.src, Line 45
Error detected in program body.
Error occurred at C:/.../.../.../pol/pkg/mobiles/death/npcdeath.src, Line 45
Execution aborted due to: Error compiling file
I copied the code that
*Edwards posted to put in npcdeath.src
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
I think i have added the code in my npcdeath.src correctly (I'm not 100% sure..)
Code: Select all
/* $Id: npcdeath.src 1203 2008-05-18 17:00:51Z AustinHeilman $
*
* Purpose
* This script allows side effects to be triggered as a result of NPC death, like unmounting
* players off their dying mount, playing death sounds, etc. This script is common for all NPCs,
* and is called for each.
*
*/
use uo;
use os;
use util;
use cfgfile;
include ":merchants:storage";
include ":timedscripts:timedScripts";
include ":death:death";
include ":loot:lootParser";
include ":mounts:mounts";
include ":death:levelSystem";
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
endif
DP_PlayDeathSound(corpse);
CPM_DeleteContainers(corpse);
foreach loot_entry in ( GetConfigStringArray(npc_cfg, "Loot") )
Loot_Generate(corpse, loot_entry);
SleepMS(2);
endforeach
if ( GuardKillCheck(corpse) )
return 1;
elseif ( NoCorpseCheck(corpse, npc_cfg) )
return 1;
endif
MP_DeathUnmount(corpse);
endprogram
function GuardKillCheck(corpse)
if ( GetObjProperty(corpse, "GuardKill") );
// Nothing
elseif ( GetObjProperty(corpse, "guardkill") );
// Nothing - Old CProp
else
return 0;
endif
// No corpse. Don't drop backpack contents.
// PrintTextAbove(corpse, "*guardkilling*");
foreach item in ( EnumerateItemsInContainer(corpse) )
if ( item.container == corpse )
DestroyItem(item);
endif
SleepMS(2);
endforeach
DestroyItem(corpse);
return 1;
endfunction
function NoCorpseCheck(corpse, npc_cfg)
if ( npc_cfg.NoCorpse );
// Nothing
elseif ( GetObjProperty(corpse, "NoCorpse") );
// Nothing
elseif ( GetObjProperty(corpse, "nocorpse") );
// Nothing - Old Cprop
elseif ( GetObjProperty(corpse, "summoned") );
// Nothing;
else
return 0;
endif
// No corpse. Place backpack contents where the corpse is.
foreach item in ( EnumerateItemsInContainer(corpse) )
if ( item.container == corpse )
MoveObjectToLocation(item, corpse.x, corpse.y, corpse.z, corpse.realm, MOVEOBJECT_FORCELOCATION);
endif
SleepMS(2);
endforeach
DestroyItem(corpse);
return 1;
endfunction