Something seems wrong...

DGNXFoxN
Hi there,

I was working on "interactivity with servers" when I suddenly realized that it was a huge amount of code for just one server.
With the idea to add a huge amount of servers I couldn't help but thinking that there just had to be a better way.
I was hoping if someone could help me out with this?

There are a lot of attribute checks and flag checks done when the player interacts with a server.
But I still believe it could be done more effective and with way less coding... I was thinking functions but I have no clue how to do it so that
not every server looks exactly the same.

Thanks!

XanMag
When you talk about "interactivity with servers" do you mean like using google, yahoo, etc?

As far as it looking different, I'm sure you are aware of being able to change the background color/picture. I have only changed the color, which is really easy, but I have played games where they have a different picture in the background. You could probably doctor up a google picture and have the game command bar in a location where you would typically see the search bar in google - might make it look real, too. I'm just talking out loud really, but I think it could be done this way and it's not too hard if you get someone who knows how to do that.

As for "huge amount of code for just one server"... do you mean accounting for all of the possible things that players could search for? If so, I would say, yes, looping a function is your best bet. And, depending on how holistic you want your search engine to be (and how crazy you might be for trying it), you can add as many search queries as you want, but I'm thinking your default response will include a gigantic range possible searches. You can loop a default script and provide with a variety of different outputs for non-important search queries too.

Perhaps I totally misunderstand your question/problem though. Good luck!

DGNXFoxN
Well,

During the game the player will be able to connect to a large amount of servers. Some are indeed "Search Engines", others could be "regular pages" or "News pages", etc... but there will also be servers where they can go to look for (and download) specific software.
However, every server that contains files will need a login or otherwise be "hacked" in order to gain access to the files.
So to briefly sum up some of the things the code does before allowing to continue:

- Does the player have access to "the internet"?
- Has the player already gained access before?
- Is the player using login credentials (that can be found) or using software to gain access?
- When logged in what does the player want to do? Browse the files, check the log files (delete traces (still needs to be put in the code)).
- After the choice is made (ex: browse files) player will be presented with a list of files and be able to download them.
* When the player chooses what to download the following checks occur:
- Is the file actually on the server (player needs to type the file name in order to download)
- if yes, does the player already have that file? If yes, continue to installation.
- After the download they can choose to install, if they choose yes, it will check if it is already installed...
- then it will install...

Ofcourse, simulating all of this and having the game check for so many things kind of creates a big pile of code.
And that is just one server. Making this a function will kind off make every website look exactly the same... text-wise atleast.

EDIT: The game will have little to no images since it is supposed to be a terminal (commands only) based hacking simulator.
You could compare it best with TELEHACK.COM. However, I want to give it a more interesting touch.

DGNXFoxN
Setting up the search engines is something I think I can do with a function containing a switch with all the different searches available. Or atleast I think that would be the best way to go :)

jaynabonne
The way I have seen this handled with software development in general is to, first, get your initial one done and working. In this case, make sure the first server is working the way you want it to. Then...

Begin working on the second one. Where you find you would need to duplicate code, "de-dup" as you go along. (There are two approaches. One is to discover the duplication as you're abut to write it, knowing what you're going to write. Then you separate out the pieces you need. And roll it into the new one as well. The second approach is to actually duplicate the code and have it working. Then de-dup, making the two instances share the same code and then be sure they both still work. The first can be quicker for smaller pieces, but the second can be safer, since you know it worked at least at one time. It helps to make snapshots along way when it's working, so you can always get back to a working state as you refactor.)

Things like commands can be shared globally. Code can be put into functions and passed parameters (e.g. which server is being operated on). You can also create a base type to hold common scripts and initial attributes and then inherit your new objects from that type to gain common functionality.

That's all I can offer from a general point of view. If you have specific code that you'd like to make "common", then if you post it, we can work out a good way to either parametrize and share it or just share it.

DGNXFoxN
Seems like logic :) Not sure though how to work with the function parameters and inheriting scripts and attributes to new objects.

