[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Thrown Item Code?
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Thrown Item Code?

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page


Pages: 1 2  

Posted by Gatewaysysop2   USA  (142 posts)  [Biography] bio
Date Fri 06 May 2005 06:20 AM (UTC)  quote  ]
Message
Was curious if anyone happens to know of a decent implementation / snippet of thrown item code? As I understand it, the thrown item code in stock SMAUG isn't all there and was never finished so I'm looking for something to provide this functionality.

Basically looking for something that'll let you throw a weapon, either at a person or in a direction. Not sure if another codebase has a finished version of this or if there's a snippet, but if anyone's seen or heard of something useful in this regard, I'd very much appreciate a heads up.

Thanks!

"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #1 on Fri 06 May 2005 06:32 AM (UTC)  quote  ]
Message
This is one of my many TODO'S the code i have laying about somewhere is what i pulled out of a rom deriv, think it was Ghost MUD that i will eventually get around to porting over to Smaug.


Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
[Go to top] top

Posted by Txzeenath   USA  (54 posts)  [Biography] bio
Date Reply #2 on Fri 06 May 2005 10:57 AM (UTC)  quote  ]

Amended on Fri 06 May 2005 01:26 PM (UTC) by Txzeenath

Message
Think there's a snippet somewhere.. I'll go look if i've got it... I'm a snippet packrat of sorts :-p

--------EDIT---------
Found it, doing a "dirty" port, it's all kinds of messy so i'll try to fix it up a bit.

----------EDIT--------
Lol said forget it and i'm just rewriting it using existing functions, will still work all the same... just about 100 lines shorter and alot more simple.
*hugs smaug 1.4a and all of its incomplete mystery function greatness*

Darkness comes along thy path, searching, wanting, calling wrath,
shadows awaken, release the light, one and only.. here to fight,
challenge the darkness, the shadows they call, hunting the living,
more and all. Roaring thunder, full of hate, a single bound, seals
your fate.

-Txzeenath

telnet://divineright.org:8088
Alumuble Arda -
*Player owned shops, clans, and housing
*Multiclass & Stat training
*Random mob name generation implemented and Overland mapping.
*Realistic equipment statistics
*Interactive enviroment(weather/sectors)
*Weapon sheaths(scabbards), Throwing weapons
*Automatic crash recovery, saving, and reporting without disconnecting
*Fully customizeable color, Automapper, "Smart" mobiles, Hiscore tables, and more!

Currently running AGE v1.9.6(Originated and modified from Smaug 1.4a)
[Go to top] top

Posted by Txzeenath   USA  (54 posts)  [Biography] bio
Date Reply #3 on Fri 06 May 2005 01:36 PM (UTC)  quote  ]

Amended on Fri 06 May 2005 01:52 PM (UTC) by Txzeenath

Message
here it is, you will need to add in the item types to both mud.h and build.c, also act_obj.c will need to be modified for the do_put code(quiver is a good thing to copy from), just use search and it's obvious where to add them, you may also want to add a new weapontype(skill/gsn) for throwing:

http://www.alumuble.divineright.org/throw.c

Adding the new weapontype will require minimum work.. simply go into skills.c and find ranged_attack

Darkness comes along thy path, searching, wanting, calling wrath,
shadows awaken, release the light, one and only.. here to fight,
challenge the darkness, the shadows they call, hunting the living,
more and all. Roaring thunder, full of hate, a single bound, seals
your fate.

-Txzeenath

telnet://divineright.org:8088
Alumuble Arda -
*Player owned shops, clans, and housing
*Multiclass & Stat training
*Random mob name generation implemented and Overland mapping.
*Realistic equipment statistics
*Interactive enviroment(weather/sectors)
*Weapon sheaths(scabbards), Throwing weapons
*Automatic crash recovery, saving, and reporting without disconnecting
*Fully customizeable color, Automapper, "Smart" mobiles, Hiscore tables, and more!

Currently running AGE v1.9.6(Originated and modified from Smaug 1.4a)
[Go to top] top

Posted by Gatewaysysop2   USA  (142 posts)  [Biography] bio
Date Reply #4 on Fri 06 May 2005 05:39 PM (UTC)  quote  ]
Message
Will take a look, thanks for the help!

"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
[Go to top] top

Posted by Txzeenath   USA  (54 posts)  [Biography] bio
Date Reply #5 on Sat 07 May 2005 02:49 PM (UTC)  quote  ]

Amended on Sat 07 May 2005 05:44 PM (UTC) by Txzeenath

Message
Anyone else who needs this code will have to wait.. There was a problem with my server and my entire mud got wiped out.. luckily I had an off-site backup from about a month before.


I'll get this back up when my mud is nice and stable. I may even release some snippets on my site when I finish it.


