[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]  Adding fighting combo's
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Adding fighting combo's

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


Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Mon 29 Dec 2003 09:02 AM (UTC)  quote  ]

Amended on Mon 29 Dec 2003 09:08 AM (UTC) by Robert Powell

Message
I havent done any coding since the days of the pascal bbs games of what seems an eon ago, and C is very forien to me, with my skills ending not long after i have added a snippit or added the decleration to a new spell or skill in all the right places, tho with some reading and a little thinking i can usualy make out whats going on, but not nessasarily how to do it, now to my delema.

Im wanting to incorperate into a fairly stock smaug 1.4a windows version what resembles the Monk combo's. Now i could make them using spell_smaug and have a skill called jab_jab_jab that says "Your Jab Jab Jab does X Damage", but what i would rather see is the 3 attacks seperate in the one round -:

Your Jab does X Damage
Your Jab does X Damage
Your Jab does X Damage

Is it posible to make use of the skills in the skills table and call them to be used from the new skill being written. The jab skill uses spell_smaug.

Sort of like -:

void do_jab_jab_jab ()
{
execute jab skill
execute jab skill
execute jab skill
}

now i know there probably parameters that have to be passed back and forth etc. I know im way out of my depth here, but i would like to try if anyone would like ot offer some guidence.

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 David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Reply #1 on Mon 29 Dec 2003 11:35 AM (UTC)  quote  ]
Message
I don't know if stock SMAUG handles this the same way my MUD does - it's a derivative from way-long-ago SMAUG 1.0 - but you could try looking at the multi_hit function. That's the function that (in my version at least) determines the number of hits in your round, depending on how many attacks you succeed. In the function, it basically rolls for the first attack; if it succeeds, try a second attack (if the player can of course), if that succeeds, try a third attack, etc.

That could give you an idea, otherwise your idea of just executing the skill three times would work as well. You might want a way to check if the previous skill succeeded before launching a new one, depending on how you want your skill to work. The quick and dirty way to do that is to have a global variable set in the sub-skill function, that do_jab_jab_jab looks at. (VERY dirty, but it works... :P)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #2 on Tue 30 Dec 2003 05:17 AM (UTC)  quote  ]

Amended on Tue 30 Dec 2003 05:27 AM (UTC) by Robert Powell

Message
Ok i have had a change of plan slightly with how i would like to to work, now have 1 skill called combo that containes all the possible combinations, with the combo skill being allocated to a player after thay have received the last of the combinable skills.

As i have previously stated i dont know anything about coding in C but what i have done below has come about from reading the code for do_kick\punch and a healer snippit i have here, so please dont flame me to bad, but i do beleive in having a go at it befor i put my hands up and beg for help.

Now i havent tryed to compile this bunch of rubbish as i know there are lots of things missing well i dont realy know im just guessing, so if someone could help me with the mess in the jab jab jab if statment then i think i could complete the rest.

 
void do_combo(char *argument)
{
char arg[MAX_INPUT_LENGTH];
int sn1,sn2,sn3;
DO_FUN *attack1
DO_FUN *attack2
DO_FUN *attack3

	if ( IS_NPC(ch) && IS_AFFECTED( ch, AFF_CHARM ) )
    	{
		send_to_char( "You can't concentrate enough for that.\n\r", ch );
		return;
    	}

    	if ( !IS_NPC(ch)
    	&&   ch->level < skill_table[gsn_combo]->skill_level[ch->class] )
    	{
		send_to_char("You better leave the martial arts to fighters.\n\r", ch );
		return;
    	}

    	if ( ( victim = who_fighting( ch ) ) == NULL )
    	{
		send_to_char( "You aren't fighting anyone.\n\r", ch );
		return;
    	}

	if (!str_cmp(arg,"jab jab jab"))
    	{
      	attack1 = spell_smaug
		attack2 = spell_smaug  
		attack3 = spell_smaug    
		sn1    = skill_lookup("jab");
		sn2    = skill_lookup("jab");
		sn3    = skill_lookup("jab");
		attack1(sn1);
		attack2(sn2);
		attack3(sn3);
    	}

	if (!str_cmp(arg,"jab jab kick"))
    	{
        }

	if (!str_cmp(arg,"jab punch uppercut"))
    	{
        }

	else 
    	{
	act(AT_PLAIN,"There is no such Combination.'",TO_CHAR);
	return;
    	}
}
.

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 Meerclar   USA  (600 posts)  [Biography] bio
Date Reply #3 on Tue 30 Dec 2003 08:04 AM (UTC)  quote  ]
Message
Simpler I think would be to do something like what follows instead of the if check you have.


	if (str_cmp(arg,"jab jab jab"))
    	{
      	do_jab
        do_jab
        do_jab
    	}


