Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
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
LOP 1.45
Author: Remcon
Submitted by: Remcon
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
Users Online
CommonCrawl, Yandex, Bing, Sogou, Yahoo!

Members: 0
Guests: 7
Stats
Files
Topics
Posts
Members
Newest Member
477
3,705
19,232
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » Codebases » SWFOTE FUSS » Identifying Weapon Type in Co...
Forum Rules | Mark all | Recent Posts

Identifying Weapon Type in Combat messages
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Mar 6, 2010, 4:21 pm
Go to the top of the page
Go to the bottom of the page

Daiimus
Fledgling
GroupMembers
Posts13
JoinedFeb 26, 2006

I've been working on a project to redo the weapon messages. So far I've managed to isolate male and female, but when trying to discern weapon types I've had issues. My code compiles fine but the check for the weapon seems to fail. I haven't written the code completely out yet because so far I'm just using checks in the messages to make sure it work.

If anyone has any insight into the problem, I'd greatly appreciate it.


The code is below...

void dam_message( CHAR_DATA *ch, CHAR_DATA *victim, int dam, int dt, OBJ_DATA *wield )
{
    char buf1[256], buf2[256], buf3[256];
    const char *vs;
    const char *vp;
    const char *attack;
    char punct;
    sh_int dampc;
    struct skill_type *skill = NULL;
    bool gcflag = FALSE;
    bool gvflag = FALSE;
    

    if ( ! dam )
      dampc = 0;
    else
      dampc = ( (dam * 1000) / victim->max_hit) +
              ( 50 - ((victim->hit * 50) / victim->max_hit) );

   /*		     10 * percent					*/
	
	if ( dam ==      0 && ch->sex == SEX_MALE ) { vs = "MALE miss badly, sending nothing but a gust of air past";	vp = "MALE misses badly, sending nothing but a gust of air past"; }
	else if ( dam ==      0 && ch->sex == SEX_FEMALE) { vs = "FEMALE miss badly, sending nothing but a gust of air past";	vp = "FEMALE misses badly, sending nothing but a gust of air past";	}
	 else if ( dam ==      0 && ch->sex == SEX_MALE && wield && wield->value[3] == WEAPON_LIGHTSABER) { vs = "MALE swing lightsaber like wet noodle";	vp = "MALE swing lightsaber around light wet noodle"; }
    else if ( dampc <=    5 ) { vs = "barely scratch";vp = "barely scratches";}
    else if ( dampc <=   10 ) { vs = "scratch";	vp = "scratches";	}
    else if ( dampc <=   20 ) { vs = "nick";	vp = "nicks";		}
    else if ( dampc <=   30 ) { vs = "graze";	vp = "grazes";		}
    else if ( dampc <=   40 ) { vs = "bruise";	vp = "bruises";		}
    else if ( dampc <=   50 ) { vs = "hit";	vp = "hits";		}
    else if ( dampc <=   60 ) { vs = "injure";	vp = "injures";		}
    else if ( dampc <=   75 ) { vs = "thrash";	vp = "thrashes";	}
    else if ( dampc <=   80 ) { vs = "wound";	vp = "wounds";		}
    else if ( dampc <=   90 ) { vs = "maul";    vp = "mauls";		}
    else if ( dampc <=  125 ) { vs = "decimate";vp = "decimates";	}
    else if ( dampc <=  150 ) { vs = "devastate";vp = "devastates";	}
    else if ( dampc <=  200 ) { vs = "maim";	vp = "maims";		}
    else if ( dampc <=  300 ) { vs = "MUTILATE";vp = "MUTILATES";	}
    else if ( dampc <=  400 ) { vs = "DISEMBOWEL";vp = "DISEMBOWELS";	}
    else if ( dampc <=  500 ) { vs = "MASSACRE";  vp = "MASSACRES";	}
    else if ( dampc <=  600 ) { vs = "PULVERIZE"; vp = "PULVERIZES";	}
    else if ( dampc <=  750 ) { vs = "EVISCERATE";vp = "EVISCERATES";	}
    else if ( dampc <=  990 ) { vs = "* OBLITERATE *";
			        vp = "* OBLITERATES *";			}
    else                      { vs = "*** ANNIHILATE ***";
			        vp = "*** ANNIHILATES ***";		}
       
Post is unread #2 Mar 6, 2010, 6:56 pm
Go to the top of the page
Go to the bottom of the page

Andril
Magician
GroupMembers
Posts147
JoinedJun 9, 2009

As far as I can tell, you're probably not seeing the messages you want because dam is not equal to 0 which means it's not going to bother checking against the attackers sex. Try putting those gender checks in all the options and see what happens.
       
Post is unread #3 Mar 6, 2010, 8:15 pm
Go to the top of the page
Go to the bottom of the page

Daiimus
Fledgling
GroupMembers
Posts13
JoinedFeb 26, 2006

Nah, I've rigged instances when it identifies male and female without a problem. It's the lightsaber miss message that never seems to work out. There seems to be something wrong with that portion of the code.
       
Post is unread #4 Mar 6, 2010, 10:44 pm
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Yeah, your issue seems to be the logic, it SHOULD just show that a gust goes by if male or female hits, because for each, your argument would be true already.

You should check for the light saber BEFORE you check for the other, which is equivalent to empty handedness or anything really, atm.

So I would suggest something like so:

	 if ( dam ==  0 )
         {
             if( wield && wield->value[3] == WEAPON_LIGHTSABER ) 
             {
                  if( ch->sex == SEX_MALE )
                  { 
                      vs = "MALE swing lightsaber like wet noodle";
                      vp = "MALE swing light saber around light wet noodle"; 
                  }
                  if( ch->sex == SEX_FEMALE )
                  { 
                      vs = "FEMALE swing lightsaber like wet noodle";
                      vp = "FEMALE swing light saber around light wet noodle"; 
                  }
             }
             //other weapon misses here
	    else if ( ch->sex == SEX_MALE )  //basically like bare hands miss message 
            { 
                if( ch->sex == SEX_MALE )
                {
                     vs = "MALE miss badly, sending nothing but a gust of air past";	
                     vp = "MALE misses badly, sending nothing but a gust of air past";
                }
                else
                if( ch->sex == SEX_FEMALE )
                {
                     vs = "FEMALE miss badly, sending nothing but a gust of air past";	
                     vp = "FEMALE misses badly, sending nothing but a gust of air past";
                }
            }
        }


Though, in truth, I would probably switch to char types and snprintf everything to make it simpler than it is.

Later,
KeB
       
Post is unread #5 Mar 7, 2010, 7:56 am
Go to the top of the page
Go to the bottom of the page

Daiimus
Fledgling
GroupMembers
Posts13
JoinedFeb 26, 2006

Thanks Keberus!

That's exactly what I needed to do. It's kinda embarrassing that I missed that but I'm new to this whole thing and I got alot of mistakes ahead of me, methinks

What do you mean by switching to char types? Switching it over to snprintf everything makes sense. I was kinda just worried I'd mess something up in combat since I was just slicing through the code with a metaphorical machete.
       
Post is unread #6 Mar 7, 2010, 3:30 pm   Last edited Mar 7, 2010, 3:31 pm by Keberus
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Well, the nice thing about char types would be that you could snprintf, and that way you wouldn't have to seperate the male/female parts so the same code if you did:

char vs[MSL], vp[MSL];


instead of the const char* calls would look like:

	 if ( dam ==  0 )
         {
             if( wield && wield->value[3] == WEAPON_LIGHTSABER ) 
             {
                     snprintf( vs, MSL, "You swing your lightsaber around like a wet noodle!" );
                     snprintf( vp, MSL, "%s swings %s lightsaber around like a wet noodle!", ch->sex == SEX_MALE ? "A male" : "A female", ch->sex == SEX_MALE ? "his" : "her" );
             }

             //other weapon misses here


It would considerably reduce the number of lines code needed, if you wanted separate messages based on the sex of the individual.
       
Post is unread #7 Mar 11, 2010, 10:32 pm
Go to the top of the page
Go to the bottom of the page

Daiimus
Fledgling
GroupMembers
Posts13
JoinedFeb 26, 2006

Fantastic!

Thanks again, Kerberus.

I finally got around to doing some more work tonight and basically just had to copy and paste what you provided me with plus a few variable changes per weapon type and all that. Seems to work fine. I have to rework the final hit message a little though, I think I might need to incorporate a third message to account for what a witness would see once i add some of the verbose attacks. That's just a variable away though.

Since I'm new at C, I'm still not precisely sure what MSL is...but what it does is apparent. The ability to use a switch like that in the code is fantastic and could allow me to come up with some really awesome combat messages "on the fly".

I was wondering about the weapon types though. When I did an oset weapontype, it only displayed
none, lightsaber, vibro-blade, blaster, force pike, bowcaster, bludgeon, dualsaber
but in the code there is also "talonous arms" and "flexible arms" listed in the weapon procifiency bonus check which I used to check for the types originally.

Is there anything that incorporates those weapon types or is it limited to unarmed mobs? Would I need to to use something along the lines of wield->value[5] == WEAPON_TALONOUS_ARMS to check for it? I searched around in some of the code and couldn't find much of anything referencing it thereafter.
       
Post is unread #8 Mar 12, 2010, 4:05 pm
Go to the top of the page
Go to the bottom of the page

Keberus
Conjurer
GroupFUSS Project Team
Posts341
JoinedJun 4, 2005

Daiimus said:


Since I'm new at C, I'm still not precisely sure what MSL is...but what it does is apparent.


MSL is a shorthand for MAX_STRING_LENGTH which sets the maximum length of the variable in characters.

Daiimus said:


but in the code there is also "talonous arms" and "flexible arms" listed in the weapon procifiency bonus check which I used to check for the types originally.

Is there anything that incorporates those weapon types or is it limited to unarmed mobs? Would I need to to use something along the lines of wield->value[5] == WEAPON_TALONOUS_ARMS to check for it? I searched around in some of the code and couldn't find much of anything referencing it thereafter.


Yeah, things like talonous arms and flexible arms are mostly just remnants from the SMAUG codebase that SWR is derived from.
       
Pages:<< prev 1 next >>