Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
Bug in get_exp_worth( )
Oct 10, 2017, 1:26 am
By GatewaySysop
Bug in do_drag( )
Oct 8, 2017, 12:40 am
By GatewaySysop
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Beastmaster 6D sound files
Author: Vladaar
Submitted by: Vladaar
Users Online
CommonCrawl

Members: 0
Guests: 11
Stats
Files
Topics
Posts
Members
Newest Member
476
3,704
19,231
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SWFOTE FUSS » External ship descriptions:
Forum Rules | Mark all | Recent Posts

External ship descriptions:
< Newer Topic :: Older Topic > Why can't I paint my ISD neon blue?

Pages:<< prev 1 next >>
Post is unread #1 Jan 25, 2010, 6:48 pm
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

So, digging about for useless datatypes/structures/anything else I found ship->description was just waiting to be used.

So, I've added some support for reading and writing it out to the prototype file and the actual player ship file. On to the next part I've just set a small description to one of my ships just as a proof of concept to see if it works, if you can look at said ship and see its description:

in act_info.c
    if((ship = ship_in_room(ch->in_room, arg1)) != NULL) //Checks to see if your in the same room as the ship
    {
        send_to_char(ship->description, ch);
        return;
        }

The above seems to work with out causing any problems. So I wanted to expand this to space, so I tried this:

    if ( ( ship = ship_from_cockpit(ch->in_room->vnum)) && (ship->starsystem) && ( ( target = get_ship_here(arg1, target->starsystem ) ) != NULL ) )
    {
            if ( IS_SET(target->flags, SHIP_CLOAK) )
                send_to_char(target->description, ch);
        return;
    }


So, since I suck at C what I tried to check against is: Are we in a ship; with a window and in space? Also, is our target in space with us if so, can we see said target, and if so give me the description baby!
Now sometimes that works sometimes it doesn't. My problem is getting do_look to work with the target statement (I think).

What happens is if I go to a ship's cockpit and type 'look self' self is getting passed to target and then get_ship_here which equals epic failure as it can't access the memory address. The same goes for 'look jack' if I have a PC named Jack.

Any ideas as to what or where I'm going wrong? I know I am missing something somewhere so I turn to you guys for help!

Below is the chunk-o-code of the original do_look. Where I'm inserting my new functions is right after the last for loop. (Line 488 in this chunk)

