DragonPrime - LoGD Resource Community
Welcome Guest
  • Good afternoon, Guest.
    Please log in, or register.
  • July 25, 2017, 03:31:39 PM
Home Forums News Downloads Login Register Advanced Search
* *
DragonPrime Menu
Login
 
 
Resource Pages
Search



How to

How to: Create a New Specialty

Author: Sichae (Chris Vorndran)


Contents



Introduction


So, what are you looking at? All these new specialties coming out... "HEY, I wanna make one!" Well, first you need to learn your basic PHP. But, if worst comes to worst, then it is best to just use another person's specialty as a template.

So, at the end of PR 10, XChrisX and many others were wondering, "How can I make more specialties? The stock three are getting rather bland."

So, Chris went out, and over many days, he shut them all off into modules. So that they may be more easily editable, as well as makeable.

So, what do we have now? A back story, as well as some information. You think you can handle it?

*you nod*

Hold up their bucko! We got to prep you first... think if a surgeon went into operation with dirty hands, eh?

Return to Contents

Before You Start



Some things that you might wish to know, before you begin coding a specialty:

*For starters, a rough knowledge of PHP, as well as some good examples (The Core Specialties) is essential. If you do not know the difference between a else and else if statement... then you might not wish to bother... or, you can begin, and if you get flustered you must always remember, you have examples to look upon.

*Another thing that will come in handy, is a Development Server. See, if I ran bad code on my live server, I would get so many petitions about small errors, that I was trying to debug.

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



The first thing you might want to do, is think of a certain skill set, that you would wish to emulate in your specialty. Come on now, I know there is some gears cranking it that head of yours! Think, come on, THINK! Okay, you got one? Good, now onto step 2.

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:

function modulefilename_getmoduleinfo(){ $info = array( "name" => "Specialty - Skill Set Name", "author" => "Your Name", "version" => "1.0", "download" => "http://dragonprime.net/users/yourname/thisfile.zip", "category" => "Specialties", "prefs" => array( "Specialty - Skill Set Name User Prefs,title", "skill"=>"Skill points in Skill Set Name,int|0", "uses"=>"Uses of Skill Set Name allowed,int|0", ), ); return $info; }

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) Category, keep it at Specialties... doesn't need to be altered.
6) Creating the Prefs array, where all user module info will be stored.
7) Skill Points are what increase with Increment Specialty as well as Leveling in game. It usually goes up by one, unless a 3rd party mod is
doing otherwise.
8) Uses is the actual amount of points that you have per day to spend. Stored at Newday.

NOTE: 7 & 8 must remain as int|0", unless you wish for your players to have a head start:

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/Uninstall Routine



Okay, so moving on to our "install routine" (NOTE: I shall be outlining each of the hooks, so that you can see which do which):

function modulefilename_install(){ module_addhook("choose-specialty"); module_addhook("set-specialty"); module_addhook("fightnav-specialties"); module_addhook("apply-specialties"); module_addhook("newday"); module_addhook("incrementspecialty"); module_addhook("specialtynames"); module_addhook("specialtymodules"); module_addhook("specialtycolor"); module_addhook("dragonkill"); return true; }

1) Choose Specialty comes about, after a DK, or when a person's specialty is undecided, and they choose upon newday.
2) Set Specialty comes *right* after the Choose Specialty, in which the buff is set, and logged into your account as your specialty.
3) Fightnav Specialties is hooking into the battle code, in order to display the navs for the Specialty Skills.
4) Apply Specialties is the part of the dohook, which actually defines what each of the spells/skills do.
5) Newday is in there, so that upon newday, you get your accurate bonus, and your specialty is restocked with uses.
6) Incrementspecialty is a function that is used, in order to display the message, as well as increase the skill points.
7) Specialtynames is used by other scripts to call in the name of the specialty.
8) Specialtymodules was added during PR 12 I believe. It is to retrieve the module filename, in order to refresh skills and whatnot.
9) Specialtycolor is just like specialtynames, except that it retrieves the color code.
10) Dragonkill, to reset the uses and skill points, in order to start anew

