func void activate_trap(var int chesttype, var int traptype) {
var int trapchance;
var int dexunchance;
var int trapon;
var int damagebasic;
var int magicvisualfx;
var int spawnnecrom;
var int sbmode_damage;
if (rx_avanfistring) {
return;
};
if (trapstatus == true) {
if (hero.attribute[atr_dexterity] /*5*/ > 100) {
dexunchance = ((talentcount_picklock * 2) + 10) + (hero.attribute[atr_dexterity] /*5*/ - 100);
}
else {
dexunchance = (talentcount_picklock * 2) + 10;
};
if (((chesttype == 0) || (chesttype == 1)) || (chesttype == 2)) {
trapon = false;
};
if (chesttype == 3) {
if (dexunchance < 600) {
trapchance = 600 - dexunchance;
}
else {
trapchance = 1;
};
if (hlp_random(1000) < trapchance) {
trapon = true;
}
else {
trapon = false;
};
}
else if (chesttype == 4) {
if (dexunchance < 750) {
trapchance = 750 - dexunchance;
}
else {
trapchance = 1;
};
if (hlp_random(1000) < trapchance) {
trapon = true;
}
else {
trapon = false;
};
}
else if (chesttype == 5) {
if (dexunchance < 900) {
trapchance = 900 - dexunchance;
}
else {
trapchance = 1;
};
if (hlp_random(1000) < trapchance) {
trapon = true;
}
else {
trapon = false;
};
}
else if (chesttype == 6) {
if (dexunchance < 1000) {
trapchance = 1000 - dexunchance;
}
else {
trapchance = 1;
};
if (hlp_random(1000) < trapchance) {
trapon = true;
}
else {
trapon = false;
};
};
if (trapon == true) {
if (traptype == 1) {
sbmode_damage = (5 - sbmode) * 15;
if (sbmode_damage < 1) {
sbmode_damage = 1;
};
damagebasic = 150 + (hlp_random(sbmode_damage) * chesttype);
if (resistpoisonknow == false) {
if (hero.attribute[atr_hitpoints] /*0*/ > (damagebasic + 1)) {
ai_printred("В сундуке была ядовитая ловушка!");
npc_changeattribute(hero, atr_hitpoints, -damagebasic);
rx_poisonhero();
rx_playeffect("SPELLFX_INCOVATION_GREEN", hero);
rx_playeffect("SPELLFX_BLOODDEAD1", hero);
}
else {
if (rx_nexthitignore) {
rx_useprotectpotion();
return;
};
ai_stopprocessinfos(hero);
hero.aivar[4] = false;
player_mobsi_production = mobsi_none;
npc_changeattribute(hero, atr_hitpoints, -hero.attribute[atr_hitpoints_max] /*1*/);
ai_printred("В сундуке была ядовитая ловушка!");
rx_poisonhero();
rx_playeffect("SPELLFX_INCOVATION_GREEN", hero);
rx_playeffect("SPELLFX_BLOODDEAD1", hero);
ai_drawweapon(hero);
ai_removeweapon(hero);
};
};
}
else if (traptype == 2) {
sbmode_damage = (5 - sbmode) * 20;
if (sbmode_damage < 1) {
sbmode_damage = 1;
};
damagebasic = 100 + (hlp_random(sbmode_damage) * chesttype);
if (damagebasic > hero.protection[prot_fire] /*3*/) {
damagebasic = damagebasic - hero.protection[prot_fire] /*3*/;
}
else {
damagebasic = 100;
};
if (hero.attribute[atr_hitpoints] /*0*/ > (damagebasic + 1)) {
npc_changeattribute(hero, atr_hitpoints, -damagebasic);
ai_playani(hero, "S_FIRE_VICTIM");
rx_playeffect("SPELLFX_BLOODDEAD1", hero);
ai_stopfx(hero, "VOB_MAGICBURN");
npc_stopani(hero, "S_FIRE_VICTIM");
}
else {
if (rx_nexthitignore) {
rx_useprotectpotion();
return;
};
ai_stopprocessinfos(hero);
hero.aivar[4] = false;
player_mobsi_production = mobsi_none;
b_say(hero, hero, "$Dead");
npc_changeattribute(hero, atr_hitpoints, -hero.attribute[atr_hitpoints_max] /*1*/);
ai_playani(hero, "S_FIRE_VICTIM");
ai_drawweapon(hero);
ai_removeweapon(hero);
ai_stopfx(hero, "VOB_MAGICBURN");
npc_stopani(hero, "S_FIRE_VICTIM");
};
}
else if (traptype == 3) {
sbmode_damage = (5 - sbmode) * 25;
if (sbmode_damage < 1) {
sbmode_damage = 1;
};
damagebasic = 100 + (hlp_random(sbmode_damage) * chesttype);
if (damagebasic > hero.protection[prot_magic] /*5*/) {
damagebasic = damagebasic - hero.protection[prot_magic] /*5*/;
}
else {
damagebasic = 100;
};
if (hero.attribute[atr_hitpoints] /*0*/ > (damagebasic + 1)) {
npc_changeattribute(hero, atr_hitpoints, -damagebasic);
}
else {
if (rx_nexthitignore) {
rx_useprotectpotion();
return;
};
ai_stopprocessinfos(hero);
hero.aivar[4] = false;
player_mobsi_production = mobsi_none;
b_say(hero, hero, "$Dead");
npc_changeattribute(hero, atr_hitpoints, -hero.attribute[atr_hitpoints_max] /*1*/);
ai_drawweapon(hero);
ai_removeweapon(hero);
};
magicvisualfx = hlp_random(4);
if (magicvisualfx == 0) {
rx_playeffect("spellFX_BELIARSRAGE", hero);
rx_playeffect("SPELLFX_BELIARSRAGE_TARGET_CLOUD", hero);
rx_playeffect("SPELLFX_BELIARSRAGE_COLLIDE", hero);
rx_playeffect("SPELLFX_BLOODDEAD1", hero);
}
else if (magicvisualfx == 1) {
rx_playeffect("SPELLFX_ICECUBE", hero);
rx_playeffect("SPELLFX_ICESHIELD_COLLIDE", hero);
rx_playeffect("SPELLFX_BLOODDEAD1", hero);
}
else if (magicvisualfx == 2) {
rx_playeffect("SPELLFX_FEAR", hero);
rx_playeffect("SPELLFX_FEAR_WINGS", hero);
rx_playeffect("SPELLFX_FEAR_WINGS2", hero);
rx_playeffect("SPELLFX_FEAR_GROUND", hero);
rx_playeffect("SPELLFX_BLOODDEAD1", hero);
}
else {
if (magicvisualfx == 3) {
rx_playeffect("SPELLFX_SKULL_COLLIDEFX", hero);
rx_playeffect("SPELLFX_GREENTENTACLE_TARGET", hero);
rx_playeffect("SPELLFX_BREATHOFDEATH_TARGET", hero);
rx_playeffect("SPELLFX_BLOODDEAD1", hero);
};
};
}
else {
if (traptype == 4) {
sbmode_damage = (5 - sbmode) * 5;
if (sbmode_damage < 1) {
sbmode_damage = 1;
};
spawnnecrom = sbmode_damage + (hlp_random(sbmode_damage) * chesttype);
if (spawnnecrom >= 90) {
rx_saveparservars();
wld_spawnnpcrange(hero, demonlord /*44265*/, 1, 500.0);
rx_restoreparservars();
}
else if (spawnnecrom >= 80) {
rx_saveparservars();
wld_spawnnpcrange(hero, demon /*44217*/, 1, 500.0);
rx_restoreparservars();
}
else if (spawnnecrom >= 70) {
rx_saveparservars();
wld_spawnnpcrange(hero, skeleton_warrior_dark /*45122*/, 2, 500.0);
rx_restoreparservars();
}
else if (spawnnecrom >= 60) {
rx_saveparservars();
wld_spawnnpcrange(hero, skeleton_warrior /*45115*/, 2, 500.0);
rx_restoreparservars();
}
else if (spawnnecrom >= 50) {
rx_saveparservars();
wld_spawnnpcrange(hero, skeleton_dark /*45104*/, 2, 500.0);
rx_restoreparservars();
}
else if (spawnnecrom >= 40) {
rx_saveparservars();
wld_spawnnpcrange(hero, skeleton /*45090*/, 2, 500.0);
rx_restoreparservars();
}
else if (spawnnecrom >= 30) {
rx_saveparservars();
wld_spawnnpcrange(hero, lesser_skeleton_dark /*45089*/, 2, 500.0);
rx_restoreparservars();
}
else if (spawnnecrom >= 20) {
rx_saveparservars();
wld_spawnnpcrange(hero, lesser_skeleton /*45087*/, 2, 500.0);
rx_restoreparservars();
}
else if (spawnnecrom >= 10) {
rx_saveparservars();
wld_spawnnpcrange(hero, gobbo_skeleton /*44638*/, 2, 500.0);
rx_restoreparservars();
}
else {
rx_saveparservars();
wld_spawnnpcrange(hero, gobbo_skeleton /*44638*/, 1, 500.0);
rx_restoreparservars();
};
rx_playeffect("SPELLFX_SKULL_COLLIDEFX", hero);
snd_play("MFX_FEAR_CAST");
rx_playeffect("FX_EarthQuake", hero);
};
};
};
};
};