Abstract items

Archive of the older Feature Request Forum Posts
Locked
User avatar
itec
Novice Poster
Posts: 42
Joined: Thu Feb 09, 2006 11:48 pm

Abstract items

Post by itec »

Like in object oriented languages, items should be possible to derive from another abstract item. Let's say we have item class MaceWeapon, which looks like this:

Code: Select all

Abstract MaceWeapon
{
    Attribute       macefighting
    HitSound        0x13C
    MissSound       0x234
    equipscript     equip
    unequipscript   unequip
    destroyscript   destroy
    HitScript	   :combat:mainHitScript
    CProp	        OnHit a1:S15::combat:maceHit
}
And a weapon club:

Code: Select all

Weapon 0x13B3 : MaceWeapon
{
    Name            Club
    desc            club
    Speed           40
    Damage          1d3+20
    Anim            0x000b
    MaxHP           35
    VendorSellsFor  27
    VendorBuysFor   13
    strrequired     10
    MinDam          11
    MaxDam          13
}
Or the definition could be handled as an element:

Code: Select all

    DeriveFrom       MaceWeapon
So the abstract items (and why not NPC templates also) would be a collection of properties. This would save a lot of repeating in config files, and it would make maintenance easier.
zandor
New User
Posts: 14
Joined: Sat Feb 04, 2006 10:13 am

Post by zandor »

Not evil this think.

I also like to have a sort of C #DEFINE and #IFDEFINEDCOMPILE #ENDCOMPIELSECION to compile single senction of code in some circustances....
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

Zandor I think what you're trying to say can be accomplished using constants.

Code: Select all

use uo;

const TESTCONST := 0;

program testconst(who)
  if (TESTCONST)
    SendSysMessage(who, "Test area compiled");
  endif
  SendSysMessage(who, "Ending script");
endprogram
If TESTCONST is 0, the script will be compiled as if only SendSysMessage(who, "Ending script"); exists. Check the .lst file to see.
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Post by OldnGrey »

Well, that's a new one for me!
Thanks for the education :)
User avatar
zandor70
Master Poster
Posts: 93
Joined: Fri Feb 10, 2006 10:06 am

Post by zandor70 »

No... I can use const like vars into programs but program compiled is always the same.
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

For the record, what CWO says works. Here's his example in action:


conditional_compile.src - TESTCONST == 0

Code: Select all

use uo;

const TESTCONST := 0;

program testconst(who)
  if (TESTCONST)
    SendSysMessage(who, "Test area compiled");
  endif
  SendSysMessage(who, "Ending script");
endprogram
conditional_compile.lst - TESTCONST == 0

Code: Select all

conditional_compile.src, Line 5
program testconst(who)
const TESTCONST := 0;
0: get arg 'who'
SendSysMessage(who, "Ending script");
1: local #0
2: "Ending script"
3: 3L
4: 1000L
5: Func(2,0): SendSysMessage
6: #
7: leave block(1)
8: progend


conditional_compile.src - TESTCONST == 1

Code: Select all

use uo;

const TESTCONST := 1;

program testconst(who)
  if ( TESTCONST )
    SendSysMessage(who, "Test area compiled");
  endif
  SendSysMessage(who, "Ending script");
endprogram
conditional_compile.lst - TESTCONST == 1

Code: Select all

conditional_compile.src, Line 5
program testconst(who)
const TESTCONST := 1;
0: get arg 'who'
SendSysMessage(who, "Test area compiled");
1: local #0
2: "Test area compiled"
3: 3L
4: 1000L
5: Func(2,0): SendSysMessage
6: #
SendSysMessage(who, "Ending script");
7: local #0
8: "Ending script"
9: 3L
10: 1000L
11: Func(2,0): SendSysMessage
12: #
13: leave block(1)
14: progend

zandor70: Could you post your code that is not working?
User avatar
zandor70
Master Poster
Posts: 93
Joined: Fri Feb 10, 2006 10:06 am

Post by zandor70 »

I thinked const was used like vars.... I have never watched the code, sorry. I think you are right is code in .ecl is this, and for me is a very good news.
User avatar
CWO
POL Expert
Posts: 1160
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

I did this all over my AI because its a bit more efficient than variables and conditionals in the script (notice, ecompile doesn't even compile the conditional if/else/endif so POL doesn't have to read it). Now spellcaster code, ranged combat code, firebreath, and tactical stuff is all configurable.
Locked