Add us on facebook! - Download Xtremeworlds from CNET - Xtremeworlds Active Server List

Convert Structures to Classes

This is where you can ask for features you wish to see in the next release!

Convert Structures to Classes

Postby smchronos » Wed Mar 10, 2010 12:13 am

I think Bradyok should convert structures like players, maps, npcs, items, etc. into separate classes. You can still save and load those using binary methods and it wouldn't take an incredible amount of time to do this. Then, he should open up the arrays of npcs, maps, players, etc. to scripting so that people can directly mess with things.

Example:
Code: Select all
// ... in some function
player = getPlayerObject(Index)
player.x = 30 // Sets the x position to 30
player.move_speed = 14 // Sets the individual player's movement speed

// ... in some other function
npc = getMapNpcObject(3, 4) // Gets the fourth npc on map 3
npc.hp = 11 // Sets the health
npc.max_hp = 15 // Sets the max health
npc.behavior = ATTACK_OTHER_NPC // Changes NPC behavior

// ... in first function that is now angry
map = player.map // Gets map from player stored earlier
map.tile(0, 0).fringe = getTilesetTile(3, 13) // Sets the map fringe in position 0, 0 to the third tileset's 13th tile

// ... cool functionality example of dynamically creating an npc (memory only)
npc = new NPC( /* ... constructor arguments ... */ )
map.npcs.add(npc) // add new npc


That is some basic stuff, but it would open up doors to scripting and make it easier to add functionality to the server and scripting at the same time. For things that Bradyok wouldn't want made available to people, he could write an outside method (like it's being done now) to do that... or something. I just think that it would help people organize their scripts better, reduce what has to be written, make things simpler, and be able to provide better and more powerful scripts.

In fact, I'd do this for him right now if he was willing to let me; however, I know he isn't going to let anyone touch his source code, which is understandable.

[EDIT]
Oh, and a converter for scripts could be done as well by simply looking for specific commands that previously existed such as getPlayerX(Index) and converting it into player.x after declaring a player variable (or, depending on how things are written it could be player(Index).x).
User avatar
smchronos
 
Posts: 163
Joined: Wed Jun 03, 2009 12:18 am

Return to Wishlist

Who is online

Users browsing this forum: No registered users and 1 guest