The Uninstall is much easier:

function modulefilename_uninstall(){ $sql = "UPDATE " . db_prefix("accounts") . " SET specialty='' WHERE specialty='XX'"; db_query($sql); return true; }

1) XX is equal to the two letter variable that you assign to the specialty.

If you understand, then please proceed, if not, then look to the examples.

Return to Contents

Creating The PHP File - Dohook - Everything Else



Okay, so we have the Install and the Getmoduleinfo... but the install put in all these hooks... and we haven't used them yet. So, we shall now, in the "dohook". Dohook works like so:

function modulefilename_dohook($hookname,$args){ global $session,$resline; $spec = "XX"; $name = "Specialty Name"; $ccode = "Color Code (`%)"; switch ($hookname) { case "dragonkill": set_module_pref("uses", 0); set_module_pref("skill", 0); break; case "choose-specialty": if ($session['user']['specialty'] == "" || $session['user']['specialty'] == '0') { addnav("$ccode$name`0","newday.php?setspecialty=".$spec."$resline"); $t1 = translate_inline("Little Anecdote, to go alongside the Specialty Name"); $t2 = appoencode(translate_inline("$ccode$name`0")); rawoutput("<a class='link' href='newday.php?setspecialty=$spec$resline'>$t1 ($t2)</a>"); addnav("","newday.php?setspecialty=$spec$resline"); } break; case "set-specialty": if($session['user']['specialty'] == $spec) { page_header($name); output("Background Story of your Specialty."); } break; case "specialtycolor": $args[$spec] = $ccode; break; case "specialtynames": $args[$spec] = translate_inline($name); break; case "specialtymodules": $args[$spec] = "modulefilename"; break; case "incrementspecialty": if($session['user']['specialty'] == $spec) { $new = get_module_pref("skill") + 1; set_module_pref("skill", $new); $name = translate_inline($name); $c = $args['color']; output("`n%sYou gain a level in `&%s%s to `#%s%s!",$c, $name, $c, $new, $c); $x = $new % 3; if ($x == 0){ output("`n`^You gain an extra use point!`n"); set_module_pref("uses", get_module_pref("uses") + 1); }else{ if (3-$x == 1) { output("`n`^Only 1 more skill level until you gain an extra use point!`n"); }else{ output("`n`^Only %s more skill levels until you gain an extra use point!`n", (3-$x)); } } output_notl("`0"); } break; case "newday": $bonus = getsetting("specialtybonus", 1); if($session['user']['specialty'] == $spec) { $name = translate_inline($name); if ($bonus == 1) { output("`n`2For being interested in %s%s`2, you receive `^1`2 extra `&%s%s`2 use for today.`n", $ccode, $name, $ccode, $name); }else{ output("`n`2For being interested in %s%s`2, you receive `^%s`2 extra `&%s%s`2 uses for today.`n", $ccode, $name, $bonus, $ccode, $name); } } $amt = (int)(get_module_pref("skill") / 3); if ($session['user']['specialty'] == $spec) $amt = $amt + $bonus; set_module_pref("uses", $amt); break; case "fightnav-specialties": $uses = get_module_pref("uses"); $script = $args['script']; if ($uses > 0) { addnav(array("$ccode$name (%s points)`0", $uses), ""); addnav(array("$ccode Skill One`7 (%s)`0", 1), $script."op=fight&skill=$spec&l=1", true); } if ($uses > 1) { addnav(array("$ccode Skill Two`7 (%s)`0", 2), $script."op=fight&skill=$spec&l=2",true); } if ($uses > 2) { addnav(array("$ccode Skill Three`7 (%s)`0", 3), $script."op=fight&skill=$spec&l=3",true); } if ($uses > 4) { addnav(array("$ccode Skill Four`7 (%s)`0", 5), $script."op=fight&skill=$spec&l=5",true); } break; //Gonna Leave out the Apply Specialty for now } return $args; }

1) global $session,$resline are just two functions in order to apply it to all folk. $resline is the sanity check. Not needed to be edited.
2) $spec is setting the Two Letter code for your specialty. Make it relate. If I make "Dragon Powers", It wouldn't make any sense to make it "ZF".
3) $name is just called a bunch of times, just fill it in with your Specialty Name.
4) $ccode is equal the the in-game color code. NOTE If you wish to use `$, it must be `\$, or it will conflict and error.
5) case "dragonkill": includes the two codes that are meant to delete the skill points and usage points for a specialty
6) case "choose-specialty": is the area where you set up the navs for your choosing of specialty. You can add in a little anecdote, in order to sway people to it.

