Item system hhmmm?
Blitz3D Forums/Blitz3D Beginners Area/Item system hhmmm?
| ||
I'm cluless... I thought of making a Type called Item and store a players' item in a dim Name$ + _Items ... and add items name to the array... and when ever its used get in the type the specs for that item... Following me? What would you do? So player can have unlimited items unless he gets over his carring limit(but that i can do, set the limit that is)... ? |
| ||
global max_items = 100 for carry.items = each items if carry\items > max_items then print "Sorry to many Items dude" endif next |
| ||
I haven't tested it but would that work surely this would be better:global max_items = 100 global carry.items global num_items num_items=0 for carry=each items num_items=num_items+1 next if num_items>max_items then print "Your carrying too much!" endif |
| ||
Hmm, something like this. Putting the check code in a function means you only need to check it when the player picks up an item. MAX_ITEMS can be replaced with a global if you want the maximum number of items to change.Const MAX_ITEMS = 50 Global Player_Items.Item Global Player_ItemCount = 0 Dim Player_Items.Item(MAX_ITEMS) Function AddItem(p_Item.Item) If Player_ItemCount <= MAX_ITEMS then ;Not carrying too much, add the item Player_ItemCount = Player_ItemCount + 1 Player_Items(Player_ItemCount) = p_Item Else Print "You're carrying too much" EndIf End Function Hope that helps! |
| ||
What I want to do is... be able to add unlimited to it... but later I'm gonna give every object a weight and depending on his max weight... then I'll put restriction... However how could I set it to be unlimited? Is it possible? It would prolly cause problems... I should put a max :) |
| ||
Something like this maybe:Type Player Field Name$ Field Strength% Field Dexterity% Field Constitution% Field Wisdom% Field Intelligence% Field Charisma% Field MaxCarry# Field InventoryWeight# End Type Player1.player = new player player1\Name = "Bob the Hunter" ;ensure the name is unique if you're doing multiplayer player1\Strength = 14 player1\Dexterity = 13 player1\Constitution = 12 player1\Wisdom = 10 player1\Intelligence = 12 player1\Charisma = 14 player1\MaxCarry = player1\Strength * 5 Type Item Field Name$ Field Weight# Field Owner$ End Type Function AddItem(p_Item.Item) If Player1\InventoryWeight + p_Item\Weight <= Player1\MaxCarry then ;Not carrying too much, add the item p_Item\Owner = Player1\Name Player1\InventoryWeight = Player1\InventoryWeight + p_Item\Weight Else Print "You're carrying too much" EndIf End Function |
| ||
Not bad :) Why use < and > ? |
| ||
why use <>? I'm not, I'm using <= less than or equal to. |
| ||
You might want to use a more unique identifier for the owner, something like PlayerName + UserName + Left$(RegKey$, 5) Where the playername is "Bob The Hunter" the Username is whatever they use to login into the server and the RegKey is whatever registration key they may need to legally own your game (don't use the whole key for security reasons obviously) |
| ||
Type Item Field Name$ Field Class$ Field Element_Add$, Element_DamMIN%, Element_DamMAX%, Element_Effect$ Field Magic_Add$, Magic_DamMIN%, Magic_DamMAX%, Magic_Effect$, Magic_Type$ Field STR_Add%, AGI_Add%, VIT_Add%, INT_Add%, DEX_Add%, CON_Add%, WIS_Add%, CHA_Add% Field STR_Rem%, AGI_Rem%, VIT_Rem%, INT_Rem%, DEX_Rem%, CON_Rem%, WIS_Rem%, CHA_Rem% Field EXP_Req%, STR_Req%, AGI_Req%, VIT_Req%, INT_Req%, DEX_Req%, CON_Req%, WIS_Req%, CHA_Req% End Type I made this for items lol... Req = Requirements Rem = Removes Add = Adds DamMIN = Minimum Damage DamMAX = Maximum Damage And this for Char Sheet: Type Character Field From_Account$ ; Account Field Name$ ; Char Name Field Second_Name$ ; Second Name Field Guild$ ; Guild Field Hit_Points ; Health Field Magic_Powers ; Magic Power Field Good_Evil ; Between Good and Evil Field Strenght% ; STR Field Agility% ; AGI Field Vitality% ; VIT Field Intelligence% ; INT Field Dexterity% ; DEX Field Constitution% ; CON Field Wisdom% ; WIS Field Charisma% ; CHA Field DamageMIN ; Min Damage Field DamageMAX ; Max Damage Field Defence ; Defence Field Magic_Damage ; Magic Add Damage Field Magic_Defence ; Magic Add Defence Field Char_Speed ; Speed of Char Field MaxCarry# Field InventoryWeight# ; Equip Field Head Field Torso Field Legs Field R-Hand Field L-Hand Field Hands Field Feets End Type What do you think... its gonna be a pain to write and read off the users char_sheet on the server :| Its gonna be hard I need to convert lvls and exp... I want my rpg to not be based on LEVELS. Its not realistic :P but then again is killing monster any more realistic ;) |
| ||
Vitality and Constitution could easily be the same stat as could agility and dexterity (Keep it simple). For certain things, you could have a two-byte index lookup table (i.e. for standard equipment), that way you can have up to 65536 items in the table but simply refer to them in two bytes. Likewise, guilds can be registered on a lookup table (which the player needs only download when querying guilds, or logging on). i.e. internally an Item could look like this (Assuming Vit and Con, Agl and Dex are combined) : Type Item Field Name$ ;never sent or received from server unless custom items are supported in which case only when it is a custom item (i.e. not in local lookup table) Field NameID% Field Class$ ;same for this one Field ClassID% Field Element_Add$, Element_DamMIN%, Element_DamMAX%, Element_Effect$ Field Magic_Add$, Magic_DamMIN%, Magic_DamMAX%, Magic_Effect$, Magic_Type$ Field STR_Add%, AGI_Add%, VIT_Add%, INT_Add%, WIS_Add%, CHA_Add% Field STR_Rem%, AGI_Rem%, VIT_Rem%, INT_Rem%, WIS_Rem%, CHA_Rem% Field EXP_Req%, STR_Req%, AGI_Req%, VIT_Req%, INT_Req%, WIS_Req%, CHA_Req% End Type NewItem.Item = New Item NewItem\NameID = 1 ;Item lookup table as below ;Fill in the values from the rest via the lookup table ;;;;;;;;;;;;;;;;SAMPLE CLASS LOOKUP TABLE;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;NOT ACTUAL BLITZ CODE (OBVIOUSLY);;;;;;;;;;;;;; ID CLASSNAME 0 All 1 Fighter 2 Wizard 3 Sorceror 4 Druid 5 Cleric 6 Rogue 7 Bard ;;;;;;;;;;;;;;;;SAMPLE ITEM LOOKUP TABLE;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;NOT ACTUAL BLITZ CODE (OBVIOUSLY);;;;;;;;;;;;;; ID ItemName Other info (whatever it may be) 0 "Sheepskin" 1 1 "Leather Boots" 0 2 "Steel Boots" 0 3 "Adamantium Boots" 0 4 "Titanium Boots" 0 5 "Uranium Boots" 0 6 "Leather Jerkin" 0 7 "Chain Cuirass" 0 8 "Steel Platemail" 0 9 "Steel Scalemail" 1 10 "Leather Skirt" 0 All you really need to send (except with custom items) is the item ID, the rest can be done serverside. If you want to (help) prevent hacking, you should store the character server side, and then simply send the info to the player when it needs updated. |
| ||
Bear in mind that to be hack proof, most of the calculations should be done server side, and to do that, you will need a very chunky cluster of servers to support more than a few people. If on the other hand you intend this to be run as a friends only LAN game then security is less of an issue. |
| ||
Perturbatio: Don't worry it was my idea to run everything server side. Example: Client sends request to move his player x+10, Server Checks if its possible if it is it moves the player and sends to the client somekind of x+10 movement... Some it should be hack prouf and all data of the player are saved in a player file when event the connect quits... I thought of doing the Server side using GUI not graphics... but id need two loops one for the GUI menus and stuff and one for Process of Client to Server things... and Im not sure how to make to loops :| What do u think? |
| ||
I think perhaps you should start small, work on creating a simple server controlled game, and learn from that. Of course, it will take longer to do, but by the time you get to writing your bigger game, you'll have discovered some of the pitfalls already. Start with a simple MP game like pong or space invaders. It's not the type of game that matters, just the implementation of client-server code. Then try playing said game over the net with a friend, and see how it performs. |
| ||
I think perhaps you should start even smaller... like making a GAME! :D then you can worry about making a Multiplayer Game. |
| ||
lol. |