Top Mud Sites Forum Return to TopMudSites.com
Go Back   Top Mud Sites Forum > Mud Development and Administration > MUD Coding
Click here to Register


This is a discussion on "Weapon material immunities" in the Top Mud Sites MUD Coding forum :

Hello. I installed a FirstMud server, and have modified it a bit. I want to get imms/res/vulns to weapon materials working, and have churned out some code. In handler.c I've got this: Code: immune_t check_material(CharData * ch, ObjData * obj, weap_material) { immune_t immune, def; flag_t bit; immune = IMMUNE_NONE; def = IS_NORMAL; obj = get_eq_char(ch, WEAR_WIELD); weap_material = obj->material; if (obj != NULL) { switch (weap_material) { case iron: case silver: case gold: if (IsSet(ch->imm_flags, IMM_IRON)) def = IS_IMMUNE; else if (IsSet(ch->res_flags, RES_IRON)) def = IS_RESISTANT; else if (IsSet(ch->vuln_flags, VULN_IRON)) def = IS_VULNERABLE; else if (...



You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our MUD community today!

If you have any problems with the registration process or your account login, please contact us.

If you are a registered member of the old TMS forums, please click here
Reply
 
LinkBack Thread Tools
Old 09-05-2009, 07:19 PM   #1
riayi
New Member
 
Join Date: Aug 2009
Posts: 2
riayi is on a distinguished road
Weapon material immunities

Hello. I installed a FirstMud server, and have modified it a bit. I want to get imms/res/vulns to weapon materials working, and have churned out some code. In handler.c I've got this:
Code:
immune_t check_material(CharData * ch, ObjData * obj, weap_material)
{
    immune_t immune, def;
    flag_t bit;

    immune = IMMUNE_NONE;
    def = IS_NORMAL;
    
    obj = get_eq_char(ch, WEAR_WIELD);
    weap_material = obj->material;
    if (obj != NULL)
    {
        switch (weap_material)
        {
            case iron:
            case silver:
            case gold:
                if (IsSet(ch->imm_flags, IMM_IRON))
                    def = IS_IMMUNE;
                else if (IsSet(ch->res_flags, RES_IRON))
                    def = IS_RESISTANT;
                else if (IsSet(ch->vuln_flags, VULN_IRON))
                    def = IS_VULNERABLE;
                else if (IsSet(ch->dire_vuln_flags, DIRE_VULN_IRON))
                    def = IS_DIRE_VULNERABLE;
                if (IsSet(ch->imm_flags, IMM_SILVER))
                    def = IS_IMMUNE;
                else if (IsSet(ch->res_flags, RES_SILVER))
                    def = IS_RESISTANT;
                else if (IsSet(ch->vuln_flags, VULN_SILVER))
                    def = IS_VULNERABLE;
                else if (IsSet(ch->dire_vuln_flags, DIRE_VULN_SILVER))
                    def = IS_DIRE_VULNERABLE;
                if (IsSet(ch->imm_flags, IMM_GOLD))
                    def = IS_IMMUNE;
                else if (IsSet(ch->res_flags, RES_GOLD))
                    def = IS_RESISTANT;
                else if (IsSet(ch->vuln_flags, VULN_GOLD))
                    def = IS_VULNERABLE;
                else if (IsSet(ch->dire_vuln_flags, DIRE_VULN_GOLD))
                    def = IS_DIRE_VULNERABLE;
                break;
                default:
                def = IS_NORMAL;
                break;
        }
    }

    switch (weap_material)
    {
        case (silver):
            bit = IMM_SILVER;
            break;
        case (iron):
            bit = IMM_IRON;
            break;
        case (gold):
            bit = IMM_GOLD;
            break;
        default:
            return def;
    }

    if (IsSet(ch->imm_flags, bit))
        immune = IS_IMMUNE;
    else if (IsSet(ch->res_flags, bit) && immune != IS_IMMUNE)
        immune = IS_RESISTANT;
    if (IsSet(ch->dire_vuln_flags, bit))
        immune = IS_DIRE_VULNERABLE;
    else if (IsSet(ch->vuln_flags, bit) && immune != IS_DIRE_VULNERABLE)
    {
        if (immune == IS_IMMUNE)
            immune = IS_RESISTANT;
        else if (immune == IS_RESISTANT)
            immune = IS_NORMAL;
        else if (immune == IS_VULNERABLE)
            immune = IS_VULNERABLE;
    }

    if (immune == IMMUNE_NONE)
        return def;
    else
        return immune;
}
In fight.c, the damage modifier is checked like so:
Code:
switch (check_material(victim, weap_material))
    {
        case (IS_IMMUNE):
            immune = true;
            dam = 0;
            break;
        case (IS_RESISTANT):
            dam -= dam / 3;
            break;
        case (IS_VULNERABLE):
            dam += dam / 2;
            break;
        case (IS_DIRE_VULNERABLE):
            dam += dam;
            break;
        default:
            break;
    }
In defines.h, I set up material types (I think):
Code:
typedef enum
{
    iron,
    silver,
    gold
}
weap_material;
And lastly, in proto.h, the check_material function is defined:
Code:
Proto(immune_t check_material, (ObjData * weap_material));
I've just begun coding, and I'm using the functions already in place, as well as whatever I can find on the net, to guide my modifications. I have managed to achieve most of what I've started, but right now the compiler complains that
Quote:
fight.c:1183: error: cannot convert `CharData*' to `ObjData*' for argument `1' to `immune_t check_material(ObjData*)'
The referenced line is the first one from fight.c:
Code:
switch (check_material(victim, weap_material))
I'd appreciate any help anyone could give me. Thanks in advance!
riayi is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 09-09-2009, 11:50 AM   #2
Newworlds
Legend
 
Newworlds's Avatar
 
Join Date: Aug 2007
Name: NewWorlds
Home MUD: New Worlds
Posts: 1,169
Newworlds will become famous soon enoughNewworlds will become famous soon enough
Re: Weapon material immunities

Your CharData is a string pointer and your ObjData is an object pointer. You can't do that without a Mixed array.
Newworlds is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Thread Tools


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

All times are GMT -4. The time now is 09:34 PM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Style based on a design by Essilor
Copyright Top Mud Sites.com 2011