Thanks,
ayuri
void do_look( CHAR_DATA *ch, char *argument )
{
	char arg  [MAX_INPUT_LENGTH];
	char arg1 [MAX_INPUT_LENGTH];
	char arg2 [MAX_INPUT_LENGTH];
	char arg3 [MAX_INPUT_LENGTH];
	EXIT_DATA *pexit;
	CHAR_DATA *victim;
	OBJ_DATA *obj;
	ROOM_INDEX_DATA *original;
	char *pdesc;
	bool doexaprog; 
	sh_int door;
	int number, cnt;

	if ( !ch->desc )
		return;

	if ( ch->position < POS_SLEEPING )
	{
		send_to_char( "You can't see anything but stars!\n\r", ch );
		return;
	}

	if ( ch->position == POS_SLEEPING )
	{
		send_to_char( "You can't see anything, you're sleeping!\n\r", ch );
		return;
	}

	if ( !check_blind( ch ) )
		return;

	if ( !IS_NPC(ch)
			&&   !IS_SET(ch->act, PLR_HOLYLIGHT)
			&&   !IS_AFFECTED(ch, AFF_TRUESIGHT)
			&&   !IS_AFFECTED(ch, AFF_INFRARED)
			&&   room_is_dark( ch->in_room ) )
	{
		set_char_color( AT_DGREY, ch );
		send_to_char( "It is pitch black ... \n\r", ch );
		show_char_to_char( ch->in_room->first_person, ch );
		return;
	}

	argument = one_argument( argument, arg1 );
	argument = one_argument( argument, arg2 );
	argument = one_argument( argument, arg3 );

	doexaprog = str_cmp( "noprog", arg2 ) && str_cmp( "noprog", arg3 );

	if ( arg1[0] == '\0' || !str_cmp( arg1, "auto" ) )
	{
		SHIP_DATA * ship;

		/* 'look' or 'look auto' */
		set_char_color( AT_RMNAME, ch);
		ch_printf(ch, "&R-=&r( &G&W%s%s &G&r)&R=-&C&w ", color_str( AT_RMNAME, ch), ch->in_room->name);
		//send_to_char( ch->in_room->name, ch);
		//send_to_char(" ", ch);

		if ( !ch->desc->original )
		{
			if ((get_trust(ch) >= LEVEL_IMMORTAL) && (IS_SET(ch->pcdata->flags, PCFLAG_ROOM)))
			{
				if( get_trust( ch ) >= LEVEL_IMMORTAL )
				{
					if( IS_SET( ch->act, PLR_ROOMVNUM ) )
					{
						set_char_color( AT_BLUE, ch );   /* Added 10/17 by Kuran of */
						send_to_char( "{", ch );   /* SWReality */
						ch_printf( ch, "&G&W%s%d", color_str(AT_RVNUM, ch), ch->in_room->vnum );
						set_char_color( AT_BLUE, ch );   /* Added 10/17 by Kuran of */
						send_to_char( "}", ch );
					}
					if( IS_SET( ch->pcdata->flags, PCFLAG_ROOM ) )
					{
						set_char_color( AT_CYAN, ch );
						send_to_char( "[", ch );
						send_to_char( " ", ch );
						set_char_color( AT_RFLAGS1, ch );
						send_to_char( flag_string( ch->in_room->room_flags, r_flags ), ch );
						send_to_char( " ", ch );
						if( ch->in_room->room_flags2 != 0 )
						{
							set_char_color( AT_RFLAGS2, ch );
							send_to_char( flag_string( ch->in_room->room_flags2, r_flags2 ), ch );
							send_to_char( " ", ch );
						}
						set_char_color( AT_CYAN, ch );
						send_to_char( "]", ch );
					}
				}
			}
		}

		send_to_char( "\n\r", ch );
		set_char_color( AT_RMDESC, ch ); 	

		if ( arg1[0] == '\0'
				|| ( !IS_NPC(ch) && !IS_SET(ch->act, PLR_BRIEF) ) )
			send_to_char( ch->in_room->description, ch );


		if( !IS_NPC(ch) && IS_SET(ch->act, PLR_AUTOEXIT) )
		{
			if ( IS_SET(ch->pcdata->flags, PCFLAG_MAP))
				do_newexits(ch, "" );
			else
				do_exits(ch, "" );
		}


		show_ships_to_char( ch->in_room->first_ship, ch );
		show_list_to_char( ch->in_room->first_content, ch, FALSE, FALSE );
		show_char_to_char( ch->in_room->first_person, ch );

		if ( str_cmp( arg1, "auto" ) )
			if (   (ship = ship_from_cockpit(ch->in_room->vnum))  != NULL )
			{
				set_char_color(  AT_WHITE, ch );
				ch_printf( ch , "\n\rThrough the transparisteel windows you see:\n\r" );

				if (ship->starsystem)
				{
					MISSILE_DATA *missile;
					SHIP_DATA *target;
					PLANET_DATA *planet;

					set_char_color(  AT_GREEN, ch );
					if ( ship->starsystem->star1 && str_cmp(ship->starsystem->star1,"";) ) 
						ch_printf(ch, "&YThe star, %s.\n\r" , 
								ship->starsystem->star1);
					if ( ship->starsystem->star2 && str_cmp(ship->starsystem->star2,"";)  ) 
						ch_printf(ch, "&YThe star, %s.\n\r" , 
								ship->starsystem->star2 );
					for( planet = ship->starsystem->first_planet; planet; planet = planet->next_in_system ) 
						if(planet->controls == 0)
							ch_printf(ch, "&GThe planet, %s.\n\r" , planet->name );
						else
							ch_printf(ch, "&OAsteroid designation %s.\n\r", planet->name);
					for ( target = ship->starsystem->first_ship; target; target = target->next_in_starsystem )
					{       
						if ( target != ship && !IS_SET(target->flags, SHIP_CLOAK)) 
						{
							if(ship->class != 11)
								ch_printf(ch, "&C%s\n\r", 
										target->name);
							else
								ch_printf(ch, "&O%s\n\r", target->name); }
					}
					for ( missile = ship->starsystem->first_missile; missile; missile = missile->next_in_starsystem )
					{        
						ch_printf(ch, "&R%s\n\r", 
								missile->missiletype == CONCUSSION_MISSILE ? "A Concusion Missile" : 
								( missile->missiletype ==  PROTON_TORPEDO ? "A Torpedo" : 
								  ( missile->missiletype ==  HEAVY_ROCKET ? "A Heavy Rocket" : "A Heavy Bomb" ) ) );
					}

				}
				else if ( ship->location == ship->lastdoc )
				{
					ROOM_INDEX_DATA *to_room;
					to_room = ship->in_room;
					if (to_room) //get_room_index( ship->location ) ) != NULL )
					{
						ch_printf( ch, "\n\r" );
						original = ch->in_room;
						char_from_room( ch );
						char_to_room( ch, to_room );
						do_glance( ch, "" );	
						char_from_room( ch );
						char_to_room( ch, original );
					}    
				}


			}

		return;
	}

	if ( !str_cmp( arg1, "under" ) )
	{
		int count;

		/* 'look under' */
		if ( arg2[0] == '\0' )
		{
			send_to_char( "Look beneath what?\n\r", ch );
			return;
		}

		if ( ( obj = get_obj_here( ch, arg2 ) ) == NULL )
		{
			send_to_char( "You do not see that here.\n\r", ch );
			return;
		}
		if ( ch->carry_weight + obj->weight > can_carry_w( ch ) )
		{
			send_to_char( "It's too heavy for you to look under.\n\r", ch );
			return;
		}
		count = obj->count;
		obj->count = 1;
		act( AT_PLAIN, "You lift $p and look beneath it:", ch, obj, NULL, TO_CHAR );
		act( AT_PLAIN, "$n lifts $p and looks beneath it:", ch, obj, NULL, TO_ROOM );
		obj->count = count;
		if ( IS_OBJ_STAT( obj, ITEM_COVERING ) )
			show_list_to_char( obj->first_content, ch, TRUE, TRUE );
		else
			send_to_char( "Nothing.\n\r", ch );
		if ( doexaprog ) oprog_examine_trigger( ch, obj );
		return;
	}

	if ( !str_cmp( arg1, "i" ) || !str_cmp( arg1, "in" ) )
	{
		int count;

		/* 'look in' */
		if ( arg2[0] == '\0' )
		{
			send_to_char( "Look in what?\n\r", ch );
			return;
		}

		if ( ( obj = get_obj_here( ch, arg2 ) ) == NULL )
		{
			send_to_char( "You do not see that here.\n\r", ch );
			return;
		}

		switch ( obj->item_type )
		{
			default:
				send_to_char( "That is not a container.\n\r", ch );
				break;

			case ITEM_DRINK_CON:
				if ( obj->value[1] <= 0 )
				{
					send_to_char( "It is empty.\n\r", ch );
					if ( doexaprog ) oprog_examine_trigger( ch, obj );
					break;
				}

				ch_printf( ch, "It's %s full of a %s liquid.\n\r",
						obj->value[1] <     obj->value[0] / 4
						? "less than" :
						obj->value[1] < 3 * obj->value[0] / 4
						? "about"     : "more than",
						liq_table[obj->value[2]].liq_color
						);

				if ( doexaprog ) oprog_examine_trigger( ch, obj );
				break;

			case ITEM_PORTAL:
				for ( pexit = ch->in_room->first_exit; pexit; pexit = pexit->next )
				{
					if ( pexit->vdir == DIR_PORTAL
							&&   IS_SET(pexit->exit_info, EX_PORTAL) )
					{
						if ( room_is_private( ch, pexit->to_room )
								&&   get_trust(ch) < sysdata.level_override_private )
						{
							set_char_color( AT_WHITE, ch );
							send_to_char( "That room is private buster!\n\r", ch );
							return;
						}
						original = ch->in_room;
						char_from_room( ch );
						char_to_room( ch, pexit->to_room );
						do_look( ch, "auto" );
						char_from_room( ch );
						char_to_room( ch, original );
						return;
					}
				}
				send_to_char( "You see a swirling chaos...\n\r", ch );
				break;
			case ITEM_CONTAINER:
			case ITEM_CORPSE_NPC:
			case ITEM_CORPSE_PC:
			case ITEM_DROID_CORPSE:
				if ( IS_SET(obj->value[1], CONT_CLOSED) )
				{
					send_to_char( "It is closed.\n\r", ch );
					break;
				}

				count = obj->count;
				obj->count = 1;
				act( AT_PLAIN, "$p contains:", ch, obj, NULL, TO_CHAR );
				obj->count = count;
				show_list_to_char( obj->first_content, ch, TRUE, TRUE );
				if ( doexaprog ) oprog_examine_trigger( ch, obj );
				break;
		}
		return;
	}

	if ( (pdesc=get_extra_descr(arg1, ch->in_room->first_extradesc)) != NULL )
	{
		send_to_char( pdesc, ch );
		return;
	}

	door = get_door( arg1 );
	if ( ( pexit = find_door( ch, arg1, TRUE ) ) != NULL )
	{
		if ( pexit->keyword )
		{
			if ( IS_SET(pexit->exit_info, EX_CLOSED)
					&&  !IS_SET(pexit->exit_info, EX_WINDOW) )
			{
				if ( IS_SET(pexit->exit_info, EX_SECRET)
						&&   door != -1 )
					send_to_char( "Nothing special there.\n\r", ch );
				else
					act( AT_PLAIN, "The $d is closed.", ch, NULL, pexit->keyword, TO_CHAR );
				return;
			}
			if ( IS_SET( pexit->exit_info, EX_BASHED ) )
				act(AT_RED, "The $d has been bashed from its hinges!",ch, NULL, pexit->keyword, TO_CHAR);
		}

		if ( pexit->description && pexit->description[0] != '\0' )
			send_to_char( pexit->description, ch );
		else
			send_to_char( "Nothing special there.\n\r", ch );

		/*
		 * Ability to look into the next room			-Thoric
		 */
		if ( pexit->to_room
				&& ( IS_AFFECTED( ch, AFF_SCRYING )
					||   IS_SET( pexit->exit_info, EX_xLOOK )
					||   get_trust(ch) >= LEVEL_IMMORTAL ) )
		{
			if ( !IS_SET( pexit->exit_info, EX_xLOOK )
					&&    get_trust( ch ) < LEVEL_IMMORTAL )
			{
				set_char_color( AT_MAGIC, ch );
				send_to_char( "You attempt to scry...\n\r", ch );
				/* Change by Narn, Sept 96 to allow characters who don't have the
				   scry spell to benefit from objects that are affected by scry.
				   */
				if (!IS_NPC(ch) )
				{
					int percent = ch->pcdata->learned[ skill_lookup("scry";) ];
					if ( !percent )
						percent = 99;

					if(  number_percent( ) > percent ) 
					{
						send_to_char( "You fail.\n\r", ch );
						return;
					}
				}
			}
			if ( room_is_private( ch, pexit->to_room )
					&&   get_trust(ch) < sysdata.level_override_private )
			{
				set_char_color( AT_WHITE, ch );
				send_to_char( "That room is private buster!\n\r", ch );
				return;
			}
			original = ch->in_room;
			if ( pexit->distance > 1 )
			{  
				ROOM_INDEX_DATA * to_room;
				if ( (to_room=generate_exit(ch->in_room, &pexit)) != NULL )
				{
					char_from_room( ch );
					char_to_room( ch, to_room );
				}
				else
				{
					char_from_room( ch );
					char_to_room( ch, pexit->to_room );
				}
			}
			else
			{
				char_from_room( ch );
				char_to_room( ch, pexit->to_room );
			}
			do_look( ch, "auto" );
			char_from_room( ch );
			char_to_room( ch, original );
		}
		return;
	}
	else
		if ( door != -1 )
		{
			send_to_char( "Nothing special there.\n\r", ch );
			return;
		}

	if ( ( victim = get_char_room( ch, arg1 ) ) != NULL )
	{
		show_char_to_char_1( victim, ch );
		return;
	}


	/* finally fixed the annoying look 2.obj desc bug	-Thoric */
	number = number_argument( arg1, arg );
	for ( cnt = 0, obj = ch->last_carrying; obj; obj = obj->prev_content )
	{
		if ( can_see_obj( ch, obj ) )
		{
			if ( (pdesc=get_extra_descr(arg, obj->first_extradesc)) != NULL )
			{
				if ( (cnt += obj->count) < number )
					continue;
				send_to_char( pdesc, ch );
				if ( doexaprog ) oprog_examine_trigger( ch, obj );
				return;
			}

			if ( (pdesc=get_extra_descr(arg, obj->pIndexData->first_extradesc)) != NULL )
			{
				if ( (cnt += obj->count) < number )
					continue;
				send_to_char( pdesc, ch );
				if ( doexaprog ) oprog_examine_trigger( ch, obj );
				return;
			}

			if ( nifty_is_name_prefix( arg, obj->name ) )
			{
				if ( (cnt += obj->count) < number )
					continue;
				pdesc = get_extra_descr( obj->name, obj->pIndexData->first_extradesc );
				if ( !pdesc )
					pdesc = get_extra_descr( obj->name, obj->first_extradesc );
				if ( !pdesc )
					send_to_char( "You see nothing special.\r\n", ch );
				else
					send_to_char( pdesc, ch );
				if ( doexaprog ) oprog_examine_trigger( ch, obj );
				return;
			}
		}
	}

	for ( obj = ch->in_room->last_content; obj; obj = obj->prev_content )
	{
		if ( can_see_obj( ch, obj ) )
		{
			if ( (pdesc=get_extra_descr(arg, obj->first_extradesc)) != NULL )
			{
				if ( (cnt += obj->count) < number )
					continue;
				send_to_char( pdesc, ch );
				if ( doexaprog ) oprog_examine_trigger( ch, obj );
				return;
			}

			if ( (pdesc=get_extra_descr(arg, obj->pIndexData->first_extradesc)) != NULL )
			{
				if ( (cnt += obj->count) < number )
					continue;
				send_to_char( pdesc, ch );
				if ( doexaprog ) oprog_examine_trigger( ch, obj );
				return;
			}
			if ( nifty_is_name_prefix( arg, obj->name ) )
			{
				if ( (cnt += obj->count) < number )
					continue;
				pdesc = get_extra_descr( obj->name, obj->pIndexData->first_extradesc );
				if ( !pdesc )
					pdesc = get_extra_descr( obj->name, obj->first_extradesc );
				if ( !pdesc )
					send_to_char( "You see nothing special.\r\n", ch );
				else
					send_to_char( pdesc, ch );
				if ( doexaprog ) oprog_examine_trigger( ch, obj );
				return;
			}
		}
	}

	send_to_char( "You do not see that here.\n\r", ch );
	return;
}
       
