Cyiane
Posts : 26 Join date : 2010-02-23
| Subject: Re: Game mechanics... Fri Mar 02, 2012 7:29 am | |
| So after some digging in the old v2 source I found the curse and stun code... But I can't quite pin it down. Anyone competent in C able to help out? Stun code - Code:
-
int spell_stun(int cn,int co,int power) { int in;
if (ch[co].flags&CF_IMMORTAL) return 0;
in=god_create_item(1); if (!in) { xlog("god_create_item failed in skill_stun"); return 0; }
power=spell_immunity(power,ch[co].skill[SK_IMMUN][5]);
power=spell_race_mod(power,ch[cn].kindred); strcpy(it[in].name,"Stun"); it[in].flags|=IF_SPELL; it[in].sprite[1]=91; it[in].duration=it[in].active=power+TICKS; it[in].temp=SK_STUN; it[in].power=power;
if (ch[co].skill[SK_SENSE][5]+10>power) do_char_log(co,1,"%s cast stun on you.\n",ch[cn].reference); else do_char_log(co,0,"You have been stunned.\n"); do_char_log(cn,1,"%s was stunned.\n",ch[co].reference); if (!IS_IGNORING_SPELLS(co)) do_notify_char(co,NT_GOTHIT,cn,0,0,0); do_notify_char(cn,NT_DIDHIT,co,0,0,0); char_play_sound(co,ch[cn].sound+7,-150,0); char_play_sound(cn,ch[cn].sound+1,-150,0); chlog(cn,"Cast Stun on %s",ch[co].name); if (!add_spell(co,in)) { do_char_log(cn,1,"Magical interference neutralised the %s's effect.\n",it[in].name); return 0; }
fx_add_effect(5,0,ch[co].x,ch[co].y,0);
return 1; }
void skill_stun(int cn) { int co,m,co_orig;
if ((co=ch[cn].skill_target1)) ; else if (ch[cn].attack_cn!=0) co=ch[cn].attack_cn; else co=cn;
if (cn==co) { do_char_log(cn,0,"You cannot stun yourself!\n"); return; }
if (!do_char_can_see(cn,co)) { do_char_log(cn,0,"You cannot see your target.\n"); return; }
/* CS, 000209: Remember PvP attacks */ remember_pvp(cn,co); if (is_exhausted(cn)) return;
if (!may_attack_msg(cn,co,1)) { chlog(cn,"Prevented from attacking %s (%d)",ch[co].name,co); return; }
if (spellcost(cn,20)) return;
if (chance_base(cn,ch[cn].skill[SK_STUN][5],12,ch[co].skill[SK_RESIST][5])) { if (cn!=co && ch[co].skill[SK_SENSE][5]>ch[cn].skill[SK_STUN][5]+5) { do_char_log(co,1,"%s tried to cast stun on you but failed.\n",ch[cn].reference); if (!IS_IGNORING_SPELLS(co)) do_notify_char(co,NT_GOTMISS,cn,0,0,0); } return; }
if (ch[co].flags&CF_IMMORTAL) { do_char_log(cn,0,"You lost your focus.\n"); return; } spell_stun(cn,co,ch[cn].skill[SK_STUN][5]);
co_orig=co;
m=ch[cn].x+ch[cn].y*MAPX; if ((co=map[m+1].ch)!=0 && ch[co].attack_cn==cn && co_orig!=co) { if (ch[cn].skill[SK_STUN][5]+RANDOM(20)>ch[co].skill[SK_RESIST][5]+RANDOM(20)) spell_stun(cn,co,ch[cn].skill[SK_STUN][5]); } if ((co=map[m-1].ch)!=0 && ch[co].attack_cn==cn && co_orig!=co) { if (ch[cn].skill[SK_STUN][5]+RANDOM(20)>ch[co].skill[SK_RESIST][5]+RANDOM(20)) spell_stun(cn,co,ch[cn].skill[SK_STUN][5]); } if ((co=map[m+MAPX].ch)!=0 && ch[co].attack_cn==cn && co_orig!=co) { if (ch[cn].skill[SK_STUN][5]+RANDOM(20)>ch[co].skill[SK_RESIST][5]+RANDOM(20)) spell_stun(cn,co,ch[cn].skill[SK_STUN][5]); } if ((co=map[m-MAPX].ch)!=0 && ch[co].attack_cn==cn && co_orig!=co) { if (ch[cn].skill[SK_STUN][5]+RANDOM(20)>ch[co].skill[SK_RESIST][5]+RANDOM(20)) spell_stun(cn,co,ch[cn].skill[SK_STUN][5]); }
fx_add_effect(7,0,ch[cn].x,ch[cn].y,0);
add_exhaust(cn,TICKS*3);
// ch[cn].errno=ERR_SUCCESS;
And curse - Code:
-
int spell_curse(int cn,int co,int power) { int in,n;
if (ch[co].flags&CF_IMMORTAL) return 0;
in=god_create_item(1); if (!in) { xlog("god_create_item failed in spell_curse"); return 0; }
power=spell_immunity(power,ch[co].skill[SK_IMMUN][5]);
power=spell_race_mod(power,ch[cn].kindred); strcpy(it[in].name,"Curse"); it[in].flags|=IF_SPELL; for (n=0; n<5; n++) it[in].attrib[n][1]=-(power/3); //(power/3+10); it[in].sprite[1]=89; it[in].duration=it[in].active=18*60*2; it[in].temp=SK_CURSE; it[in].power=power;
if (!add_spell(co,in)) { do_char_log(cn,1,"Magical interference neutralised the %s's effect.\n",it[in].name); return 0; } if (ch[co].skill[SK_SENSE][5]+10>power) do_char_log(co,1,"%s cast curse on you.\n",ch[cn].reference); else do_char_log(co,0,"You have been cursed.\n"); do_char_log(cn,1,"%s was cursed.\n",ch[co].name); if (!IS_IGNORING_SPELLS(co)) do_notify_char(co,NT_GOTHIT,cn,0,0,0); do_notify_char(cn,NT_DIDHIT,co,0,0,0); char_play_sound(co,ch[cn].sound+7,-150,0); char_play_sound(cn,ch[cn].sound+1,-150,0); chlog(cn,"Cast Curse on %s",ch[co].name); fx_add_effect(5,0,ch[co].x,ch[co].y,0);
return 1; }
void skill_curse(int cn) { int co,co_orig,m;
if ((co=ch[cn].skill_target1)) ; else if (ch[cn].attack_cn!=0) co=ch[cn].attack_cn; else co=cn;
if (cn==co) { do_char_log(cn,0,"You cannot curse yourself!\n"); return; }
if (!do_char_can_see(cn,co)) { do_char_log(cn,0,"You cannot see your target.\n"); return; }
/* CS, 000209: Remember PvP attacks */ remember_pvp(cn,co); if (is_exhausted(cn)) return;
if (spellcost(cn,35)) return;
if (!may_attack_msg(cn,co,1)) { chlog(cn,"Prevented from attacking %s (%d)",ch[co].name,co); return; }
if (chance_base(cn,ch[cn].skill[SK_CURSE][5],10,ch[co].skill[SK_RESIST][5])) { if (cn!=co && ch[co].skill[SK_SENSE][5]>ch[cn].skill[SK_CURSE][5]+5) { do_char_log(co,0,"%s tried to cast curse on you but failed.\n",ch[cn].reference); if (!IS_IGNORING_SPELLS(co)) do_notify_char(co,NT_GOTMISS,cn,0,0,0); } return; }
if (ch[co].flags&CF_IMMORTAL) { do_char_log(cn,0,"You lost your focus.\n"); return; }
spell_curse(cn,co,ch[cn].skill[SK_CURSE][5]);
co_orig=co;
m=ch[cn].x+ch[cn].y*MAPX; if ((co=map[m+1].ch)!=0 && ch[co].attack_cn==cn && co_orig!=co) { if (ch[cn].skill[SK_CURSE][5]+RANDOM(20)>ch[co].skill[SK_RESIST][5]+RANDOM(20)) spell_curse(cn,co,ch[cn].skill[SK_CURSE][5]); } if ((co=map[m-1].ch)!=0 && ch[co].attack_cn==cn && co_orig!=co) { if (ch[cn].skill[SK_CURSE][5]+RANDOM(20)>ch[co].skill[SK_RESIST][5]+RANDOM(20)) spell_curse(cn,co,ch[cn].skill[SK_CURSE][5]); } if ((co=map[m+MAPX].ch)!=0 && ch[co].attack_cn==cn && co_orig!=co) { if (ch[cn].skill[SK_CURSE][5]+RANDOM(20)>ch[co].skill[SK_RESIST][5]+RANDOM(20)) spell_curse(cn,co,ch[cn].skill[SK_CURSE][5]); } if ((co=map[m-MAPX].ch)!=0 && ch[co].attack_cn==cn && co_orig!=co) { if (ch[cn].skill[SK_CURSE][5]+RANDOM(20)>ch[co].skill[SK_RESIST][5]+RANDOM(20)) spell_curse(cn,co,ch[cn].skill[SK_CURSE][5]); }
fx_add_effect(7,0,ch[cn].x,ch[cn].y,0);
add_exhaust(cn,TICKS*4);
// ch[cn].errno=ERR_SUCCESS;
Thanks again! | |
|