SphereCommunity
Saving information in one tag - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Saving information in one tag (/Thread-Saving-information-in-one-tag)



Saving information in one tag - Alaric - 07-11-2013 05:04 AM

I would like to remove/forbid the recall spell and use teleports like in Elder Scroll IV: Oblivion.

But I'm not sure, how to save it. My idea is to set "tag.teleport" on a player and every entrance to a dungeon would be represented with something (that's what I need help with). I thought, by letters from A to Z - the whole alphabet. As the player enters the region of the entrance to a dungeon the trigger on=@enter fires and checks whether the player's tag.teleport contains the letter.

The main portal will be in a town. As the player goes thought the world, he/she finds the entrances etc. and in the moment he/she finds it, he/she can teleport from the town to the dungeon.

The problem is, the alphabet has only 26 chars, it means only 26 possible teleports.

Don't you know a similar trick with numbers, or something like that?
For example 1.dungeon represents number 1, 2.dung number 2.
If the tag is 0 => the player hasn't found neither the first dung nor the second.
If the tag is 1 => the player has found the first one.
If the tag is 2 => found only the second one.
If its 3 => found both.

Hope you understand what I mean.


RE: Saving information in one tag - darksun84 - 07-11-2013 05:28 AM

Yea you can store one or more bitmask in a tag, bitmask can hold up to 32 different values so with just three you can store up to 96 different location.

Example with 3 bitmask stored in a tag :


First, it's better you organize your dungeon locations bitmask values inside a defname.

3 bitmask -> 3 defnames

PHP Code:
[DEFNAME dungeon_group_1]
g1_dung_1   01
g1_dung_2   02
g1_dung_3   04
g1_dung_4   08
g1_dung_5   010
g1_dung_6   020
..
g1_dung_32 080000000  //0+ eight bit 

same thing for 2nd bitmaks and bitmask

PHP Code:
[DEFNAME dungeon_group_2]
g2_dung_1   01
g2_dung_2   02
g2_dung_3   04
g2_dung_4   08
g2_dung_5   010
g2_dung_6   020
..
g2_dung_32 080000000 

[DEFNAME dungeon_group_3]
g3_dung_1   01
g3_dung_2   02
g3_dung_3   04
g3_dung_4   08
g3_dung_5   010
g3_dung_6   020
..
g3_dung_32 080000000 

When a your player will enter in a dungeon area you will have to do the check/set of the bitmask.

PHP Code:
//In dungeon g1_dung_2
ON=@Enter
src
.check_dungeon_bitmask 1,<def.g1_dung_2>,<src.tag0.teleport>

//argv[2] is the first bitmask, argv[3] second bitmask, argv[4] third bitmask.
//argv[0] is the bitmask group.
//argv[1] is the value you want to compare.

[FUNCTION check_dungeon_bitmask]
// i don't remember if you can edit argv, so i'll use local
local.mask_1 = <argv[2]>
local.mask_2 = <argv[3]>
local.mask_3 = <argv[4]>

//<local.mask_<dargv[0]> will take the appropriate bitmask group 
if <local.mask_<dargv[0]>&<argv[1]>  // i already know this place
    
return
else  
// i don't know this place
    //adding the dungeon bit value to local.mask_<dargv[0]>
    
local.mask_<dargv[0]> |= <argv[1]>  
    
//setting it to the player,in our case local.mask_1 is changed
    
tag.teleport = <local.mask_1>,<local.mask_2>,<local.mask_3>
    return 
endif 

Well it looks weird and i didn't test it, but it should works theorically !
Also the check function will need some restyling.

Best way will be to use just @RegionEnter trigger and storing the dungeon bitmask value in
a tag contained in the areadef of the dungeon entrace.

Or you can use LIST for handling all of this crap Tongue