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

Reply
 
Thread Tools
Old 09-05-2009, 06: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   Reply With Quote
Old 09-09-2009, 10:50 AM   #2
Newworlds
Legend
 
Newworlds's Avatar
 
Join Date: Aug 2007
Name: NewWorlds
Home MUD: New Worlds
Posts: 1,382
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   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

All times are GMT -4. The time now is 01:58 AM.


Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Style based on a design by Essilor
Copyright Top Mud Sites.com 2014