----------EDIT--------
Code is back up, should be fine to use.

Darkness comes along thy path, searching, wanting, calling wrath,
shadows awaken, release the light, one and only.. here to fight,
challenge the darkness, the shadows they call, hunting the living,
more and all. Roaring thunder, full of hate, a single bound, seals
your fate.

-Txzeenath

telnet://divineright.org:8088
Alumuble Arda -
*Player owned shops, clans, and housing
*Multiclass & Stat training
*Random mob name generation implemented and Overland mapping.
*Realistic equipment statistics
*Interactive enviroment(weather/sectors)
*Weapon sheaths(scabbards), Throwing weapons
*Automatic crash recovery, saving, and reporting without disconnecting
*Fully customizeable color, Automapper, "Smart" mobiles, Hiscore tables, and more!

Currently running AGE v1.9.6(Originated and modified from Smaug 1.4a)
[Go to top] top

Posted by Longbow   (102 posts)  [Biography] bio
Date Reply #6 on Mon 09 Jan 2006 06:43 PM (UTC)  quote  ]
Message
Hmm, the link doesn't work for me. I could sure use that piece of code.
Godbless,
Longbow
[Go to top] top

Posted by Longbow   (102 posts)  [Biography] bio
Date Reply #7 on Wed 15 Feb 2006 05:29 PM (UTC)  quote  ]
Message
Does anybody have a copy of this code that I could have? Please :)


Godbless,
Longbow
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Reply #8 on Wed 15 Feb 2006 06:19 PM (UTC)  quote  ]
Message
Sounds pretty simple.
Just copy some code from the ranged_attack function if the arg's true for find_door, then check victim in room for the arg.

Then it's just an obj from char, make a forumla depending (presumably) on weight of the item and the strength of the thrower, and call the damage code, then obj_to_room(vict)...

Should take all of 10 minutes to code, don't see why you need a snippet :/

ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com

Drop by the area archives and find something for your mud. http://areaarchives.servegame.com
[Go to top] top

Posted by Longbow   (102 posts)  [Biography] bio
Date Reply #9 on Wed 15 Feb 2006 11:12 PM (UTC)  quote  ]
Message
Well, in all honesty, I don't know C worth beans. I'm in the process of learning, but I thought it'd be helpful to my MUD to get a throw code sooner than later. Not trying to be lazy; I just don't have the ability to do even a simple 10 minute operation in C yet. :)
[Go to top] top

Posted by Gatewaysysop2   USA  (142 posts)  [Biography] bio
Date Reply #10 on Thu 16 Feb 2006 (UTC)  quote  ]
Message
Quote:

Should take all of 10 minutes to code, don't see why you need a snippet :/


Sigh.

Is it really that difficult to grasp that what is easy for some people is not for others?

There's a reason people almost universally include examples when trying to teach others to code, in any language, and it is precisely because pseudo-explanations like yours are meaningless to those without an already good understanding of the subject matter.

IMHO, most of the people reading your post who don't "need a snippet" and can code this "in 10 minutes" would already have been able to do so without our terse explanation. To the rest of them, all they'll get out of it is feeling bad about their skill level, which accomplishes nothing.

For those interested, I may have a copy of the code that was posted here. I'll hunt around for it and post if I find it. In the mean time, I believe either SWR has thrown item code in it somewhere that you might look at.

"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Reply #11 on Thu 16 Feb 2006 02:49 AM (UTC)  quote  ]
Message
You are right in many ways, Gatewaysysop2, but people should always be aware that what they're trying to do is not at all easy and they shouldn't expect walk-in-the-park solutions. I strongly discourage anybody from doing anything hard until they can at least read lines of C code and understand (more or less, at the least) what the lines do.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Reply #12 on Thu 16 Feb 2006 07:30 AM (UTC)  quote  ]

Amended on Thu 16 Feb 2006 09:54 PM (UTC) by Dace K

Message
Jeez, what's up your ass, Gatewaysysop? I gave step by step instructions on what to do, which is far more than what I got when I was learning to code

My mistake apparently is assuming that anyone posting on a coding board knows basic coding already, so I just told him which functions to use.
Silly silly me.

Here's an example of what I was talking about. I just hacked this together in about 5 minutes, and haven't even tested if it'll compile. It's at least a nice start though, and it *should* work, unless I missed something stupid.