TinFoilMkIV
As far as running the initial check list on the very basic interactions, I would create function to run through all the common items, such as as you said, is the player connected to the internet, have they logged in here before, etc...

The next important part is to have your function reference the server in question by using 'this.<attribute>'. As this will allow you tun run the function from any server and it will specifically look at the attributes contained by that server itself. In this way you can create the basic functionality, then store the server specific data within the server itself while using the same function across all of them.

Alternatively as Jay said, you can pass the server as a parameter when running the function and reference the current one that way.

HegemonKhan
DGNXFoxN wrote:Not sure though how to work with the function parameters and inheriting scripts and attributes to new objects.


Object Types (Groups~Classes):

(can be found under 'advanced' in the left side's 'tree of stuff' in the GUI~Editor)

(and they can be added to Objects simply via: 'Attributes' Tab -> Inherited Attributes -> Add)

these hold Attributes and~or other Object Types, which these Object Types, can be added to Objects (as Inherited Attributes), giving that Object every Attribute that it holds (including the Attributes of Object Types within the Object Type).

for an example:

much better:

<object name="dragon_1">
<inherit name="dragon_object_type">
</object>

<object name="dragon_2">
<inherit name="dragon_object_type">
</object>

<object name="dragon_3">
<inherit name="dragon_object_type">
</object>

<object name="dragon_4">
<inherit name="dragon_object_type">
</object>

<type name="dragon_object_type">
<attr name="strength_integer_attribute" type="int">100</attr>
<attr name="endurance_integer_attribute" type="int">100</attr>
<attr name="dexterity_integer_attribute" type="int">100</attr>
<attr name="agility_integer_attribute" type="int">100</attr>
<attr name="speed_integer_attribute" type="int">100</attr>
<attr name="luck_integer_attribute" type="int">100</attr>
</type>


much worse:

<object name="dragon_1">
<attr name="strength_integer_attribute" type="int">100</attr>
<attr name="endurance_integer_attribute" type="int">100</attr>
<attr name="dexterity_integer_attribute" type="int">100</attr>
<attr name="agility_integer_attribute" type="int">100</attr>
<attr name="speed_integer_attribute" type="int">100</attr>
<attr name="luck_integer_attribute" type="int">100</attr>
</object>

<object name="dragon_2">
<attr name="strength_integer_attribute" type="int">100</attr>
<attr name="endurance_integer_attribute" type="int">100</attr>
<attr name="dexterity_integer_attribute" type="int">100</attr>
<attr name="agility_integer_attribute" type="int">100</attr>
<attr name="speed_integer_attribute" type="int">100</attr>
<attr name="luck_integer_attribute" type="int">100</attr>
</object>

<object name="dragon_3">
<attr name="strength_integer_attribute" type="int">100</attr>
<attr name="endurance_integer_attribute" type="int">100</attr>
<attr name="dexterity_integer_attribute" type="int">100</attr>
<attr name="agility_integer_attribute" type="int">100</attr>
<attr name="speed_integer_attribute" type="int">100</attr>
<attr name="luck_integer_attribute" type="int">100</attr>
</object>

<object name="dragon_4">
<attr name="strength_integer_attribute" type="int">100</attr>
<attr name="endurance_integer_attribute" type="int">100</attr>
<attr name="dexterity_integer_attribute" type="int">100</attr>
<attr name="agility_integer_attribute" type="int">100</attr>
<attr name="speed_integer_attribute" type="int">100</attr>
<attr name="luck_integer_attribute" type="int">100</attr>
</object>


and any Attribute added (or via scripting) to the Object directly, will over-ride any Inherited Attribute from an Object Type:

<object name="dragon_0">
<inherit name="dragon_object_type">
<attr name="strength_integer_attribute" type="int">0</attr> // this will over-ride the Inherited 'strength_integer_attribute' Attribute's Value of 100, with Value 0, meaning our 'dragon_0' Object will have 0 strength.
</object>

<type name="dragon_object_type">
<attr name="strength_integer_attribute" type="int">100</attr>
<attr name="endurance_integer_attribute" type="int">100</attr>
<attr name="dexterity_integer_attribute" type="int">100</attr>
<attr name="agility_integer_attribute" type="int">100</attr>
<attr name="speed_integer_attribute" type="int">100</attr>
<attr name="luck_integer_attribute" type="int">100</attr>
</type>


-------------

anoher example of Object Types with Object Types (layers~levels of inheritance):

<object name="claymore">
<inherit name="weapon_object_type">
<attr name="type_stringlist_attribute" type="simplestringlist">weapon</attr>
<attr name="weight_integer_attribute" type="int">10</attr>
<attr name="layer_integer_attribute" type="int">2</attr>
<attr name="two_handed_boolean_attribute" type="boolean">true</attr>
<attr name="physical_damage_integer_attribute" type="int">50</attr>
<attr name="attack_rating_integer_attribute" type="int">25</attr>
</object>

<type name="equipment_object_type">
<attr name="durability_integer_attribute" type="int">100</attr>
<attr name="equipable_boolean_attribute" type="boolean">true</attr>
<attr name="unequipable_boolean_attribute" type="boolean">true</attr>
<attr name="type_stringlist_attribute" type="simplestringlist">weapon;armor;clothing</attr>
<attr name="slot_stringlist_attribute" type="simplestringlist">head;face;neck;ears;shoulders;arms;hands;fingers;left_hand;right_hand;chest;back;waist;legs;feet</attr>
<attr name="weight_integer_attribute" type="int">0</attr>
<attr name="layer_integer_attribute" type="int">0</attr>
<equip type="script">
// blah scripting
</equip>
<unequip type="script">
// blah scripting
</unequip>
</type>

<type name="weapon_object_type">
<inherit name="equipment_object_type" />
<attr name="two_handed_boolean_attribute" type="boolean">false</attr>
<attr name="physical_damage_integer_attribute" type="int">0</attr>
<attr name="fire_damage_integer_attribute" type="int">0</attr>
<attr name="water_damage_integer_attribute" type="int">0</attr>
<attr name="air_damage_integer_attribute" type="int">0</attr>
<attr name="earth_damage_integer_attribute" type="int">0</attr>
<attr name="attack_rating_integer_attribute" type="int">0</attr>
<attr name="slot_stringlist_attribute" type="simplestringlist">left_hand;right_hand</attr>
</type>

<type name="armor_object_type">
<inherit name="equipment_object_type" />
<attr name="physical_defense_integer_attribute" type="int">0</attr>
<attr name="fire_defense_integer_attribute" type="int">0</attr>
<attr name="water_defense_integer_attribute" type="int">0</attr>
<attr name="air_defense_integer_attribute" type="int">0</attr>
<attr name="earth_defense_integer_attribute" type="int">0</attr>
<attr name="armor_class_integer_attribute" type="int">0</attr>
<attr name="slot_stringlist_attribute" type="simplestringlist">head;face;neck;ears;shoulders;arms;hands;fingers;chest;back;waist;legs;feet</attr>
</type>


---------------------------

Parameters are VARIABLES that can be transferred between Elements (Functions, Commands, Delegates, etc?) and also can *optionally* be locally~temporarily renamed~relabeled, too.

for example...

<game name="xxx">
<attr name="player_objectlist_attribute" type="objectlist">player_1;player_2;player_3</attr>
<start type="script">
show menu ("Character?", game.player_objectlist_attribute, false) {
name_function (result)
}
</start>
</game>

<function name="name_function" parameters="player_parameter">
msg ("Name?")
get input {
player_parameter.alias = result
}
</function>


you pick what player you'll be using: player_1, player_2, or player_3
let's say you pick: result = player_2

the 'name_function' Function takes the 'result' (player_2) as its Parameter for use in its scripting, and changes its label~name to: player_parameter

conceptually: player_parameter <=== result <=== player_2

so conceptually: player_parameter.alias = player_2.alias

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums