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


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Combat System

Combat System

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Harsk   USA  (47 posts)  [Biography] bio
Date Sat 15 Dec 2001 11:02 AM (UTC)
Message
I was wondering where if fight.c the combat system is handled. What I want to do is change they way combat is handled, so that lowlevel characters don't get stuck inside rooms with a high level aggro mob and end up killed. I've looked through it, but can't really make heads or tails of it (that, or I'm just tired). Any help would be greatly appreciated.

Also, I would like to know if it would be possible to code in ranged attacks. IE: your in a room north of the room that a mob is in. You want to fire a ranged weapon south into that room to attack said mob. Also, you want it so that when that character that made the ranged attack enters the room soon after finds themselves in close quarters combat with the attacked mob. If anyone knows how to do this, please let me know. Or, if anyone knows of a snippet that will do this, again, let me know. Thanks.
[Go to top] top

Posted by Kris   USA  (198 posts)  [Biography] bio
Date Reply #1 on Sat 15 Dec 2001 09:58 PM (UTC)
Message
First-off, the aggressive flag is crap in my opinion. The best way to achieve something like this is to not use that flag altogether. Instead, use a mobprog that does the same thing. In that mobprog, just have it perform an ifcheck based on the victim player's level. If you really insist on doing this with that antiquated flag, find the part of the source code in which a mob with that flag initiates combat with the player (I couldn't find it myself; but then again, I didn't look very hard either). When you find that code, put the comat initiation within an ifcheck that goes something like: if ( victim->level > (ch->level - 15) )

You would need to modify that ifcheck depending on the context of the code in which you end up placing that. For example, it may be vch instead of victim. ch->level in this case would be the mob's level. The ifcheck basically states that if the victim's level is greater than 15 levels less than the mob's level (i.e. the mob is less than 15 levels higher than the player), then go ahead and do the aggr initiate combat thing. But I would really suggest just using mobprogs for that stuff, since they're much more customizeable for each situation.

As for casting a spell from one room to another, yah that's very possible. The details of the spell and what-not will have to be worked-out by you of course, but here's the general concept of doing something from one room into the next (like casting a fireball to the room south or whatever). Notice in act_info.c, the do_look function. You know that you can 'look east', 'look south', etc, so naturally something to that effect would be in do_look. Here's the ifcheck I found on line 1229 (it'll be on a different line for you, as I've modified act_info.c so much):
door = get_door(arg1);
if ( (pexit=find_door(ch, arg1, TRUE)) != NULL )

This ifcheck uses get_door to determine if arg1 (what you type after 'look') points to a valid exit for that room. Find that code, so you can look at the details. It then goes on for a bit checking if the door is closed, the room has the private flag set, etc. After all that, you get to the part that really counts:

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 );

This code temporarily moves the player to the target room (similar to the immortal 'at' command). The do_look( ch, "auto" ); makes the player actually in that room. You would replace that with the code to cast the spell. The last 2 lines move the player back into his original room. Now, of course, you can put in some other stuff to give the illusion that the player is actually standing there, casting a ball of flame south, or whatever, instead of the player just appearing in the room and casting the spell.

I hope that helps :)

--Kris

P.S. If that is helpful to you, please feel free to visit my mud's website at www.aethia.org (I hope Nick doesn't mind me putting that there).
[Go to top] top

Posted by Harsk   USA  (47 posts)  [Biography] bio
Date Reply #2 on Mon 17 Dec 2001 12:04 AM (UTC)
Message
OK, that helped with getting it set up so that players can fire missile weapons and spells into another room. However, in some cases you will want aggressive mobs. I should have been a little clearer on what I was asking, so here it is.

Player A starts combat with mob A, player A then decides to leave the room. While the flee command is usefull, it often poses serious risks to the player. So instead of useing flee or recall, the player can then just leave the room from where they came from just by typeing in that direction. Hence, the character does not loose any experience after leaving the room, and can reenter the room to continue the fight. I allready have it set up so that the mob will recognize its attacker, and renew the fight.
[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.


13,007 views.

It is now over 60 days since the last post. This thread is closed.     [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.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

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

[Best viewed with any browser - 2K]    [Hosted at HostDash]