NOTE: You can add in some things, such as:

if ($session['user']['dragonkills'] < get_module_setting("mindk")) break;

In order to set in a limit to the specialty, if the user doesn't have X DKs.
NOTE: The following would need to be added into the getmoduleinfo():

"settings"=>array( "mindk"=>"Minimum DK for specialty,int|5", ), "prefs"=>... prefs should already be set up.

7) case "set-specialty": is just the finalization of the setting of your specialty. It is also where you set in the back story for your little specialty.
8) case "specialtycolor": is just to make sure, that whenever the script is called, it displays the same color as set in the specialty.
9) case "specialtynames": same as specialtycolor, but with the name
10) case "specialtymodules": is used to call in the module file name from another script. Just insert your module file name.
11) case "incrementspecialty": is put in, in order to increment a person's skill points. Not Needed to be altered.
12) case "newday": is just to refresh your use points, as well as put in your bonus.
13) case "fightnav-specialties": is the creation of the navs in the battle script, in order to trigger the right thing, when you click upon it. Only shows up, if you have the right amount of Points.

Of course, there are all kinds of places where you can hook in, like making something in the village only seeable:

// Make Sure to add_modulehook("village"); into the install. case "village": if ($session['user']['specialty'] == $spec){ output("`n As a Dragon, you see a Statue."); } break;

If you understand, then we shall move on. If not, then please go to your example.

Return to Contents


Creating The PHP File - Dohook - Applying the Specialty Code *Balance*



Now, to the fun stuff!

Okay, so you got this nice thing, called the
case "apply-specialties":


And this is where you set up all of your special moves. Now, I am only going to run down a very basic skill set:
case "apply-specialties": $skill = httpget('skill'); $l = httpget('l'); if ($skill==$spec){ if (get_module_pref("uses") >= $l){ switch($l){ case 1: apply_buff('ts1',array( "startmsg"=>, "rounds"=>, "wearoff"=>", "roundmsg"=>, "badguyatkmod"=>, "badguydefmod"=>, "schema"=>"modulefilename" )); break; case 2: apply_buff('ts2',array( "startmsg"=>, "name"=>, "rounds"=>, "minioncount"=>, "minbadguydamage"=> "maxbadguydamage"=> "effectmsg"=>, "effectnodmgmsg"=>, "schema"=>"modulefilename" )); break; case 3: apply_buff('ts3', array( "startmsg"=>, "name"=>, "rounds"=>, "wearoff"=>, "roundmsg"=>, "regen"=>, "schema"=>"modulefilename" )); break; case 5: apply_buff('ts5',array( "startmsg"=>, "name"=>, "rounds"=>, "wearoff"=>, "atkmod"=>, "defmod"=>, "roundmsg"=>, "schema"=>"modulefilename" )); break;} set_module_pref("uses", get_module_pref("uses") - $l); }else{ apply_buff('ts0', array( "startmsg"=>, "rounds"=>1, "schema"=>"modulefilename" )); } } break;

1)Okay, so what we have here, is a standard buff. With badguyatkmod and badguydefmod.
These two values are multipliers. So, if their attack is 10 and I want it to be 5, I do

"badguyatkmod"=>.5,

Same way with badguydefmod. Now, these values can also be used for balance. Let's say I do this:

"atkmod"=>2, "badguydefmod"=>1.4,

That would increase my attack, but at the same time, increase his defense. So the balance? Good.

2) Minions: Okay, so if you have tinkered with mounts, you basically know all of the values for this:

"minioncount"=> Defines the amount of minions
"minbadguydamage"=> Sets the minimum damage that your minion can cause
"maxbadguydamage"=> Sets the maximum damage that your minion can cause
"effectmsg"=> Is to show what is going on, when the creature hits. Include the {damage} tag
to show Damage Dealt, as well as the {badguy} to show whom you are attacking.
"effectnodmgmsg"=> Is to show what is going on, when the creature misses

There are several other things that you can do.

3) The "regen" command. Popular for healing. If I want to heal 5 per turn"

"regen"=>5,
And there we go. Or, you can do some special things, such as:

"regen"=>$session['user']['level']

Like the Mystic Arts does for "Regeneration"

4) The use of atkmod and defmod. These can drastically alter battle. So, you want to keep in mind, balance!
If I up my stats by 50, I want the badguy to at least have a fighting change, so increase his by 40, if not more.

5) This message is just to display that you have no magic points left.

