DragonPrime - LoGD Resource Community
Welcome Guest
  • Good morning, Guest.
    Please log in, or register.
  • November 24, 2017, 01:09:21 AM
Home Forums News Downloads Login Register Advanced Search
* *
DragonPrime Menu
Login
 
 
Resource Pages
Search



How to

How to: Create a New Race

Author: Sichae (Chris Vorndran)





Contents



Introduction
Welcome to Sichae's Race Documentation. You are probably viewing this file, because you want to make a race. Well, you are in the right place. This guide is intended to aide those that are adept and those that aren't. Please take note of the notes that I have left in this document, as they will aide you even further. Most importantly, have fun with it.

Return to Contents
Before You Start
I should also note that this document is based on the current 0.9.8 pre-releases of LoGD which you can find on http://dragonprime.net.

Return to Contents
Let's Begin
Okay, since the beginning of time, there have been races... Well, LotGD has more. Although, I am not sure if there are any racists around LotGD, although I happen to know, that the Dwarf is far superior to the stupid Elf. Elves don't do a thing.

Just kidding. But, as the world grows, as do the amount of races, and that is why you turn to here. This is the Ultimate Race Building Guide 0.1, brought to you by Sichae aka Christopher Devin Vorndran.

So, this document shall entail all that you need to know about races and race creation.

Return to Contents
Creating the PHP File - Beginnings
Now, you wish to set up your very first specialty (or you are coming back, because you made a bad one :P) Okay, now begin your PHP file:
// Begin File <?php // End Begin File
Very good... hopefully you understand the rough outline of the function:
// Begin Race getmoduleinfo function modulefilename_getmoduleinfo(){ $info = array( "name" => "Race - Race Name", "author" => "Your Name Here", "version" => "1.0", "download" => "http://blah.blah.org/blah.zip", "vertextloc" => "http://blah.blah.org/", "category" => "Races", "settings" => array( "Race Settings,title", "minedeathchance"=>"Chance for Race to die in the mine,range,0,100,1|25", "mindk"=>"How many DKs do you need before the race is available?,int|5", ), "requires"=>array( "sharedracefilename"=>"Version|Author, link to download", ), ); return $info; } // End Race getmoduleinfo
1) Naming your Module, as it will be seen on the outside, as well as any configuration of the file settings from within the game.

2) Author, self explanatory

3) Version No. Don't worry about it... just remember, if you make a change, increment the version number.

4) Download, write in the download link or the location of the zipped file. (Might as well just post in on DP)

5) Vertextloc, is where the version.txt is held. This is to comply with Lonnyl's Module Version Checking system, which allows for easy updating. This link should point to the folder, where your version.txt is held. You must leave in the end /

6) Category, keep it at Race... doesn't need to be altered.

7) Creating the Settings array, those two are for the Mine Encounter, and setting a Minimum DK before the race is available.

8) Requires array will require the race, and forbid installation without the needed file.

If you understand, then we can proceed, if you do not, then look at your example files.


Return to Contents
Creating the PHP File - Install and Uninstall
Okay, so here is where I am going to show two versions. The first will be the version for a race, that has it's own city. The following, will be for a race, that shares a city.
// Begin Install function modulefilename_install(){ module_addhook("chooserace"); module_addhook("setrace"); module_addhook("newday"); module_addhook("villagetext"); module_addhook("travel"); module_addhook("charstats"); module_addhook("validlocation"); module_addhook("validforestloc"); module_addhook("moderate"); module_addhook("changesetting"); module_addhook("raceminedeath"); module_addhook("pvpadjust"); module_addhook("racenames"); // Update from commentary sections using village-$city to village-$race; // This is pretty much a one-time thing $sql = "UPDATE " . db_prefix("commentary") . " SET section='village-Racename' WHERE section='village-Race Village Name'"; db_query($sql); return true; } // end install
Okay, now for a shared city race:
// Begin Share City function modulefilename_install(){ module_addhook("chooserace"); module_addhook("setrace"); module_addhook("creatureencounter"); module_addhook("charstats"); module_addhook("raceminedeath"); module_addhook("racenames"); return true; } // End sharecity
1) chooserace, is the setup for a person to choose their race...