/*Silly little throw - Dace K*/
void do_throw( CHAR_DATA *ch, char *argument)
{
    CHAR_DATA *victim, *vch;
    EXIT_DATA *pexit;
    ROOM_INDEX_DATA *was_in_room;
    OBJ_DATA *obj;
    char arg1[MAX_INPUT_LENGTH];
    char arg2[MAX_INPUT_LENGTH];
    char temp[MAX_INPUT_LENGTH];
    char buf[MAX_STRING_LENGTH];
    sh_int dir = -1, dist = 0, color = AT_GREY;
    char *dtxt = "somewhere";
    char *stxt = "thrown item";

    argument = one_argument(argument, arg);
    argument = one_argument(argument, arg2);

    if ( arg1[0] == '\0' )
    {
	send_to_char( "Throw what where?  At who?\n\r", ch );
	return rNONE;
    }

    victim = NULL;

    if ( ms_find_obj(ch) )
	return;

	if ( ( obj = get_obj_carry( ch, arg1 ) ) == NULL )
	{
	    send_to_char( "You do not have that item.\n\r", ch );
	    return;
	}

	/*Insert checks for itemtypes you don't want throwable here*/

    /* get an exit or a victim */
    if ( (pexit = find_door(ch, arg2, TRUE)) == NULL )
    {
	if ( (victim=get_char_room(ch, arg2)) == NULL )
	{
	    send_to_char( "Throw in what direction?\n\r", ch );
	    return rNONE;
	}
	else
	{
/*	Uncomment if you don't want people throwing at fight-engaged*
		if ( who_fighting(ch) == victim )
	    {
		send_to_char( "They are too close to release that type of attack!\n\r", ch );
		return rNONE;
	    } */
	}
    }
    else
	dir = pexit->vdir;

    /* check for ranged attacks from private rooms, etc */
    if ( !victim )
    {
	if ( IS_SET(ch->in_room->room_flags, ROOM_PRIVATE)
	||   IS_SET(ch->in_room->room_flags, ROOM_SOLITARY) )
	{
	    send_to_char( "You cannot throw an object from a private room.\n\r", ch );
	    return rNONE;
	}
	if ( ch->in_room->tunnel > 0 )
	{
	    count = 0;
	    for ( vch = ch->in_room->first_person; vch; vch = vch->next_in_room )
		++count;
	    if ( count >= ch->in_room->tunnel )
	    {
		send_to_char( "This room is too cramped to perform such an attack.\n\r", ch );
		return rNONE;
	    }
	}
    }

    if ( pexit && !pexit->to_room )
    {
	send_to_char( "Are you expecting to throw through a wall!?\n\r", ch );
	return rNONE;
    }

    /* Check for obstruction */
    if ( pexit && IS_SET(pexit->exit_info, EX_CLOSED) )
    {
	if ( IS_SET(pexit->exit_info, EX_SECRET)
	||   IS_SET(pexit->exit_info, EX_DIG) )
	    send_to_char( "Are you expecting to throw through a wall!?\n\r", ch );
	else
	    send_to_char( "Are you expecting to throw through a door!?\n\r", ch );
	return rNONE;
    }

    vch = NULL;
    if ( pexit && arg1[0] != '\0' )
    {
	if ( (vch=scan_for_victim(ch, pexit, arg1)) == NULL )
	{
	    send_to_char( "You cannot see your target.\n\r", ch );
	    return rNONE;
	}

	/* don't allow attacks on mobs stuck in another area?
	if ( IS_NPC(vch) && xIS_SET(vch->act, ACT_STAY_AREA)
	&&   ch->in_room->area != vch->in_room->area) )
	{
	}
	*/
	/*don't allow attacks on mobs that are in a no-missile room --Shaddai */
	if ( IS_SET(vch->in_room->room_flags, ROOM_NOMISSILE) )
	{
	    send_to_char( "You can't get a clean shot off.\n\r", ch );
	    return rNONE;
	}
	/* Taken out cause of wait state
	if ( !IS_NPC(ch) && !IS_NPC(vch) )
	{
	    send_to_char("Pkill like a real pkiller.\n\r", ch );
	    return rNONE;
	}
	*/

	/* can't properly target someone heavily in battle */
	if ( vch->num_fighting > max_fight(vch) )
	{
	    send_to_char( "There is too much activity there for you to get a clear shot.\n\r", ch );
	    return rNONE;
	}
    }
    if ( vch ) {
    if ( !IS_NPC( vch ) && !IS_NPC( ch ) &&
	 xIS_SET(ch->act, PLR_NICE ) )
    {
	send_to_char( "Your too nice to do that!\n\r", ch );
	return rNONE;
    }
    if ( vch && is_safe(ch, vch, TRUE) )
	    return rNONE;
    }
    was_in_room = ch->in_room;

	separate_obj(obj);

	if ( pexit )
	{
		act( AT_GREY, "You throw $p $T.", ch, obj, dir_name[dir], TO_CHAR );
		act( AT_GREY, "$n throw $p $T.", ch, obj, dir_name[dir], TO_ROOM );
	}
	else
	{
		act( AT_GREY, "You throw $p at $N.", ch, obj, victim, TO_CHAR );
		act( AT_GREY, "$n throws $p at $N.", ch, obj, victim, TO_NOTVICT );
		act( AT_GREY, "$n throws $p at you!", ch, obj, victim, TO_VICT );
	}
    }


    /* victim in same room */
    if ( victim )
    {
    	check_illegal_pk( ch, victim );
	check_attacker( ch, victim );
	ranged_got_target( ch, victim, NULL, obj,
		0, TYPE_HIT, stxt, color );
    }

    /* assign scanned victim */
    victim = vch;

    /* reverse direction text from move_char */
    dtxt = rev_exit(pexit->vdir);

    while ( dist <= range )
    {
	char_from_room(ch);
	char_to_room(ch, pexit->to_room);

	if ( IS_SET(pexit->exit_info, EX_CLOSED) )
	{
	    /* whadoyahknow, the door's closed */
		sprintf(buf, "You see your %s hit a door in the distance to the %s.",
		    short_descr, dir_name[dir] );
	    act( color, buf, ch, NULL, NULL, TO_CHAR );
		sprintf(buf, "%s flies in from %s and smashes into the %sern door.",
		   obj->short_descr, dtxt, dir_name[dir] );
		buf[0] = UPPER(buf[0]);
		act( color, buf, ch, NULL, NULL, TO_ROOM );
	    break;
	}


ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com

Drop by the area archives and find something for your mud. http://areaarchives.servegame.com
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Reply #13 on Thu 16 Feb 2006 07:31 AM (UTC)  quote  ]
Message



	/* no victim? pick a random one */
	if ( !victim )
	{
	    for ( vch = ch->in_room->first_person; vch; vch = vch->next_in_room )
	    {
		if ( ((IS_NPC(ch) && !IS_NPC(vch))
		||   (!IS_NPC(ch) &&  IS_NPC(vch)))
		&&    number_bits(1) == 0 )
		{
		    victim = vch;
		    break;
		}
	    }
	    if ( victim && is_safe(ch, victim, TRUE) )
	    {
	        char_from_room(ch);
	        char_to_room(ch, was_in_room);
		return;
	    }
	}

	/* In the same room as our victim? */
	if ( victim && ch->in_room == victim->in_room )
	{

		act( color, "$p flies in from $T.", ch, obj, dtxt, TO_ROOM );

	    /* get back before the action starts */
	    char_from_room(ch);
	    char_to_room(ch, was_in_room);

	    check_illegal_pk( ch, victim );
	    check_attacker( ch, victim );
	    return ranged_got_target( ch, victim, NULL, obj,
					dist, TYPE_HIT, stxt, color );

 	}

	if ( dist == range )
	{
	    if ( obj )
	    {
		act( color, "Your $t falls harmlessly to the ground to the $T.",
		    ch, myobj(obj), dir_name[dir], TO_CHAR );
		act( color, "$p flies in from $T and falls harmlessly to the ground here.",
		    ch, obj, dtxt, TO_ROOM );
		    obj_from_char(obj);
		obj_to_room(obj, ch->in_room, ch);
	    }
	    break;
	}

	if ( ( pexit = get_exit( ch->in_room, dir ) ) == NULL )
	{
	    if ( obj )
	    {
		act( color, "Your $p hits a wall and bounces harmlessly to the ground to the $T.",
		    ch, myobj(obj), dir_name[dir], TO_CHAR );
		act( color, "$p strikes the $Tsern wall and falls harmlessly to the ground.",
		    ch, obj, dir_name[dir], TO_ROOM );
		    obj_from_char(obj);
		obj_to_room(obj, ch->in_room, ch);
	    }
	    break;
	}
	    act( color, "$p flies in from $T.", ch, obj, dtxt, TO_ROOM );
	dist++;
    }

    char_from_room( ch );
    char_to_room( ch, was_in_room );

    return rNONE;
}


I'm just tired of people asking for snippets all the time. I used to release snippets, only to find people coming onto my mud and telling me my code was stock because they found it on a snippet site. Bleh.

ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com

Drop by the area archives and find something for your mud. http://areaarchives.servegame.com
[Go to top] top

Posted by Longbow   (102 posts)  [Biography] bio
Date Reply #14 on Fri 17 Feb 2006 12:09 AM (UTC)  quote  ]
Message
Hey Dace K, first of all, let me thank you for helping me out. I realize it'd probably get annoying with people always asking for snippets; hence, I try to keep my requests to a minimum.
I wish I knew C so I could save you the bother, but since I don't, I figure that the best way to get the more advanced things done while I'm learning the basics is to ask. :) And if nothing else, it helps me a bit to see the completed code so I can try to figure out WHY it works. I'm an inquistive fellow, you know. ;)


Godbless,
Longbow
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


10,205 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]