Post is unread #2 Jan 26, 2010, 2:28 am   Last edited Jan 26, 2010, 2:41 am by Andril
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

You could try something like this for looking at a ships description from another ship, in space or not.
SHIP_DATA *ship = NULL, *tship = NULL;
if( ( ship = ship_from_cockpit( ch->in_room->vnum ) ) != NULL ) // make sure we're in a ship and can look out
   if( ( tship = get_ship( arg1 ) ) != NULL )                   // make sure we can find a ship with the right name
      if( ship->location == tship->location )                   // both ships are in the same location, same room or both in space
         if( ship->location == 0 && ship->starsystem == tship->starsystem ) // both ships are in space and in the same starsystem
         {
            send_to_char( tship->description, ch );
            return;
         }
         else if( ship->location != 0 ) // neither ship is in space but they are in the same location, which means same room
         {
            send_to_char( tship->description, ch );
            return;
         }

The best place to put this might be at the end before the "You don't see that here." message to ensure that everything else was checked first. Maybe not though. Also, I didn't bother to check for the ship being cloaked as it doesn't appear to actually be used anywhere within the code in any real way, at least not in space.c or 11.c. Just a deal to get what flags are set on the ship but no do_cloakship or anything like that.

For looking at a ship in the same room, just stick the first bit of code you posted above this bit at the end of do_look and, assuming I didn't totally screw something up, you should be good to go in regards to showing the correct ship description to the player.
       
