Skip to content

Commit

Permalink
Added CREATE ART.
Browse files Browse the repository at this point in the history
  • Loading branch information
luciensadi committed Nov 26, 2023
1 parent 1a94432 commit a86bb7d
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 20 deletions.
19 changes: 10 additions & 9 deletions lib/world/obj/0.obj
Original file line number Diff line number Diff line change
Expand Up @@ -1290,19 +1290,20 @@ Material: metal
Barrier: 32
BREAK
#125
Keywords: white tunic keyn jraye
Name: a white tunic
Keywords: art creative work
Name: a work of art
RoomDesc:$
A white tunic is folded neatly here.~
Someone's unfinished creative effort has been left here.~
LookDesc:$
A plain white tunic, made of a soft, high-quality linen. The fabric feels
odd, as if its not made of anything... earthly.
The artist hasn't yet rendered their vision here.
~
Type: Worn
WearFlags: 100001
Material: fabric
Type: Art
WearFlags: 1
ExtraFlags: 1000000000
Material: paper
[POINTS]
Barrier: 32
Weight: 0.10
Barrier: 4
BREAK
#126
Keywords: silver cord
Expand Down
32 changes: 26 additions & 6 deletions src/act.informative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,17 @@ void show_obj_to_char(struct obj_data * object, struct char_data * ch, int mode)
SPECIAL(pocket_sec);

*buf = '\0';

if (GET_OBJ_TYPE(object) == ITEM_CREATIVE_EFFORT) {
strlcat(buf, "^c(Art) ^n", sizeof(buf));
}

if ((mode == SHOW_MODE_ON_GROUND) && object->text.room_desc) {
strlcpy(buf, CCHAR ? CCHAR : "", sizeof(buf));
strlcat(buf, CCHAR ? CCHAR : "", sizeof(buf));

if (object->graffiti) {
strlcat(buf, object->graffiti, sizeof(buf));
strlcat(buf, "^n", sizeof(buf));
}
else {
// Gun magazines get special consideration.
Expand Down Expand Up @@ -311,7 +318,7 @@ void show_obj_to_char(struct obj_data * object, struct char_data * ch, int mode)
}
}
else if (GET_OBJ_NAME(object) && (mode == SHOW_MODE_IN_INVENTORY || mode == SHOW_MODE_INSIDE_CONTAINER)) {
strlcpy(buf, GET_OBJ_NAME(object), sizeof(buf));
strlcat(buf, GET_OBJ_NAME(object), sizeof(buf));
if (GET_OBJ_TYPE(object) == ITEM_DESIGN)
strlcat(buf, " (Plan)", sizeof(buf));
if (GET_OBJ_VNUM(object) == 108 && !GET_OBJ_TIMER(object))
Expand Down Expand Up @@ -349,16 +356,17 @@ void show_obj_to_char(struct obj_data * object, struct char_data * ch, int mode)
}
}
else if (GET_OBJ_NAME(object) && ((mode == 3) || (mode == 4) || (mode == SHOW_MODE_OWN_EQUIPMENT) || (mode == SHOW_MODE_SOMEONE_ELSES_EQUIPMENT))) {
strlcpy(buf, GET_OBJ_NAME(object), sizeof(buf));
strlcat(buf, GET_OBJ_NAME(object), sizeof(buf));
}
else if (mode == SHOW_MODE_JUST_DESCRIPTION) {
// Deliberately using strlcpy here to overwrite the (Art) tag.
if (GET_OBJ_DESC(object))
strlcpy(buf, GET_OBJ_DESC(object), sizeof(buf));
else
strlcpy(buf, "You see nothing special..", sizeof(buf));
}
else if (mode == SHOW_MODE_CONTAINED_OBJ) {
snprintf(buf, sizeof(buf), "\t\t\t\t%s", GET_OBJ_NAME(object));
snprintf(ENDOF(buf), sizeof(buf) - strlen(buf), "\t\t\t\t%s", GET_OBJ_NAME(object));
}

