|
|
#1 | |
|
New Member
Join Date: Aug 2009
Posts: 2
![]() |
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;
}
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;
}
Code:
typedef enum
{
iron,
silver,
gold
}
weap_material;
Code:
Proto(immune_t check_material, (ObjData * weap_material)); Quote:
Code:
switch (check_material(victim, weap_material)) |
|
|
|
|
|
|
#2 |
|
Legend
Join Date: Aug 2007
Name: NewWorlds
Home MUD: New Worlds
Posts: 1,184
![]() ![]() |
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.
|
|
|
|