Post is unread #3 Jan 26, 2010, 7:06 am
Go to the top of the page
Go to the bottom of the page

Keirath
Magician
GroupMembers
Posts144
JoinedJan 24, 2008

It would also be nice to hide your ship when you look out of a window (when the ship is landed)
       
Post is unread #4 Jan 26, 2010, 10:27 am
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

I do have a hackish cloak flag so that is why all that is in there. As to hiding your ship to yourself when your in your ship and landed - yeah. That has to be an oversight cause when your in space and you look - you don't see your ship. Just never really though about it that one much. I think that one would be classified as a minor bug. Not going to cause a crash but annoying none the less.

The above seems to work pretty well. I had to add in an extra set of braces starting with the 2nd if statement due to compiler warning but other than that, looks good.

Thanks Keirath,
ayuri
       
Post is unread #5 Jan 27, 2010, 3:37 pm
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

Ok, so ship descriptions are working somewhat now.

The new thing I'm running into when the ship's are given a description in the proto file its all one line that looks very nasty to the neatness of having everything formatted.

So, I thought I could use strlinwrp to make them all nice and neat. However, since I mostly code by example, and I've only seen two examples of strlinwrp in two spots - it don't offer much help.
I thought I could get away with something like:
strcpy(newexerndesc,strlinwrp(ship->description,60));
ship->description = STRALLOC( newexterndesc );