Eh, I will explain these in the dohook portion. Onto the uninstall:
// Begin Uninstall function modulefilename_uninstall(){ global $session; $vname = getsetting("villagename", LOCATION_FIELDS); $gname = get_module_setting("villagename"); $sql = "UPDATE " . db_prefix("accounts") . " SET location='$vname' WHERE location = '$gname'"; db_query($sql); if ($session['user']['location'] == $gname) $session['user']['location'] = $vname; $sql = "UPDATE " . db_prefix("accounts") . " SET race='" . RACE_UNKNOWN . "' WHERE race='Race Name'"; db_query($sql); if ($session['user']['race'] == 'Race Name') $session['user']['race'] = RACE_UNKNOWN; return true; } // End uninstall
Okay, those DB queries, are just to make sure, that no one is left with a badnav, or an inexstant race, when it is uninstalled.

If you understand, then we can proceed, if you do not, then look at your example files.

Return to Contents
Creating the PHP File - Dohook - Separate Races
I am going to detail the Own City races first, then do share city in the next section.
// Begin Dohook function modulefilename_dohook($hookname,$args){ //yeah, the $resline thing is a hack. Sorry, not sure of a better way //to handle this. // Pass it in via args? global $session,$resline; $city = get_module_setting("villagename"); $race = "Race Name"; switch($hookname){ case "pvpadjust": if ($args['race'] == $race) { $args['creaturedefense']++; } break; case "racenames": $args[$name] = $name; break; case "raceminedeath": if ($session['user']['race'] == $race) { $args['chance'] = get_module_setting("minedeathchance"); } break; case "changesetting": // Ignore anything other than villagename setting changes if ($args['setting'] == "villagename") { if ($session['user']['location'] == $args['old']) $session['user']['location'] = $args['new']; $sql = "UPDATE " . db_prefix("accounts") . " SET location='" . $args['new'] . "' WHERE location='" . $args['old'] . "'"; db_query($sql); if (is_module_active("cities")) { $sql = "UPDATE " . db_prefix("module_userprefs") . " SET value='" . $args['new'] . "' WHERE modulename='cities' AND setting='homecity'" . "AND value='" . $args['old'] . "'"; db_query($sql); } } break; case "charstats": if ($session['user']['race']==$race){ addcharstat("Vital Info"); addcharstat("Race", $race); } break; case "chooserace": if ($session['user']['dragonkills'] < get_module_setting("mindk")) break; output("<a class='link' href='newday.php?setrace=$race$resline'>This is the part</a>
that is being shown, when a person is selecting to be this race, over the others.`n`n",$city,true); addnav("Race Name`0","newday.php?setrace=$race$resline"); addnav("","newday.php?setrace=$race$resline"); break; case "setrace": if ($session['user']['race']==$race){ output("`^Right after you select the race, it displays me!!!"); if (is_module_active("cities")) { if ($session['user']['dragonkills']==0 && $session['user']['age']==0){ //new farmthing, set them to wandering around this city. set_module_setting("newest-$city", $session['user']['acctid'],"cities"); } set_module_pref("homecity",$city,"cities"); $session['user']['location']=$city; } } break; case "newday": if ($session['user']['race']==$race){ modulefilename_checkcity(); apply_buff("racialbenefit",array( "name"=>"Racial Buff Name`0", "atkmod"=>"", "allowintrain"=>1, "allowinpvp"=>1, "rounds"=>-1, ) ); } break; case "validlocation": case "validforestloc": if (is_module_active("cities")) $args[$city]="village-$race"; break; case "moderate": if (is_module_active("cities")) $args["village-$race"]="City of $city"; break; case "travel": $capital = getsetting("villagename", LOCATION_FIELDS); if ($session['user']['location']==$capital){ addnav("Safer Travel"); addnav(substr($city,0,1)."?Go to $city","runmodule.php?module=cities&op=travel&city=$city"); }elseif ($session['user']['location']!=$city){ addnav("More Dangerous Travel"); addnav(substr($city,0,1)."?Go to $city","runmodule.php?module=cities&op=travel&city=$city&d=1"); } if ($session['user']['superuser'] & SU_EDIT_USERS){ addnav("Superuser"); addnav("Go to $city","runmodule.php?module=cities&op=travel&city=$city&su=1"); } break; case "villagetext": modulefilename_checkcity(); //remind me to edit this later ^.^ if ($session['user']['location'] == $city){ $args['text']="This is the village text, that is to be displayed for your city.`n"; $args['clock']="`nThis is the little thing, that will display the current game time as %s.`n"; $args['title']="$city"; $args['sayline']="how do your people talk? Grunting=grunts, Barking=barks"; $args['talk']="`n`^Nearby some villagers blank :`n"; $new = get_module_setting("newest-$city", "cities"); if ($new != 0) { $sql = "SELECT name FROM " . db_prefix("accounts") . " WHERE acctid='$new'"; $result = db_query_cached($sql, "newest-$city"); $row = db_fetch_assoc($result); $args['newestplayer'] = $row['name']; $args['newestid']=$new; } else { $args['newestplayer'] = $new; $args['newestid']=""; } if ($new == $session['user']['acctid']) { $args['newest']="`nYou are new in the village, what are you experiencing?"; } else { $args['newest']="`nYou see someone new... they are doing something, and they are`^%s`6."; } $args['gatenav']="The Gates"; $args['fightnav']="The Fighting"; $args['marketnav']="The Market"; $args['tavernnav']="The Taverns"; $args['section']="village-$race"; } break; } return $args; } // End Dohook
Phew, that was a long one. So, I tried to outline what need to go where, within the actual code... but in case you missed it:

1) pvpadjust, is what is exectued to balance out what you have, when fighting an enemy. If I am upping my attack, the person I am attacking should have some kind of counter measure... so raise their defense.

2) raceminedeath, the chance that you will die in a Mine

3) changesetting, just something so that navs for a shoppe that is in the town so they don't get messed up.

4) charstats, this displays your race in your vital info!

5) chooserace and setrace, these are the messages that are displayed when you are selecting your race to be, at the start of the game.

6) newday, this is when you are going to apply your racial buff. Basically, an atkmod, or a defmod will suffice... anything that is too grand, such as invincibility, it extremely frowned upon. Rounds to -1, ensures that it lasts indefinately.

7) validlocation, moderate, travel. Validlocation, is making sure that you are in a location that actually exists. Moderate, allows you to moderate the commentary that is going on in your village. Travel, allows a person to get to your city.

8) All of the villagetext is self-explanatory. If you do not understand it, there are many examples out there for you to check against.

If you feel comfortable, you may move on. If not, please look at references.

Return to Contents
Creating the PHP File - Dohook - Share City Races
Okay, these are the races that are going to be sharing a race's town.
// Begin Code function modulefilename_dohook($hookname,$args){ //yeah, the $resline thing is a hack. Sorry, not sure of a better way //to handle this. // It could be passed as a hook arg? global $session,$resline; if (is_module_active("sharingcity'srace'sfilename")) { $city = get_module_setting("villagename", "sharingcity'srace'sfilename"); } else { $city = getsetting("villagename", LOCATION_FIELDS); } $race = "Race Name"; switch($hookname){ case "raceminedeath": if ($session['user']['race'] == $race) { $args['chance'] = get_module_setting("minedeathchance"); $args['racesave'] = "Dogding the rocks, what does it say?.`n"; } break; case "charstats": if ($session['user']['race']==$race){ addcharstat("Vital Info"); addcharstat("Race", $race); } break; case "chooserace": if ($session['user']['dragonkills'] < get_module_setting("mindk")) break; output("<a class='link' href='newday.php?setrace=$race$resline'>This is the part</a>
that is being shown, when a person is selecting to be this race, over the others.`n`n",$city,true); addnav("Race Name`0","newday.php?setrace=$race$resline"); addnav("","newday.php?setrace=$race$resline"); break; case "setrace": if ($session['user']['race']==$race){ output("`#You just selected your race, what does it say?!"); if (is_module_active("cities")) { if ($session['user']['dragonkills']==0 && $session['user']['age']==0){ //new farmthing, set them to wandering around this city. set_module_setting("newest-$city", $session['user']['acctid'],"cities"); } set_module_pref("homecity",$city,"cities"); $session['user']['location']=$city; } } break; case "creatureencounter": if ($session['user']['race']==$race){ //get those folks who haven't manually chosen a race modulefilename_checkcity(); $args['creatureexp']=round($args['creatureexp']*1.1,0); } break; } return $args; } // End code
Same Things for the other race, except a lot of the cases are thrown out. This is because they are not needed.

