Your browser must have JavaScript enabled in order to view this page.
 
Welcome Guest#1780 Login/register    Go to Bottom
Go to Top
    DpPage >
DpNpc

DpNpc

CREATING DUTCHPIPE "NON PLAYING CHARACTERS"

 > Building a NPC
 > DpObject
 > DpLiving

Building a NPC

You can build a NPC in two ways:

  1. Make a new instance of DpNpc and call methods in it to set it up. For simple NPCs, this is all that is needed. For example:

    1. inherit(DPUNIVERSE_STD_PATH 'DpNpc.php');
    2.  
    3.     . 'DpNpc.php');
    4. $npc->addId('barkeeper');
    5. $npc->setTitle('barkeeper');
    6. $npc->setTitleImg(DPUNIVERSE_IMAGE_URL 'barkeeper.gif');
    7. $npc->setBody('<img src="' DPUNIVERSE_IMAGE_URL
    8.     . 'barkeeper_body.gif" width="125" height="200" border="0" alt="" '
    9.     . 'align="left" style="margin-right: 15px" />The barkeeper is '
    10.     . 'serving free beer!<br />');
  2. By making a custom class that extends on DpNpc.

    dpuniverse/npc/barkeeper.php

    1. inherit(DPUNIVERSE_STD_PATH 'DpNpc.php');
    2.  
    3. public function createDpNpc()
    4. {
    5.     $this->addId('barkeeper');
    6.     $this->setTitle('barkeeper');
    7.     $this->setTitleImg(DPUNIVERSE_IMAGE_URL 'barkeeper.gif');
    8.     $this->setBody('<img src="' DPUNIVERSE_IMAGE_URL
    9.         . 'barkeeper_body.gif" width="125" height="200" border="0" '
    10.         . 'alt="" align="left" style="margin-right: 15px" />The '
    11.         . 'barkeeper is serving free beer!<br />');
    12.     etc.
    13. }

The class name should be the same as the filename, with the first letter capitalized.

Note that because of PHP namespace limitations, currently the classname must be unique in your universe. We plan on supporting auto-class names.

There are various methods you can call (like setTitle) or define (like createDpPage) which will be discussed next.

DpObject

DpNpc extends on the DpObject class which implements common object functionality, so all definable methods and callable methods made available by DpObject are also available when creating a Npc.

If you haven't done so, you should first read the DpObject documentation.

DpLiving

Also, DpNpc extends on the DpLiving class, common code for users and computer generated characters.

If you haven't done so, you should first read the DpLiving documentation.


    DpPage >

Documentation generated on Mon, 03 Sep 2007 22:17:44 +0200 by phpDocumentor 1.3.0RC6

Click me!
Guest#1780
 
 
 
  Go to Top
 
 
Input Field OptionsClose Input Field Go to Top
 
Legal Notices | Copyright © 2006, 2007 Lennert Stock. All rights reserved. Last update: Mon Sep 03 2007, 21:50 CET.