However it is clear that I'm pretty clueless.

Anyone have any ideas?
ayuri
       
Post is unread #6 Jan 27, 2010, 3:56 pm   Last edited Jan 27, 2010, 4:05 pm by ayuri
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

Hmm....
Seems I'm looking in the wrong place.

I was looking at the top of SHIP_DATA *make_prototype_ship()
and at ship->description = STRALLOC( "" );
Completely blowing off ship->description = ship_prototypes[ship_type].description; down near the bottom.

Time to play!

**EDIT:
So, another useless bit of code (as far as I can tell) is that ship->description = STRALLOC( "" ); near the top of SHIP_DATA *make_prototype_ship() in ships.c

I was able to get what I wanted by doing:
ship->description = strlinwrp(ship_prototypes[ship_type].description,60);


WOO!
ayuri
       
Post is unread #7 Feb 4, 2010, 4:55 pm
Go to the top of the page
Go to the bottom of the page

ayuri
Magician
GroupMembers
Posts239
JoinedJun 13, 2008

I should point out at some point I'll document my steps but its just like adding the mod snippet to the game. Just make sure you put the structs in tech.c for tech skills or you'll run into crashes. Also, once you do the above with the ship->description = strlinwrp(ship_prototypes[ship_type].description,60); each prototype will need to have the Description ~ set. If you dont have it the game will crash as it has nothing to do the strlinwrp to.

ayuri
       
Pages:<< prev 1 next >>