Sphereserver / Source-X

Ultima Online server emulator
Apache License 2.0
53 stars 40 forks source link

Discussion: Server layers system #1209

Open Tolokio opened 4 months ago

Tolokio commented 4 months ago

There are some times where I need to store items somewhere. In thoose cases I need to create a container and put it on the map. Or I can create an account with a player that store all that stuff on his bank. But this may cause many errors, as the container can be removed and mess all the script.

How do u see to create a server's layer or something like that? So we could use that as general storage container.

//Example:
[typedef ei_never_lose_this_item]
on=@destroy
cont=<serv.storage1>
return 1

//Another example (for the stable system problems where pets are removed if StableMaster is killed.)
//this script would get pets into <serv.storage1> and get pets back once a new stableMaster Spawn.

[chardef stable_master]

on=@death
serv.newitem i_backpack
ref1 <new.uid>
FORCONT <FINDLAYER.29.UID>
     local.pets ++
     cont=<ref1.uid>
endfor
if (<local.pets>)
    ref1.cont=<serv.storage1>
    ref5=<spawnItem>
    ref5.tag.PetsAtContainer=<ref1.uid>
else
    ref1.remove
endif

on=@create
if <spawnItem>
     ref1=<spawnitem>
     ref2=<ref1.tag.PetsAtContainer>
     ref3=<uid>
     if <ref2.isvalid>
          forcont <ref2.uid>
               cont=<ref3.findlayer.29.uid>
          endfor
          ref2.remove //remove container as it is no longer needed.
          ref1.tag.PetsAtContainer  //remove tag as it is no longer needed.
     endif
endif
Jhobean commented 4 months ago

I thonk how layer are designed must be on a char. I dont think its possible to place a layer on server itself.

Tolokio commented 4 months ago

Dosnt have to be a layer's system, just some kind of storage's system. Maybe I shouldnt use the word "layer". But the idea comes from layer system.

not
canerksk commented 4 months ago

Instead, would more than one bank account work for one account/character?

The serv.findlayer.1 function can be a bit complicated. More possible alternative methods can be considered.

The first alternative solution that comes to my mind is;

likesrc.house.0.uid / src.houses.count etc.

There could be a property like src.bank.0.uid/src.banks to have multiple storages for a character and add a multi like

There may be virtual banks that can be added or removed asSRC.ADDBANK / SRC.DELBANK <uid>/<id>.