if (mode == SHOW_MODE_SOMEONE_ELSES_EQUIPMENT) {
Expand Down Expand Up @@ -3730,6 +3738,15 @@ void do_probe_object(struct char_data * ch, struct obj_data * j, bool is_in_shop
ammo_type[GET_OBJ_VAL(j, 2)].name,GET_OBJ_VAL(j, 0) != 1 ? "s" : "",
weapon_types[GET_OBJ_VAL(j, 1)]);
break;
case ITEM_CREATIVE_EFFORT:
if (IS_SENATOR(ch)) {
const char *author_name = get_player_name(GET_ART_AUTHOR_IDNUM(j));
snprintf(ENDOF(buf), sizeof(buf) - strlen(buf), "It was created by ^c%s^n (%d).\r\n", author_name, GET_ART_AUTHOR_IDNUM(j));
delete [] author_name;
} else {
strlcat(buf, "Nothing stands out about this item's OOC values. Try EXAMINE it instead.", sizeof(buf));
}
break;
case ITEM_OTHER:
if (GET_OBJ_VNUM(j) == OBJ_NEOPHYTE_SUBSIDY_CARD) {
snprintf(ENDOF(buf), sizeof(buf) - strlen(buf), "It is bonded to %s and has %d nuyen remaining on it.\r\n",
Expand Down Expand Up @@ -3770,7 +3787,7 @@ void do_probe_object(struct char_data * ch, struct obj_data * j, bool is_in_shop
do_probe_object(ch, j->contains, FALSE);
return;
default:
strncpy(buf, "This item type has no probe string. Contact the staff to request one.", sizeof(buf) - strlen(buf));
strncpy(buf, "This item type has no probe string. Contact staff to request one.", sizeof(buf) - strlen(buf));
break;
}

Expand Down Expand Up @@ -4123,7 +4140,10 @@ ACMD(do_examine)
send_to_char("It has not been ^WBOND^ned yet, and ^ywill not function until it is^n.\r\n\r\n", ch);
}
}
if (GET_OBJ_VNUM(tmp_object) > 1) {

if (GET_OBJ_TYPE(tmp_object) == ITEM_CREATIVE_EFFORT) {
send_to_char(ch, "^L(OOC: It's a custom object with no coded effect.)^n\r\n");
} else if (GET_OBJ_VNUM(tmp_object) > 1) {
snprintf(buf, sizeof(buf), "You %s that %s ",
GET_SKILL(ch, SKILL_POLICE_PROCEDURES) <= 0 ? "have no training in Police Procedures, but you guess" : "think",
GET_OBJ_NAME(tmp_object));
Expand Down
9 changes: 6 additions & 3 deletions src/awake.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,8 @@ enum {
#define ITEM_GRAFFITI 46
#define ITEM_DESTROYABLE 47
#define ITEM_LOADED_DECORATION 48
#define NUM_ITEMS 49
#define ITEM_CREATIVE_EFFORT 49
#define NUM_ITEMS 50
// Adding something? Add convenience definees to utils.hpp and put the type's name in constants.cpp.

#define PATCH_ANTIDOTE 0
Expand Down Expand Up @@ -2222,7 +2223,8 @@ enum {
#define CON_HOUSEEDIT_APARTMENT 49
#define CON_DECORATE_VEH 50
#define CON_TEMPDESC_EDIT 51
#define CON_MAX 51
#define CON_ART_CREATE 52
#define CON_MAX 52
// If you add another state, you need to touch comm.cpp's close_socket and make sure it's reflected there!
// Also add it to constants's connected_types.

Expand Down Expand Up @@ -2724,7 +2726,8 @@ enum {
#define OBJ_CUSTOM_NERPS_CYBERWARE 122
#define OBJ_CUSTOM_NERPS_BIOWARE 123
#define OBJ_RITUAL_SPELL_COMPONENTS 124
#define TOP_OF_TEMPLATE_ITEMS 124
#define OBJ_CUSTOM_ART 125
#define TOP_OF_TEMPLATE_ITEMS 125

#define OBJ_BLANK_MAGAZINE 127

Expand Down
2 changes: 1 addition & 1 deletion src/comm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,7 @@ void close_socket(struct descriptor_data *d)
/* added to Free up temporary editing constructs */
if (d->connected == CON_PLAYING
|| d->connected == CON_PART_CREATE
|| (d->connected >= CON_SPELL_CREATE && d->connected <= CON_TEMPDESC_EDIT && d->connected != CON_ASKNAME))
|| (d->connected >= CON_SPELL_CREATE && d->connected <= CON_ART_CREATE && d->connected != CON_ASKNAME))
{
if (d->connected == CON_VEHCUST)
d->edit_veh = NULL;
Expand Down
2 changes: 2 additions & 0 deletions src/constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ const char *connected_types[] =
"Apartment Editing",
"Vehicle Decorating",
"Tempdesc Editing",
"Creating Art",
"\n"
};

Expand Down Expand Up @@ -1047,6 +1048,7 @@ const char *item_types[] =
"Graffiti",
"Destroyable",
"Loaded Decoration",
"Art",
"\n"
};

Expand Down
96 changes: 96 additions & 0 deletions src/creative_works.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "structs.hpp"
#include "db.hpp"
#include "olc.hpp"
#include "handler.hpp"
#include "creative_works.hpp"

#define CH d->character
#define ART d->edit_obj

void create_art_main_menu(struct descriptor_data *d) {
CLS(CH);
send_to_char(CH, "1) ^cName: ^n%s^n\r\n", GET_OBJ_NAME(ART));
send_to_char(CH, "2) ^cDescription: ^n%s^n\r\n", ART->photo ? ART->photo : ART->text.look_desc);
send_to_char(CH, "3) ^cRoom Description: ^n%s^n\r\n", ART->graffiti ? ART->graffiti : ART->text.room_desc);
send_to_char(CH, "q) ^cSave and Quit^n\r\n");
send_to_char(CH, "Enter Option: ");

STATE(d) = CON_ART_CREATE;
d->edit_mode = ART_EDIT_MAIN;
}

void art_edit_parse(struct descriptor_data *d, const char *arg) {
switch(d->edit_mode) {
case ART_EDIT_MAIN:
switch (*arg) {
case '1':
send_to_char(CH, "Enter artwork's name: ");
d->edit_mode = ART_EDIT_NAME;
break;
case '2':
send_to_char(CH, "Enter artwork's look description:\r\n");
d->edit_mode = ART_EDIT_DESC;
DELETE_D_STR_IF_EXTANT(d);
INITIALIZE_NEW_D_STR(d);
d->max_str = MAX_MESSAGE_LENGTH;
d->mail_to = 0;
break;
case '3':
send_to_char(CH, "Enter artwork's room description: ");
d->edit_mode = ART_EDIT_ROOMDESC;
break;
case 'q':
case 'Q':
GET_OBJ_EXTRA(ART).SetBit(ITEM_EXTRA_KEPT);
obj_to_char(ART, CH);
mudlog_vfprintf(CH, LOG_GRIDLOG, "%s created an artwork named '%s'.", GET_CHAR_NAME(CH), GET_OBJ_NAME(ART));
log_vfprintf("Art desc: '''%s'''\r\nArt room desc: '''%s'''", ART->photo ? ART->photo : "<default>", ART->graffiti ? ART->graffiti : "<default>");
ART = NULL;
STATE(d) = CON_PLAYING;
send_to_char(CH, "Saving artwork.\r\n");
break;
}
break;
case ART_EDIT_NAME:
case ART_EDIT_ROOMDESC:
int length_with_no_color = get_string_length_after_color_code_removal(arg, CH);

// Silent failure: We already sent the error message in get_string_length_after_color_code_removal().
if (length_with_no_color == -1) {
create_art_main_menu(d);
return;
}
if (length_with_no_color >= LINE_LENGTH) {
send_to_char(CH, "That string is too long, please shorten it. The maximum length after color code removal is %d characters.\r\n", LINE_LENGTH - 1);
create_art_main_menu(d);
return;
}

if (strlen(arg) >= MAX_RESTRING_LENGTH) {
send_to_char(CH, "That string is too long, please shorten it. The maximum length with color codes included is %d characters.\r\n", MAX_RESTRING_LENGTH - 1);
create_art_main_menu(d);
return;
}

if (d->edit_mode == ART_EDIT_NAME) {
DELETE_ARRAY_IF_EXTANT(ART->restring);
ART->restring = str_dup(arg);
} else {
DELETE_ARRAY_IF_EXTANT(ART->graffiti);
ART->graffiti = str_dup(arg);
}

create_art_main_menu(d);
break;
}
}

#undef ART

void create_art(struct char_data *ch) {
struct obj_data *art = read_object(OBJ_CUSTOM_ART, VIRTUAL);
GET_ART_AUTHOR_IDNUM(art) = GET_IDNUM_EVEN_IF_PROJECTING(ch);

ch->desc->edit_obj = art;
create_art_main_menu(ch->desc);
}
12 changes: 12 additions & 0 deletions src/creative_works.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef __CREATIVE_WORKS_H
#define __CREATIVE_WORKS_H

#define ART_EDIT_MAIN 0
#define ART_EDIT_NAME 1
#define ART_EDIT_DESC 2
#define ART_EDIT_ROOMDESC 3

void art_edit_parse(struct descriptor_data *d, const char *arg);
void create_art_main_menu(struct descriptor_data *d);

#endif
4 changes: 4 additions & 0 deletions src/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "archetypes.hpp"
#include "ignore_system.hpp"
#include "newhouse.hpp"
#include "creative_works.hpp"

#if defined(__CYGWIN__)
#include <crypt.h>
Expand Down Expand Up @@ -2611,6 +2612,9 @@ void nanny(struct descriptor_data * d, char *arg)
case CON_DECK_CREATE:
dbuild_parse(d, arg);
break;
case CON_ART_CREATE:
art_edit_parse(d, arg);
break;
case CON_FCUSTOMIZE:
case CON_BCUSTOMIZE:
case CON_PCUSTOMIZE:
Expand Down
4 changes: 4 additions & 0 deletions src/modify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "helpedit.hpp"
#include "config.hpp"
#include "newhouse.hpp"
#include "creative_works.hpp"

#define DO_FORMAT_INDENT 1
#define DONT_FORMAT_INDENT 0
Expand Down Expand Up @@ -258,6 +259,9 @@ void string_add(struct descriptor_data *d, char *str)
if (STATE(d) == CON_DECK_CREATE && d->edit_mode == 1) {
REPLACE_STRING(d->edit_obj->photo);
deckbuild_main_menu(d);
} else if (STATE(d) == CON_ART_CREATE && d->edit_mode == ART_EDIT_DESC) {
REPLACE_STRING(d->edit_obj->photo);
create_art_main_menu(d);
} else if (STATE(d) == CON_VEHCUST) {
REPLACE_STRING(d->edit_veh->restring_long);
vehcust_menu(d);
Expand Down
7 changes: 6 additions & 1 deletion src/newmatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern void create_part(struct char_data *ch);
extern void create_deck(struct char_data *ch);
extern void create_spell(struct char_data *ch);
extern void create_ammo(struct char_data *ch);
extern void create_art(struct char_data *ch);

ACMD_DECLARE(do_look);

Expand Down Expand Up @@ -3688,8 +3689,12 @@ ACMD(do_create)
create_spell(ch);
}

else if (is_abbrev(buf1, "art") || is_abbrev(buf1, "book") || is_abbrev(buf1, "note") || is_abbrev(buf1, "business card") || is_abbrev(buf1, "card") || is_abbrev(buf1, "painting") || is_abbrev(buf1, "drawing")) {
create_art(ch);
}

else {
send_to_char("You can only create programs, parts, decks, ammunition, and spells.\r\n", ch);
send_to_char("You can only create programs, parts, decks, ammunition, spells, and art.\r\n", ch);
return;
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,13 @@ bool WEAPON_FOCUS_USABLE_BY(struct obj_data *focus, struct char_data *ch);
#define OBJ_IS_GRAFFITI(obj) (GET_OBJ_TYPE((obj)) == ITEM_GRAFFITI || GET_OBJ_VNUM((obj)) == OBJ_DYNAMIC_GRAFFITI)
#define GET_GRAFFITI_SPRAYED_BY(obj) (GET_OBJ_VAL((obj), 0))

// ITEM_DESTROYABLE convenience defines

// ITEM_LOADED_DECORATION convenience defines

// ITEM_CREATIVE_EFFORT convenience defines
#define GET_ART_AUTHOR_IDNUM(obj) (GET_OBJ_VAL((obj), 0))


/* Misc utils ************************************************************/
#define CHECK_FUNC_AND_SFUNC_FOR(npc, function) (mob_index[GET_MOB_RNUM(npc)].func == (function) || mob_index[GET_MOB_RNUM(npc)].sfunc == (function))
Expand Down

0 comments on commit a86bb7d

Please sign in to comment.