But hey, what is this checkcity(); I keep seeing? Next Section

Return to Contents
Creating the PHP File - checkcity
1st, I will do a Own City Race, then I will do a Share City Race
// Begin Own City Code function modulefilename_checkcity(){ global $session; $race="Race Name"; $city=get_module_setting("villagename"); if ($session['user']['race']==$race && is_module_active("cities")){ //if they're this race and their home city isn't right, set it up. if (get_module_pref("homecity","cities")!=$city){ //home city is wrong set_module_pref("homecity",$city,"cities"); } } return true; } // End Own City Code
Easy enough... just places a person in the correct city.
// Begin Share City Code function moduelfilename_checkcity(){ global $session; $race="Race Name"; if (is_module_active("sharingcity'srace'sfilename")) { $city = get_module_setting("villagename", "sharingcity'srace'sfilename"); } else { $city = getsetting("villagename", LOCATION_FIELDS); } if ($session['user']['race']==$race && is_module_active("cities")){ //if they're this race and their home city isn't right, set it up. if (get_module_pref("homecity","cities")!=$city){ //home city is wrong set_module_pref("homecity",$city,"cities"); } } return true; } // End Share City Code
This is going to drop them into the correct city, the one that they are sharing.

Well, finish out the file:
// Begin End Code function modulefilename_run(){ } ?> // End End Code
Realistically, the _run function of a race doesn't need to exist. Although, if you plan on adding new things, such as the racestorm.php of mine, then you may end up using it.