Just skip the whole sn lookup and everything else and do direct function calls. Id recommend adding a check to the do_onehit function in fight.c to stop do_jab from cycling thru multiple hits. If you need some inspiration look at some of the stuff Ive tinkered with in the fight routine for the Dawn of Time codebase, just search the fight.cpp file for my name or circle, should be easy enough to find :)


Meerclar - Lord of Cats
Coder, Builder, and Tormenter of Mortals
Stormbringer: Rebirth
storm-bringer.org:4500
www.storm-bringer.org
[Go to top] top

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #4 on Tue 30 Dec 2003 11:54 AM (UTC)  quote  ]
Message
Thanks heaps, i will download the DoT code right now and start to read throught the items you have mentioned, and see if i can learn some things that would be nice to add to this to make this work better.

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 Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #5 on Tue 30 Dec 2003 12:46 PM (UTC)  quote  ]
Message
I worked it out, took me about 1 hour to find the bits that i needed to pass with the call, now i just have to work out the bits kick and punch require as they are the only 2 seperate functions within these skills.


if (!str_cmp(arg,"jab jab jab"))
    	{
      	spell_smaug( skill_lookup( "jab" ), ch->level, ch, victim );
	spell_smaug( skill_lookup( "jab" ), ch->level, ch, victim );
	spell_smaug( skill_lookup( "jab"), ch->level, ch, victim );
    	}


this works a charm and give you the 3 extra attacks per round and outputs all the details.

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 David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Reply #6 on Tue 30 Dec 2003 01:22 PM (UTC)  quote  ]
Message
You're wasting a little time there, you don't need to do the lookup three times.

You could instead do:


if (!str_cmp(arg,"jab jab jab"))
{
  int sn = skill_lookup("jab");
  spell_smaug( sn, ch->level, ch, victim );
  spell_smaug( sn, ch->level, ch, victim );
  spell_smaug( sn, ch->level, ch, victim );
}


Another thing you can do is to do the lookup once and only once, at game boot. Look around in db.c for where a bunch of gsn_x are set; you'd want to add a similar line to set gsn_jab, without forgetting to declare the variable in the same place as the other declarations.

What this does is to store the skill number once, and then not bother looking it up. It's a good idea to do this for very frequently used skills; however there's no point in doing it for most skills as some people seem to do.

That's just an optimization however; it's not necessary. I do strongly suggest though that you do at least the integer trick I gave above; it's just really silly to do the same lookup three times in a row. :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

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

Posted by Robert Powell   Australia  (367 posts)  [Biography] bio
Date Reply #7 on Tue 30 Dec 2003 10:44 PM (UTC)  quote  ]
Message
Thanks again for the help so to do as you have said i would need to put in db.c the following and then ammend the IF statment to look as follows as well.


in db.c add
sh_int      gsn_jab;
ASSIGN_GSN(gsn_jab    "jab");

if (!str_cmp(arg,"jab jab jab") && ch->level >= 5);
    	{
      	spell_smaug( gsn_jab, ch->level, ch, victim );
	spell_smaug( gsn_jab, ch->level, ch, victim );
	spell_smaug( gsn_jab, ch->level, ch, victim );
    	}
else
        {
        act(AT_PLAIN, "You are not ready for that combination yet, TO_CHAR );
        return;
        }


So from reading the code in db.c im guessing gsn is a global skill number variable, i also decided to add a level check so that you get the use of the combo at a particular level, i dont know if the operator is right but i think thats if player level is greater than or equal to 5, been a long time sinbe i have done any math either, im a truck driver not a computer wiz.

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 David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Reply #8 on Wed 31 Dec 2003 12:49 AM (UTC)  quote  ]
Message
That's all right, except that you want to put the level check inside the jab jab jab section.

If you look at what you have now:

if argument = jab jab jab AND level is <= 5
do the jab jab jab
else
you're not ready yet

So, the "you're not ready yet" is executed if the first statement is false. It will always be false when the argument is not jab jab jab - so the players will get these annoying "you're not ready yet" messages even if they weren't trying to do the jab jab jab combo. :)

And yes, the GSNs are global skill numbers, whose purpose is to speed up skill number lookup on commonly used skills. Instead of searching through the skill list for what you want, you just access it from memory. This is much much faster than looking up every time.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[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.


7,509 views.

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]