[mordor]상점개설
/*******************************************************/
/* */
/* 상점관련 소스입니다. */
/* 편의상 파일을 하나 만들어서 관리하는게 편하실듯.. */
/* 아무튼 유용하게 쓰세요 ^^& */
/* 기타 문의는 msn tkeo@grayrese.com 로 해주세요 -ㅅ- */
/* */
/* http://www.grayrese.com */
/* tkeo@dreamwiz.com */
/* GrayRese */
/* */
/*******************************************************/
//참고로 비리아이템 체크하는 프로그램 응용했습니다.
//방 만들고 어쩌고 하는 방법도 있는데
//이 방법은 자신의 소지품에 플레그를 걸어서
//직접 판매하는 방법입니다.
#include "mstruct.h"
#include "mextern.h"
/*************/
/* 상점-개설 */
/*************/
int shop_list(ply_ptr, cmnd)
creature *ply_ptr;
cmd *cmnd;
{
char str[2048];
int fd;
room *rom_ptr;
creature *crt_ptr;
otag *op;
rom_ptr = ply_ptr->parent_rom;
fd = ply_ptr->fd;
if(F_ISSET(ply_ptr, PBLIND)) {
ANSI(fd, BLUE);
print(fd, "당신은 눈이 멀어서 아무것도 볼 수가 없습니다!");
ANSI(fd, WHITE);
return(0);
}
crt_ptr = find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[1], cmnd->val[1]);
if(!crt_ptr) {
lowercize(cmnd->str[1], 1);
crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply, cmnd->str[1], cmnd->val[1]);
if(!crt_ptr) {
print(fd, "그런 사람 없어요!");
return(0);
}
}
if(!F_ISSET(crt_ptr, PGSHOP)) {
print(fd, "그 사람은 상점을 차리지 않았습니다.");
return(0);
}
op = crt_ptr->first_obj;
if(!op) {
print(fd,"그가 팔고 있는 물건은 없습니다.");
return(0);
}
else {
print(fd, "%s님이 팔고 있는 물건", crt_ptr);
while(op) {
if(F_ISSET(op->obj, OSEITE))
print(fd, "\n %-30s 가격: %ld", obj_str(op->obj, 1, CAP), op->obj->gold);
op = op->next_tag;
}
}
return(0);
}
/*************/
/* 상점-구입 */
/*************/
int shop_buy(creature* ply_ptr, cmd* cmnd)
{
int i, cnt, fd;
creature *crt_ptr;
room *rom_ptr;
object *obj_ptr;
rom_ptr = ply_ptr->parent_rom;
fd = ply_ptr->fd;
if( cmnd->num < 2 ) {
print(fd, "\n무엇을 구입하시려구요?");
return(0);
}
if( cmnd->num < 3 ) {
print(fd, "\n사용법: <괴물이름> <물건> 구입");
return(0);
}
cmnd->str[1][0] = up(cmnd->str[1][0]);
crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply, cmnd->str[1], cmnd->val[1]);
if(!crt_ptr) {
cmnd->str[1][0] = low(cmnd->str[1][0]);
crt_ptr = find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[1], cmnd->val[1]);
if(!crt_ptr) {
print(fd, "그런 사람은 여기 없어요!\n");
return(0);
}
}
if(!F_ISSET(crt_ptr, PGSHOP)) {
print(fd,"그 사람은 상점을 차리지 않았습니다.");
return(0);
}
for(i = 0, cnt = 0; i < MAXWEAR; i++)
if( ply_ptr->ready[i] ) cnt++;
cnt += count_inv(ply_ptr, -1);
obj_ptr = find_obj(ply_ptr, crt_ptr->first_obj, cmnd->str[2], cmnd->val[2]);
if( !obj_ptr ) {
print(fd, "\n그런 물건은 팔지 않습니다.");
return(0);
}
if( ply_ptr->gold < obj_ptr->gold ) {
print(fd, "\n돈이 모자랍니다.");
return(0);
}
if( weight_ply(ply_ptr) + weight_obj(obj_ptr) > max_weight(ply_ptr) || cnt >= 150 )
{
print(fd, "\n당신은 더이상 가질 수 없습니다.");
return(0);
}
ply_ptr->gold -= obj_ptr->gold;
crt_ptr->gold += obj_ptr->gold;
del_obj_crt(obj_ptr, crt_ptr);
add_obj_crt(obj_ptr, ply_ptr);
F_CLR(obj_ptr, OSEITE);
F_CLR(ply_ptr, PHIDDN);
print(fd, "\n당신은 %I%j 샀습니다.", obj_ptr, "3");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M%j %I%j 샀습니다.", ply_ptr, "1", obj_ptr, "3");
savegame_nomsg(ply_ptr);
return(0);
}
/*************/
/* 상점-닫기 */
/*************/
int shop_close(ply_ptr)
creature *ply_ptr;
{
int fd;
otag *op;
fd = ply_ptr->fd;
op = ply_ptr->first_obj;
if(!F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 상점을 차리지 않았습니다.");
return(0);
}
F_CLR(ply_ptr, PGSHOP);
while(op) {
if(F_ISSET(op->obj, OSEITE))
F_CLR(op->obj, OSEITE);
op = op->next_tag;
}
print(fd, "당신은 자리를 자리를 접고 일어납니다.");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 자리를 접고 일어납니다.", ply_ptr, "1");
return(0);
}
/************/
/* 상점-개설 */
/************/
int shop_open(ply_ptr)
creature *ply_ptr;
{
int fd;
fd = ply_ptr->fd;
if(F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 벌써 상점을 차리고 있습니다.");
return(0);
}
F_SET(ply_ptr, PGSHOP);
print(fd, "당신은 자리를 깔고 장사할 준비를 합니다.");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 자리를 깔고 장사할 준비를 합니다.", ply_ptr, "1");
return(0);
}
/*****************/
/* 상점-물건등록 */
/*****************/
int shop_setting(ply_ptr, cmnd)
creature *ply_ptr;
cmd *cmnd;
{
int fd;
creature *crt_ptr;
object *obj_ptr;
fd = ply_ptr->fd;
obj_ptr = find_obj(ply_ptr, ply_ptr->first_obj, cmnd->str[1], cmnd->val[1]);
if(!F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 상점을 차리지 않았습니다.");
return(0);
}
if(F_ISSET(obj_ptr, OSEITE)) {
print(fd, "그 상품은 이미 진열되어 있습니다.");
return(0);
}
if(!obj_ptr) {
print(fd, "그런 물건은 없습니다.");
return(0);
}
F_SET(obj_ptr, OSEITE);
print(fd, "\n당신은 %I%j 진열대에 올렸습니다.",obj_ptr, "3");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 %I%j 진열대에 올려놨습니다.", ply_ptr, obj_ptr, "3");
return(0);
}
/*********************/
/* 상점-물건등록해제 */
/*********************/
int shop_unsetting(ply_ptr, cmnd)
creature *ply_ptr;
cmd *cmnd
{
int fd;
creature *crt_ptr;
object *obj_ptr;
fd = ply_ptr->fd;
obj_ptr = find_obj(ply_ptr, ply_ptr->first_obj, cmnd->str[1], cmnd->val[1]);
if(!obj_ptr) {
print(fd, "그런 물건은 없습니다.");
return(0);
}
if(!F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 상점을 차리지 않았습니다.");
return(0);
}
F_CLR(obj_ptr, OSEITE);
print(fd, "\n당신은 %I%j 진열대에 내렸습니다.",obj_ptr, "3");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 %I%j 진열대에서 내려놨습니다.", ply_ptr, obj_ptr, "3");
return(0);
}
/*****************/
/* 상점-물건가격 */
/*****************/
int shop_value(ply_ptr, cmnd)
creature *ply_ptr;
cmd *cmnd;
{
int fd, len;
long amt;
creature *crt_ptr;
object *obj_ptr;
fd = ply_ptr->fd;
amt = atol(cmnd->str[2]);
obj_ptr = find_obj(ply_ptr, ply_ptr->first_obj, cmnd->str[1], cmnd->val[1]);
if(!obj_ptr) {
print(fd, "그런 물건은 없습니다.");
return(0);
}
if(!F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 상점을 차리지 않았습니다.");
return(0);
}
len = strlen(cmnd->str[2]);
if(len>2 && strcmp(&cmnd->str[2][len-2],"엘")) {
print(fd, "금액 뒤에는 '엘'을 붙여야 합니다.");
return(0);
}
if(amt < 1) {
print(fd, "돈의 단위는 음수가 될수 없습니다.\n");
return(0);
}
obj_ptr->gold= amt;
print(fd, "\n당신은 %I의 가격을 %d엘로 책정합니다.",obj_ptr, obj_ptr->gold);
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 %I의 가격을 %d엘로 책정했습니다.", ply_ptr, obj_ptr, obj_ptr->gold);
return(0);
}
/* */
/* 상점관련 소스입니다. */
/* 편의상 파일을 하나 만들어서 관리하는게 편하실듯.. */
/* 아무튼 유용하게 쓰세요 ^^& */
/* 기타 문의는 msn tkeo@grayrese.com 로 해주세요 -ㅅ- */
/* */
/* http://www.grayrese.com */
/* tkeo@dreamwiz.com */
/* GrayRese */
/* */
/*******************************************************/
//참고로 비리아이템 체크하는 프로그램 응용했습니다.
//방 만들고 어쩌고 하는 방법도 있는데
//이 방법은 자신의 소지품에 플레그를 걸어서
//직접 판매하는 방법입니다.
#include "mstruct.h"
#include "mextern.h"
/*************/
/* 상점-개설 */
/*************/
int shop_list(ply_ptr, cmnd)
creature *ply_ptr;
cmd *cmnd;
{
char str[2048];
int fd;
room *rom_ptr;
creature *crt_ptr;
otag *op;
rom_ptr = ply_ptr->parent_rom;
fd = ply_ptr->fd;
if(F_ISSET(ply_ptr, PBLIND)) {
ANSI(fd, BLUE);
print(fd, "당신은 눈이 멀어서 아무것도 볼 수가 없습니다!");
ANSI(fd, WHITE);
return(0);
}
crt_ptr = find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[1], cmnd->val[1]);
if(!crt_ptr) {
lowercize(cmnd->str[1], 1);
crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply, cmnd->str[1], cmnd->val[1]);
if(!crt_ptr) {
print(fd, "그런 사람 없어요!");
return(0);
}
}
if(!F_ISSET(crt_ptr, PGSHOP)) {
print(fd, "그 사람은 상점을 차리지 않았습니다.");
return(0);
}
op = crt_ptr->first_obj;
if(!op) {
print(fd,"그가 팔고 있는 물건은 없습니다.");
return(0);
}
else {
print(fd, "%s님이 팔고 있는 물건", crt_ptr);
while(op) {
if(F_ISSET(op->obj, OSEITE))
print(fd, "\n %-30s 가격: %ld", obj_str(op->obj, 1, CAP), op->obj->gold);
op = op->next_tag;
}
}
return(0);
}
/*************/
/* 상점-구입 */
/*************/
int shop_buy(creature* ply_ptr, cmd* cmnd)
{
int i, cnt, fd;
creature *crt_ptr;
room *rom_ptr;
object *obj_ptr;
rom_ptr = ply_ptr->parent_rom;
fd = ply_ptr->fd;
if( cmnd->num < 2 ) {
print(fd, "\n무엇을 구입하시려구요?");
return(0);
}
if( cmnd->num < 3 ) {
print(fd, "\n사용법: <괴물이름> <물건> 구입");
return(0);
}
cmnd->str[1][0] = up(cmnd->str[1][0]);
crt_ptr = find_crt(ply_ptr, rom_ptr->first_ply, cmnd->str[1], cmnd->val[1]);
if(!crt_ptr) {
cmnd->str[1][0] = low(cmnd->str[1][0]);
crt_ptr = find_crt(ply_ptr, rom_ptr->first_mon, cmnd->str[1], cmnd->val[1]);
if(!crt_ptr) {
print(fd, "그런 사람은 여기 없어요!\n");
return(0);
}
}
if(!F_ISSET(crt_ptr, PGSHOP)) {
print(fd,"그 사람은 상점을 차리지 않았습니다.");
return(0);
}
for(i = 0, cnt = 0; i < MAXWEAR; i++)
if( ply_ptr->ready[i] ) cnt++;
cnt += count_inv(ply_ptr, -1);
obj_ptr = find_obj(ply_ptr, crt_ptr->first_obj, cmnd->str[2], cmnd->val[2]);
if( !obj_ptr ) {
print(fd, "\n그런 물건은 팔지 않습니다.");
return(0);
}
if( ply_ptr->gold < obj_ptr->gold ) {
print(fd, "\n돈이 모자랍니다.");
return(0);
}
if( weight_ply(ply_ptr) + weight_obj(obj_ptr) > max_weight(ply_ptr) || cnt >= 150 )
{
print(fd, "\n당신은 더이상 가질 수 없습니다.");
return(0);
}
ply_ptr->gold -= obj_ptr->gold;
crt_ptr->gold += obj_ptr->gold;
del_obj_crt(obj_ptr, crt_ptr);
add_obj_crt(obj_ptr, ply_ptr);
F_CLR(obj_ptr, OSEITE);
F_CLR(ply_ptr, PHIDDN);
print(fd, "\n당신은 %I%j 샀습니다.", obj_ptr, "3");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M%j %I%j 샀습니다.", ply_ptr, "1", obj_ptr, "3");
savegame_nomsg(ply_ptr);
return(0);
}
/*************/
/* 상점-닫기 */
/*************/
int shop_close(ply_ptr)
creature *ply_ptr;
{
int fd;
otag *op;
fd = ply_ptr->fd;
op = ply_ptr->first_obj;
if(!F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 상점을 차리지 않았습니다.");
return(0);
}
F_CLR(ply_ptr, PGSHOP);
while(op) {
if(F_ISSET(op->obj, OSEITE))
F_CLR(op->obj, OSEITE);
op = op->next_tag;
}
print(fd, "당신은 자리를 자리를 접고 일어납니다.");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 자리를 접고 일어납니다.", ply_ptr, "1");
return(0);
}
/************/
/* 상점-개설 */
/************/
int shop_open(ply_ptr)
creature *ply_ptr;
{
int fd;
fd = ply_ptr->fd;
if(F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 벌써 상점을 차리고 있습니다.");
return(0);
}
F_SET(ply_ptr, PGSHOP);
print(fd, "당신은 자리를 깔고 장사할 준비를 합니다.");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 자리를 깔고 장사할 준비를 합니다.", ply_ptr, "1");
return(0);
}
/*****************/
/* 상점-물건등록 */
/*****************/
int shop_setting(ply_ptr, cmnd)
creature *ply_ptr;
cmd *cmnd;
{
int fd;
creature *crt_ptr;
object *obj_ptr;
fd = ply_ptr->fd;
obj_ptr = find_obj(ply_ptr, ply_ptr->first_obj, cmnd->str[1], cmnd->val[1]);
if(!F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 상점을 차리지 않았습니다.");
return(0);
}
if(F_ISSET(obj_ptr, OSEITE)) {
print(fd, "그 상품은 이미 진열되어 있습니다.");
return(0);
}
if(!obj_ptr) {
print(fd, "그런 물건은 없습니다.");
return(0);
}
F_SET(obj_ptr, OSEITE);
print(fd, "\n당신은 %I%j 진열대에 올렸습니다.",obj_ptr, "3");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 %I%j 진열대에 올려놨습니다.", ply_ptr, obj_ptr, "3");
return(0);
}
/*********************/
/* 상점-물건등록해제 */
/*********************/
int shop_unsetting(ply_ptr, cmnd)
creature *ply_ptr;
cmd *cmnd
{
int fd;
creature *crt_ptr;
object *obj_ptr;
fd = ply_ptr->fd;
obj_ptr = find_obj(ply_ptr, ply_ptr->first_obj, cmnd->str[1], cmnd->val[1]);
if(!obj_ptr) {
print(fd, "그런 물건은 없습니다.");
return(0);
}
if(!F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 상점을 차리지 않았습니다.");
return(0);
}
F_CLR(obj_ptr, OSEITE);
print(fd, "\n당신은 %I%j 진열대에 내렸습니다.",obj_ptr, "3");
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 %I%j 진열대에서 내려놨습니다.", ply_ptr, obj_ptr, "3");
return(0);
}
/*****************/
/* 상점-물건가격 */
/*****************/
int shop_value(ply_ptr, cmnd)
creature *ply_ptr;
cmd *cmnd;
{
int fd, len;
long amt;
creature *crt_ptr;
object *obj_ptr;
fd = ply_ptr->fd;
amt = atol(cmnd->str[2]);
obj_ptr = find_obj(ply_ptr, ply_ptr->first_obj, cmnd->str[1], cmnd->val[1]);
if(!obj_ptr) {
print(fd, "그런 물건은 없습니다.");
return(0);
}
if(!F_ISSET(ply_ptr, PGSHOP)) {
print(fd, "당신은 상점을 차리지 않았습니다.");
return(0);
}
len = strlen(cmnd->str[2]);
if(len>2 && strcmp(&cmnd->str[2][len-2],"엘")) {
print(fd, "금액 뒤에는 '엘'을 붙여야 합니다.");
return(0);
}
if(amt < 1) {
print(fd, "돈의 단위는 음수가 될수 없습니다.\n");
return(0);
}
obj_ptr->gold= amt;
print(fd, "\n당신은 %I의 가격을 %d엘로 책정합니다.",obj_ptr, obj_ptr->gold);
broadcast_rom(fd, ply_ptr->rom_num, "\n%M님이 %I의 가격을 %d엘로 책정했습니다.", ply_ptr, obj_ptr, obj_ptr->gold);
return(0);
}
3Comments
달마
2004.05.27(목) 오후 06:47:19
수고 많으십니다~~ 화이팅.!!
Raven
2004.05.30(일) 오후 09:23:38
아이템에 플래그를 따로 지정하는 방법으로 하셨군요.
전 따로 컨테이너를 만들고 거기에 팔 물건을 담아두는 걸로 만들어 본적이 있었죠. ^^;
전 따로 컨테이너를 만들고 거기에 팔 물건을 담아두는 걸로 만들어 본적이 있었죠. ^^;
GrayRese
2004.05.30(일) 오후 11:36:03
그렇게 하면 방을 따로 만들고 어쩌고 해야되서 좀 번거로울거 같아서 이렇게 했죠-_-ㅁㅁ
근데 경매가 있어서 이게 거의 필요가 없더군요-_-..
뭐 상인이란 부업같은걸 만들어서 이 스킬이 얼만큼 있어야 경매하고 할수 있다고
하면 모를까요-_-ㅁㅁ
근데 경매가 있어서 이게 거의 필요가 없더군요-_-..
뭐 상인이란 부업같은걸 만들어서 이 스킬이 얼만큼 있어야 경매하고 할수 있다고
하면 모를까요-_-ㅁㅁ
코멘트를 삭제할 비밀번호를 입력하세요.
정회원 이상만 코멘트 쓰기가 가능합니다.
총 게시물 109개 / 검색된 게시물: 109개
글번호 | 제목 | 작성자 | 조회수 | 좋아요 | 싫어요 | 작성일 | |
---|---|---|---|---|---|---|---|
[기타]누구든지 머드 강의를 올리수 있는 곳입니다...^^ | 머드클럽 | 4551 | 0 | 0 | 2003-12-31 | ||
69 | [기타] 윈도우에서 리눅스버전 머드 돌려보기. [1] | 손문 | 3622 | 0 | 0 | 2004-09-25 | |
68 | [mordor] 사전딜레이. [1] | GrayRese | 2867 | 0 | 0 | 2004-09-06 | |
67 | [circle] 서클의 지도 공부.. | 머드짱 | 3130 | 0 | 0 | 2004-09-03 | |
66 | [천무혼] 은행 시스템 만들기! [2] | 천무혼 | 2996 | 0 | 0 | 2004-08-12 | |
65 | [흑염] 기술의 지속시간과 향상 능력치를 call_out 없이 구현. [1] | 흑염기사 | 3162 | 0 | 0 | 2004-08-12 | |
64 | [천무혼] 없는 명령어를 입력했을때 나오는 '^^;' 바꾸기 [3] | 천무혼 | 2843 | 0 | 0 | 2004-08-09 | |
63 | [기타] vi 에디터의 안시에 관한 내용입니다. [1] | 머드사랑(1) | 3095 | 0 | 0 | 2004-07-26 | |
62 | [circle] Ascii Player files 패치된 써클머드 한글화 시키기! [2] | 미르 | 3405 | 0 | 0 | 2004-07-06 | |
61 | [흑염] [천명]노점상인.c 천명 삼일장에서 사용되고있는 노점상인 쏘스. [1] | 흑염기사 | 4410 | 0 | 0 | 2004-06-13 | |
60 | [흑염] [천명] save_data.c - 특정 오브젝트의 플래그를 아이템 파일처럼 저장시켜준다. | 흑염기사 | 2742 | 0 | 0 | 2004-06-13 | |
59 | [흑염] [천명] req_string.c - mapping을 보기좋게 string으로. | 흑염기사 | 2840 | 0 | 0 | 2004-06-13 | |
58 | [mordor] 상점개설 [3] | GrayRese | 3083 | 0 | 0 | 2004-05-27 | |
57 | [mordor] 게시판의 기능 편하게..(위로 올라가고, 글쓰기기능 추가) [1] | 달마 | 3269 | 0 | 0 | 2004-05-19 | |
56 | [circle] hanlp의 지도.c | 사천건 | 3383 | 0 | 0 | 2004-05-18 | |
55 | [circle] 시간의문 경험치 못먹는거 먹게하는방법(허접이라두 잘봐주세영) [4] | 손문 | 2854 | 0 | 0 | 2004-05-07 | |
54 | [hanlp] [천명] 완치 이벤트 ...... [2] | 어두운별 | 3194 | 0 | 0 | 2004-04-30 | |
53 | [기타] gdb 사용법! [3] | GrayRese | 4600 | 0 | 0 | 2004-04-23 | |
52 | [hanlp] 현재 습득한 기술 목록 보이기. [2] | 박대성 | 2970 | 0 | 0 | 2004-04-19 | |
51 | [circle] 새천사님의 수정 사항에 추가할점.. [1] | 푸른가람 | 2842 | 0 | 0 | 2004-04-03 | |
50 | [hanlp] 10초간 데미지와 방어력 상승 [2] | 박대성 | 3009 | 0 | 0 | 2004-03-14 |