15 Aug, 2009, Xrakisis wrote in the 1st comment:
Votes: 0
Hi All,
I have the player houses snippit installed and working.
Id like to modify it and add on to it to have player run towns.
The first problem im having is im not sure how to add on
and link rooms to the begining 5.. what i tried is below and
commented out, any suggestions would be greatly appreciated.
-Xrakisis, Ian Shirm

void do_house( CHAR_DATA *ch, char *argument )
{
CHAR_DATA *architect;
char arg[MIL];
int osec;
char buf[MSL];
int i,i2;
int cost = 100000;
HOUSE_DATA *hOuse;

architect = find_architect( ch );

if (!architect)
return;

argument = one_argument( argument, arg );

if (IS_NPC(ch))
{
send_to_char("Sorry, you'll have to just wander, mobile.\n\r",ch);
return;
}

if ( arg[0] == '\0' && HAS_HOME( ch ) )
{
send_to_char( "You already bought a house. To sell it type house <sell>.\n\r", ch );
send_to_char( "You can also value your house. Type house <value>\n\r", ch );
return;
}

if ( !str_cmp( arg, "sell" ) && HAS_HOME( ch ) )
{
home_sell( ch, cost );
return;
}

if ( !str_cmp( arg, "value" ) && HAS_HOME( ch ) )
{
int value,t;

for ( hOuse = house_list; hOuse != NULL; hOuse = hOuse->next )
{
if ( !str_cmp( ch->name, hOuse->oname ) )
break;

value += ( hOuse->ovalue + hOuse->mvalue );
t++;
save_house();

}

printf_to_char( ch, "You have a total of %d mobs and objects in your house.\n\r", t );
printf_to_char( ch, "Your house is valued at a total of %d gold.\n\r", ( cost / 2 ) + value );
return;
}

if ( HAS_HOME( ch ) )
{
send_to_char( "You already own a house. To sell it type house <sell>.\n\r", ch );
return;
}

if (ch->gold < cost && !IS_IMMORTAL(ch))
{
printf_to_char( ch, "I'm sorry but it cost %d gold to buy a house.\n\r", cost );
return;
}

i = VNUM_START;

while (get_room_index(i) != NULL)
{
i++;

if (i > VNUM_STOP - 5)
{
send_to_char("Sorry all of the house vnums are used up! Tell an immortal.\n\r", ch );
return;
}
}

send_to_char("Okay… Attempting creation of your home.\n\r\n\r",ch);
ch->gold -= cost;
osec = ch->pcdata->security;
ch->pcdata->security = 5;

for (i2 = 5;i2 >= 0;i2–) // was for (i2 = 4;i2 >= 0;i2–) -xrak
// i2 needs to be 24
{
sprintf(buf,"%d",i+i2);

if( !redit_create( ch, buf ) )
{
send_to_char("Unable to create your house. Contact an Immortal.\n\r",ch);
return;
}

ch->desc->editor = ED_ROOM;
char_from_room( ch );
char_to_room( ch, ch->desc->pEdit );
SET_BIT( ((ROOM_INDEX_DATA *)ch->desc->pEdit)->area->area_flags, AREA_CHANGED );
sprintf(buf,"%s's Home",ch->name);
redit_name(ch,buf);
}

/*
* Link the rooms together
* 3
* |
* 2–1–4
* |
* 5
*/

/*
This is what i want the layout of the town to be
8 == temp 6
X6 X7 X8 X9 X10
X11 S12 A3 H13 X14
X15 +2 F1 +4 X16
X17 H18 |5 B19 X20
X21 X22 X23 X24 X25
*/

sprintf(buf,"link %d",i+1);
change_exit(ch,buf,DIR_WEST);
sprintf(buf,"link %d",i+2);
change_exit(ch,buf,DIR_NORTH);
sprintf(buf,"link %d",i+3);
change_exit(ch,buf,DIR_EAST);
sprintf(buf,"link %d",i+4);
change_exit(ch,buf,DIR_SOUTH);

// This is what i tried, but didnt work :(
// ch->desc->editor = ED_ROOM;
// char_from_room( ch );
// char_to_room( ch,i+2 );
// sprintf(buf,"link %d",i+5);
// change_exit(ch,buf,DIR_NORTH);


if ( osec > 1 )
ch->pcdata->security = osec;
send_to_char("\n\rHURRAY! Your house was made successfully.\n\r",ch);
ch->pcdata->h_vnum = i;
save_area(ch->in_room->area);
edit_done(ch);
return;
}
16 Aug, 2009, Sharmair wrote in the 2nd comment:
Votes: 0
First, though not the problem with your linking, that value option does not seem right. Seems you should
at least be getting some warning about using t and value uninitialized, and even at that, I don't think it
is doing what is intended.

Your main problem seems you are using the vnum instead of the ROOM_INDEX_DATA* in your char_to_room()
call. you should be able to replace the i+2 with get_room_index(i+2) to get the char moved into the proper
room. I don't know how your OLC here works, but if change_exit() works using the current room the char is
in as the base room, it should make the exit like you intend. You might have to set the editing room in
ch->desc->pEdit though if your OLC requires that (again, I don't know your OLC).

One other thing I noticed, when the code is looking for free rooms, it is still looking for 5, make sure you change
that to 25 too (maybe a good place to use a #define).
16 Aug, 2009, Dean wrote in the 3rd comment:
Votes: 0
Just a few questions: What will constitute a player-run town? (Several houses, a street, shop maybe?) And what sort of things do you want players to be able to do in regards to player-run towns?
16 Aug, 2009, Xrakisis wrote in the 4th comment:
Votes: 0
What i want for player run towns, will be:
When player buys town, its generated and they become Governor.
Fountain, Healing Pool, Vault (locker) created
a few houses with civilian families created.
Ability to buy Military Units, Army and Militia.
Ton of SPEC_ stuff for the players mobs.
Manually link players town to a road, so
the player can roam to another town with his army,
and leave his militia at home.
Town Closed to enemy armies while player is offline or AFK
Player run shop in their town, can 'sell' item to shopkeeper,
then when someone buys it, u get a message when u log on
and it gets deposited in ur bank.
-Xrakisis, Ian Shirm
0.0/4