If you do not understand balance, then toy around with the values. Let us proceed.

Return to Contents


Creating The PHP File - Finishing Up


function modulefilename_run(){
//Unless you plan to run a script from here, like a shop, you don't need to fill this.
}

And close the file:

?>

All done. ^_^ hooray, you are Number One!

Return to Contents


Testing



Okay, so now you need to test it. What I find best, is to set up a dev server on my home box, and test it in there. So, we go in, and for testing
set the skill points to '150' and the uses to '50'. Just so that we can check everything.

So, go to the Forest, make sure your specialty is set. And fight. Test each Skill at least 5 times each, to make sure it is all good.

Now, what you need to do, is:

Instructions:

1. Set Specialty equal to Undecided in User Editor
2. Run Newday from the Village, with the link
3. Check to see if your things look nice.

Optional, but recommended:
4. Check for Translation Compatibility
5. Check for db prefixing

If it all works, finalize the mod. Zip it up, and post it somewhere. Congrats!
You have successfully made your first specialty!

Feels good, don't it?

Return to Contents


No - No's



Okay, so I am to give some examples, of what you should NOT be doing. In the case of buffs:

Example One

apply_buff('ts5',array( // Skipping some values "rounds"=>15, "atkmod"=>4, "defmod"=>1.5, }

Okay, now, several problems with this...
1) ATKmod should NEVER be that high.
2) Rounds for Specialties should always be <= (less than or equal to) 5
3) Even though there was an attempt to balance, if the atkmod is that outrageous, then the only cure for it, is a .0001 Def Mod

Example Two

apply_buff('ts1',array( // Skipping some values "rounds"=>5, "minioncount"=>5, "minbadguydamage"=>$session['user']['level'] * 5, "maxbadguydamage"=>$session['user']['maxhitpoints'], }

Okay, things are wrong with this as well...
1) Minion Count should almost never be fixed, unless it is 1 or 2. Making it work off of a val, makes it much easier to balance
2) Since it states "ts1" that means that this is the first spell earned... and it is a bit too powerful.

Example Three

apply_buff('ts1',array( // Skipping some values "rounds"=>-1, "regen"=>$session['user']['hitpoints'], }

Now, wrong with this, two things:
1) Never make the round count -1, as it will set it until next newday
2) Regen should NEVER be that high... it should be a low value, most likely level.

Example Four

apply_buff('ts5',array( // Skipping some values "rounds"=>5, "minioncount"=>1, "invulnerable"=>1, "damageshield"=>5, "minbadguydamage"=>$session['user']['level'], "maxbadguydamage"=>$session['user']['maxhitpoints'], }

Let's see, it looks good. Level 5 Skill, decent stats ... WRONG!
1) NEVER use invulnerable alongside anything else. If it needs to be used, it should be used alone, or not at all
2) Damage Shield is a multiplier, so 5 Damage Shield... the enemy is most likely missing all the time.

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/28 - version 0.1web
- Converted to html

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

Return to Contents

Converted to HTML for use on DragonPrime by Talisman


*
DragonPrime Notices
Play LoGD on Dragonprime

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