Return to Contents
Testing
Okay, so to test... set your race equal to nothing or RACE_UNKNOWN, so that you are able to see the chooserace and setrace... and then tweak them to look right.

Then, bring you character into the forest, and make sure that your buff is executing properly. If it is, then that is good.

Next, try travelling around, if you have travel on. Make sure that your home city is working properly. If so, good. Make sure all the text in the village looks all right.

Well, that is about it... fix it up. Make sure all the colors look good. Then, unleash it on the world.

Return to Contents
Tools
Here are some of the tools I've used while working on races.
  • Editplus (http://editplus.com)
    • Very nice text editor. Has syntax highlighting, as well as matching brace amongst other things. Although it does work from a registration after X amount of days, you can easily bypass it, but just clicking the right tab when you get to that point.
  • Firefox (http://getfirefox.com)
    • One of the best browsers out there. Many different extensions that can help you.
  • EasyPHP (http://www.easyphp.org/)
    • A very easy to use server setup. Includes MySQL and PHPMyAdmin. Just plop your lotgd folder in the www folder, and run the install and all, make the DB and write the dbconnect.php to match.


Return to Contents
Credits
To MightyE and Kendaer: Thanks to you both, for providing a great game to add on to. Given me more to do with my life.

To Current/Beginning Coders: Keep the questions coming! I will help ya out!

Return to Contents
Closing
Okay, now that this is done... what to do next? How about Spell Check :P
-- Christopher Devin Vorndran -=aka=- Sichae Saracen

Return to Contents
Document History
2005/01/26 - version 0.1
- Completed first draft of this document
- Posted to DragonPrime

*
DragonPrime Notices
Welcome to DragonPrime - The LoGD Resource Community!

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
21 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search