Skill question

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago - 3 years 1 month ago #7799 by JTP
Skill question was created by JTP
H

Ok the bash skill has its messages in da da da the messages file.

But what If i want a skills messages to be part of the skill in act.offensive.c

Do i Then need an entry in messages with the skill number but with a 0 in Or something ?

Cus Im working on a skill where it Seem to wanna get messages from the messages file still.

Hope what i wrote makes sense and someone knows what to do
Last edit: 3 years 1 month ago by JTP.

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago - 3 years 1 month ago #7805 by lacrc
Replied by lacrc on topic Skill question
Short answer:
If you don't need custom skill/spell messages then use TYPE_UNDEFINED when you call damage() or hit() functions for your skill/spell. TYPE_UNDEFINED is defined as (-1) and circle will not look for a message if that's the damage type.

Long answer:
Skill messages are used based on SKILL_* types and SPELL_* types defined in your mud.
The messages are used after damage() has been rolled for them, so when you call, for example:
damage(ch, vict, 0, SKILL_BACKSTAB);
The skill message for SKILL_BACKSTAB (which is skill 131 defined in spells.h) will be used:
#define SKILL_BACKSTAB              131 /* Reserved Skill[] DO NOT CHANGE */
Since the damage() function was called with 0 it will be considered a miss and a backstab-ery miss message will be displayed.
On the other hand if it were a hit you would call:
hit(ch, vict, SKILL_BACKSTAB);
The hit() function (defined in fight.c, just like damage()) would then be called to roll the damage for the skill, and if the roll ended up to be positive (let's say 10?) then damage would be called to deal that damage:
damage(ch, vict, 10, SKILL_BACKSTAB);
This time since damage has a >0 value, a backstab-ery hit message will be displayed.

It is the same for all skills/spells.
If you want to use generic messages for a skill/spell use TYPE_UNDEFINED when you call any of these functions:
damage(ch, vict, 10, TYPE_UNDEFINED);[
hit(ch, vict, TYPE_UNDEFINED);
This tells circle to not look for a customized message for that hit/damage roll and just display a generic message.
Unrequested friendly advice: you SHOULD use customized messages, they are much better and help to set the mood and keep all the RP in your mud. Just my opinion though hehe.
Last edit: 3 years 1 month ago by lacrc.
The following user(s) said Thank You: thomas, Chime

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago - 3 years 1 month ago #7806 by JTP
Replied by JTP on topic Skill question
Well i cant use the type_undefined because i have other code that does stuff from what kind of damage type it is.

So i need the damage to be skill_*****

But i wanna use act to room/char/vict instead of the messages file, because its a Big skill that does alot of different things with several messages.
Last edit: 3 years 1 month ago by JTP.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago #7807 by JTP
Replied by JTP on topic Skill question
Maybe leaving them blank like this Will allow me to use the act messages. Im not home so cant test atm:

* skillname 250
M
250
#
#
#
#
#
#
#
#
#
#
#
#

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago - 3 years 1 month ago #7808 by lacrc
Replied by lacrc on topic Skill question
I see, I apologize, I based that stuff out of TBA stock code.

I suppose that would work (setting all the messages to #) but I can only assume based on stock TBA code.
If you want to double check (again related to TBA code) you have to check load_messages() in msgedit.c and skill_message in fight.c.

In stock code, load_messages(), which is called at boot time to load all the messages from the file, for every message fread_action() is called, and if the text in the message has just a '#' then the message is set to NULL.

In fight.c the skill_message() function is called by damage() to determine if there is a message that can be used, it will check the type of the skill/spell in 'type' variable and, in stock code, only if the message type requested isn't NULL it will be sent through act(), so you don't need to worry about segfaulting.
Last edit: 3 years 1 month ago by lacrc.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago #7809 by JTP
Replied by JTP on topic Skill question
Some Stock messages already have # in them like this one:

* poison 33
M
33
#
Poison burns intensely in your veins... you shiver... you die.
$N screams in pain, keels over and dies.
#
suffer miss victim - should never see.
suffer miss room - should never see.
#
You feel burning poison in your blood, and suffer.
$N looks really sick and shivers uncomfortably.
#
You have become poisoned somehow.
$N has somehow become poisoned.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago #7825 by JTP
Replied by JTP on topic Skill question
Thomas would all # in the messages file, let me use acts in a skill as messages instead ?

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago #7839 by thomas
Replied by thomas on topic Skill question
You'll be sending some on/off color codes, but apart from that, no problem: github.com/tbamud/tbamud/blob/master/src/fight.c#L548
         send_to_char(vict, CCRED(vict, C_CMP));
          act(msg->die_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT | TO_SLEEP); // <- msg == NULL is a no-op
          send_to_char(vict, CCNRM(vict, C_CMP));

          act(msg->die_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT); // <- msg == NULL is a no-op
        } else {
          if (msg->hit_msg.attacker_msg) {
            send_to_char(ch, CCYEL(ch, C_CMP));
            act(msg->hit_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR);
            send_to_char(ch, CCNRM(ch, C_CMP));
          }

          send_to_char(vict, CCRED(vict, C_CMP));
          act(msg->hit_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT | TO_SLEEP); // <- msg == NULL is a no-op
          send_to_char(vict, CCNRM(vict, C_CMP));

          act(msg->hit_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT); // <- msg == NULL is a no-op
        }
      } else if (ch != vict) {	/* Dam == 0 */
        if (msg->miss_msg.attacker_msg) {
          send_to_char(ch, CCYEL(ch, C_CMP));
          act(msg->miss_msg.attacker_msg, FALSE, ch, weap, vict, TO_CHAR);
          send_to_char(ch, CCNRM(ch, C_CMP));
        }

        send_to_char(vict, CCRED(vict, C_CMP));
        act(msg->miss_msg.victim_msg, FALSE, ch, weap, vict, TO_VICT | TO_SLEEP); // <- msg == NULL is a no-op
        send_to_char(vict, CCNRM(vict, C_CMP));

        act(msg->miss_msg.room_msg, FALSE, ch, weap, vict, TO_NOTVICT);  // <- msg == NULL is a no-op
But it should work.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago - 3 years 1 month ago #7840 by JTP
Replied by JTP on topic Skill question
Ok now i get messages from my acts...Just need to fiddle when to use TRUE or FALSE and get the right $n $n etc

What does the TRUE or FALSE do ?

Right now i have TRUE in all 3, both to_room/vict/char, seems to work.
Last edit: 3 years 1 month ago by JTP.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago #7842 by JTP
Replied by JTP on topic Skill question
Hmmm vict sees both TO_ROOM and TO_VICT message, not good

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago #7843 by JTP
Replied by JTP on topic Skill question
And when is it ch, 0, vict

And when vict, 0, ch ?

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago #7844 by JTP
Replied by JTP on topic Skill question
And i see some places in the code use:

#if 0
.....
act....
#endif

When is that a good idea to use ?

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago #7847 by thomas
Replied by thomas on topic Skill question
please read the file doc/act.txt to learn about the input to the act() function.

The #if / #endif pairs makes it easy to "uncomment" the part between them (switch out the 0 with a 1). Don't use them unless debugging.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago - 3 years 1 month ago #7848 by JTP
Replied by JTP on topic Skill question
Imo that file only shows exambles of ch, 0, vict
Nothing about vict, 0, ch

All over the code both sulutions are Used.
Last edit: 3 years 1 month ago by JTP.

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago #7851 by thomas
Replied by thomas on topic Skill question
quote github.com/tbamud/tbamud/blob/master/doc/act.txt#L35 :

void act(const char *str, int hide_invisible, struct char_data *ch,
struct obj_data *obj, const void *vict_obj, int type)

Please read the above. I mean, really read it. It tells you the name of the parameters.

Then, it goes on to tell you what they mean github.com/tbamud/tbamud/blob/master/doc/act.txt#L40 :

str: This is the basic string, a null terminated character array, including
control characters (see section 1.4 on ‘Control Characters’), to be sent to
characters designated by the targets.

hide_invisible: A TRUE or FALSE value indicating whether or not to hide the
entire output from any characters that cannot see the “performing character”.

ch: The “performing character”. This is the character that the output string
is associated with. The character is used to determine the room for the output
of the action in question.

obj: An object (an actual item – obj_data) used in the course of the action.

vict_obj: This can be either a character involved in the action, another
object, or even a predefined string of text.

type: One of TO_VICT, TO_CHAR, TO_NOTVICT, or TO_ROOM. This indicates who it
is to be targeted at.

1.3 The Parameters
Of the various parameters passed to the act() function, the str is the most
important, as it is the basis for the actual final output. If this parameter
is a null-pointer or points to a null-character, then the function returns
immediately. The next important parameter is the ch parameter. This, as
mentioned, points to the central character associated with the output string
and action.

obj is an object of type struct obj_data *that is passed to the function. If
there is no object to pass to the function, then a NULL or 0 should be passed
in this location.

The next parameter vict_objcan be a number of things ranging from a game object
(strcut obj_data *), through to a character (struct char_data *), and even a
null terminated character array (char *).

Do note, however, that obj and vict_obj are both ignored if there is no control
character reference (see section 1.4 ‘Control Characters’) to them and the type
is set to TO_ROOM or TO_CHAR. In these cases, NULL should be supplied as the
input to the function.

The hide_invisible flag dictates whether or not the action output should be
hidden from characters that cannot see ch. If the flag is set to TRUE
(non-zero), then this is the case.

The type determines who the output is to be sent to. There are four options for
this (all defined in comm.h) described below:

TO_ROOM: This sends the output to everybody in the room, except ch.

TO_VICT: This option sends the output to the character pointed to by vict_obj.
In this case, vict_obj must point at a character rather than an object.

TO_NOTVICT: In another case where vict_obj must point to a character. This
sends the output to everybody in the room except ch and vict_obj.

TO_CHAR: Finally, this option sends the output to the ch.

TO_SLEEP: This is a special option that must be combined with one of the above
options. It tells act() that the output is to be sent even to characters that
are sleeping. It is combined with a bitwise ‘or’. i.e. TO_VICT | TO_SLEEP.

When the string has been parsed, it is capitalized and a newline is added.
...


Now, when you've read the above a couple of times, you'll probably ask yourself (and us :) , "...but what does it mean when the parameter ch is passed a reference to the victim?". It means, as it says in the act.txt file right above here, that ch: The “performing character”. This is the character that the output string
is associated with. The character is used to determine the room for the output
of the action in question.


Consider a hypothetical scenario, where YourName is fighting HerName, and we're sending a genering "hurts" message.

So, what does this do?
act("You hurt $M", TRUE, ch, 0, vict, TO_CHAR);
act("$n hurts $N", TRUE, ch, 0, vict, TO_NOTVICT);
act("$n hurts you!", TRUE, ch, 0, vict, TO_VICT);
It sends "You hurt her" to the char causing the hurting, "YourName hurts HerName" to onlookers in the same room as YourName and "YourName hurts you!" to the victim.

So, what if we switch the order of the passed variables?
act("You hurt $m", TRUE, vict, 0, ch, TO_VICT); 
act("$N hurts $n", TRUE, vict, 0, ch, TO_NOTVICT);
act("$m hurts you!", TRUE, vict, 0, ch, TO_CHAR);
As you see, we need to switch the flags and the control characters in the strings to get the same results. Also note that now, the second line works corectly if YourName happened to hurt HerName from another room. The victims room is used to find the TO_ROOM room, because it is sent as the 'ch' parameter.

I think much of your confusion stems from the fact that we have two different concepts here with the same name. 'ch' refers to both a variable (in the calling code) and a parameter (in the act() prototype). But even though the parameter is called 'ch', any char_data pointer will work there, including 'vict'.
The following user(s) said Thank You: Chime, lacrc

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago #7854 by JTP
Replied by JTP on topic Skill question
Thank you for giving detailed explanation to both ways that helped.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago - 3 years 1 month ago #7855 by JTP
Replied by JTP on topic Skill question
Ok i knew i would run into trouble haha...the skill im making is an AOE skill and has:
   act("You ...!", FALSE, ch, 0, tch, TO_CHAR);
   act("$n ...!", FALSE, ch, 0, tch, TO_ROOM);  */ also tried VICT /*
  GET_MANA(ch) = (GET_MANA(ch) - 60);
  damage(ch, tch, dam, TYPE_UNDEFINED);

BUT if the skill instantly kills the target, all they see is You die R.I.P. and then the login menu.
Other then that it looks ok.

Any idea ? I also tried using 0 instead of tch and TRUE instead of FALSE, still the same.
Last edit: 3 years 1 month ago by JTP.

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago #7859 by JTP
Replied by JTP on topic Skill question
Solved

Please Log in or Create an account to join the conversation.

More
3 years 1 month ago #7860 by thomas
Replied by thomas on topic Skill question
How did you solve that?

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
3 years 1 month ago #7861 by JTP
Replied by JTP on topic Skill question
For the aoe skill i needed both acts and messages in order for the vict to see what happened to him.

Please Log in or Create an account to join the conversation.

Time to create page: 0.171 seconds