What's new

-Tibia 7.60 [7.6] Fields Damage

Status
Not open for further replies.

Thorge D

Advanced User
Joined
Jul 24, 2014
Messages
300
Reaction score
29
1. Autor: BD - BlackDemon
2. Link do oryginalnego tematu:
Opis: Gdy wejdziesz w ogie?, energi?, trucizn? etc. zostaje Ci odj?te 20 HP.

4. Kod:

actions.cpp pod:
[CPP]#ifdef YUR_ACT_EXT
lua_register(luaState, "getItemName", ActionScript::luaActionGetItemName);
#endif //YUR_ACT_EXT[/CPP]
dodaj:
[CPP]#ifdef BD_CONDITION
lua_register(luaState, "doCreateCondition", ActionScript::luaActionDoCreateCondition);
#endif //BD_CONDITION[/cpp]
Na samym dole tego pliku dodaj:
[CPP]#ifdef BD_CONDITION
int ActionScript::luaActionDoCreateCondition(lua_State *L)
{
//DoCreateCondition(creatureid,animationColor,damageEffect,hitEffect,attackType,of​fensive,maxDamage,minDamage,ticks,count)
long count = (long)internalGetNumber(L);
long ticks = (long)internalGetNumber(L);
int minDamage = (int)internalGetNumber(L);
int maxDamage = (int)internalGetNumber(L);
bool offensive = (bool)internalGetNumber(L);
int attacktype = (int)internalGetNumber(L);
unsigned char hitEffect = (unsigned char)internalGetNumber(L);
unsigned char damageEffect = (unsigned char)internalGetNumber(L);
unsigned char animationColor = (unsigned char)internalGetNumber(L);
unsigned int cid = (unsigned int)internalGetNumber(L);

attacktype_t attackType;

ActionScript *action = getActionScript(L);

const KnownThing* tmp = action->GetCreatureByUID(cid);
if(tmp){
Creature *creature = (Creature*)(tmp->thing);
switch(attacktype) {
case 0: attackType = ATTACK_NONE; break;
case 1: attackType = ATTACK_ENERGY; break;
case 2: attackType = ATTACK_BURST; break;
case 3: attackType = ATTACK_FIRE; break;
case 4: attackType = ATTACK_PHYSICAL; break;
case 5: attackType = ATTACK_POISON; break;
case 6: attackType = ATTACK_PARALYZE; break;
case 7: attackType = ATTACK_DRUNKNESS; break;
default:
break;
}
action->game->CreateCondition(creature, NULL, animationColor, damageEffect, hitEffect, attackType, offensive, maxDamage, minDamage, ticks, count);
}
else{
lua_pushnumber(L, -1);
std::cout << "DoCreateCondition: creature not found" << std::endl;
return 1;
}
return 1;
}
#endif //BD_CONDITION[/CPP]
actions.h pod:
[CPP]static int luaActionDoPlayerRemoveItem(lua_State *L);[/CPP]
dodaj:
[CPP]#ifdef BD_CONDITION
static int luaActionCreateCondition(lua_State *L);
static int luaActionDoCreateCondition(lua_State *L);
#endif //BD_CONDITION[/CPP]
creature.cpp na samym dole tego pliku dodaj:
[CPP]#ifdef BD_CONDITION
void Creature::removeCondition(attacktype_t attackType)
{
if(attackType == ATTACK_NONE)
return;
ConditionVec &condVec = conditions[attackType];
condVec.clear();
}
#endif //BD_CONDITION[/CPP]
creature.h pod:
[CPP]Conditions& getConditions() {return conditions;};[/CPP]
dodaj:
[CPP]#ifdef BD_CONDITION
void removeCondition(attacktype_t attackType);
#endif //BD_CONDITION [/CPP]
game.cpp nad:
[CPP]// Magic Field in destiny field
if(creatureMoving)
{
const MagicEffectItem* fieldItem = toTile->getFieldItem();[/CPP]
dodaj:
[CPP]#ifdef BD_CONDITION
if(toTile && playerMoving && playerMoving->access < g_config.ACCESS_PROTECT && !toTile->downItems.empty() || toTile && creatureMoving && creatureMoving->access < g_config.ACCESS_PROTECT && !toTile->downItems.empty())
{
ItemVector::iterator iit;
for (iit = toTile->downItems.begin(); iit != toTile->downItems.end(); iit++)
{
if(!(*iit)) continue;
Item *item = dynamic_cast<Item*>(*iit);
if(!item) continue;
if(!creatureMoving || creatureMoving->isRemoved || creatureMoving->health <= 0) break;
if (item->getID() == 1492 || item->getID() == 1423 || item->getID() == 1487){//Fire - Big
doFieldDamage(creatureMoving, 199 , NM_ME_HITBY_FIRE, NM_ME_HITBY_FIRE, ATTACK_FIRE, true, 20);
// creature DamageColor, damageEffect, hitEffect attackType, offensive, damage
if(creatureMoving && !creatureMoving->isRemoved && creatureMoving->health > 0)
CreateCondition(creatureMoving, NULL, 199, NM_ME_HITBY_FIRE, NM_ME_HITBY_FIRE, ATTACK_FIRE, true, 10, 10, 4000, 10);
}
else if(item->getID() == 1493 || item->getID() == 1424 || item->getID() == 1488){//Fire Medium
doFieldDamage(creatureMoving, 199, NM_ME_HITBY_FIRE, NM_ME_HITBY_FIRE, ATTACK_FIRE, true, 10);
if(creatureMoving && !creatureMoving->isRemoved && creatureMoving->health > 0)
CreateCondition(creatureMoving, NULL, 199, NM_ME_HITBY_FIRE, NM_ME_HITBY_FIRE, ATTACK_FIRE, true, 10, 10, 4000, 10);
}
else if(item->getID() == 1495 || item->getID() == 1491){//Energy
doFieldDamage(creatureMoving, 71, NM_ME_ENERGY_DAMAGE, NM_ME_ENERGY_DAMAGE, ATTACK_ENERGY, true, 30);
if(creatureMoving && !creatureMoving->isRemoved && creatureMoving->health > 0)
CreateCondition(creatureMoving, NULL, 71, NM_ME_ENERGY_DAMAGE, NM_ME_ENERGY_DAMAGE, ATTACK_ENERGY, true, 30, 30, 4000, 3);
}
else if(item->getID() == 1496 || item->getID() == 1490){//Poison
doFieldDamage(creatureMoving, 84, NM_ME_POISEN, NM_ME_POISEN, ATTACK_POISON, true, 10);
if(creatureMoving && !creatureMoving->isRemoved && creatureMoving->health > 0)
CreateCondition(creatureMoving, NULL, 84, NM_ME_POISEN, NM_ME_POISEN_RINGS, ATTACK_POISON, true, 10, 10, 4000, 10);
}
if(!creatureMoving || creatureMoving->isRemoved || creatureMoving->health <= 0) break;
}

}
#endif //BD_CONDITION[/CPP]
Na samym dole tego pliku dodaj:
[CPP]#ifdef BD_CONDITION
void Game::CreateCondition(Creature* creature, Creature* target, unsigned char animationColor, unsigned char damageEffect, unsigned char hitEffect, attacktype_t attackType, bool offensive, int maxDamage, int minDamage, long ticks, long count)
{
unsigned long targetID;
if(target)
targetID = target->getID();
else
targetID = 0;
MagicEffectTargetCreatureCondition magicCondition = MagicEffectTargetCreatureCondition(targetID);
magicCondition.animationColor = animationColor;
magicCondition.damageEffect = damageEffect;
magicCondition.hitEffect = hitEffect;
magicCondition.attackType = attackType;
magicCondition.maxDamage = maxDamage;
magicCondition.minDamage = minDamage;
magicCondition.offensive = offensive;
CreatureCondition condition = CreatureCondition(ticks, count, magicCondition);
creature->addCondition(condition, true);
Player *player = dynamic_cast<Player*>(creature);
if(player)
player->sendIcons();
}
void Game::doFieldDamage(Creature* creature, unsigned char animationColor, unsigned char damageEffect,
unsigned char hitEffect, attacktype_t attackType, bool offensive, int damage)
{
MagicEffectClass cd;
cd.animationColor = animationColor;
cd.damageEffect = damageEffect;
cd.hitEffect = hitEffect;
cd.attackType = attackType;
cd.offensive = offensive;
Player* itsHim = dynamic_cast<Player*>(getCreatureByID(creature->getID()));
if(itsHim){ //Since that was causing damage/2 against player, here its my solution =)
cd.maxDamage = damage*2;
cd.minDamage = damage*2;
}
else{
cd.maxDamage = damage;
cd.minDamage = damage;
}
creatureMakeMagic(NULL, creature->pos, &cd);
}
#endif //BD_CONDITION[/CPP]
game.h pod:
[CPP]#ifdef YUR_CLEAN_MAP
long cleanMap();
#endif //YUR_CLEAN_MAP [/CPP]
dodaj:
[CPP]#ifdef BD_CONDITION
void CreateCondition(Creature* creature, Creature* target, unsigned char animationColor, unsigned char damageEffect, unsigned char hitEffect, attacktype_t attackType, bool offensive, int maxDamage, int minDamage, long ticks, long count);
void doFieldDamage(Creature* creature, unsigned char animationColor, unsigned char damageEffect, unsigned char hitEffect, attacktype_t attackType, bool offensive, int damage);
Creature* getCreatureByPosition(int x, int y, int z);
#endif //BD_CONDITION[/CPP]
Na sam koniec do parametr?w dodajemy:
Code:
-DBD_CONDITION

Projekt zapisa? i przebudowa? (ctrl+F11).
Sprawdzone na czystej wersji YurOTS 0.94f.


Dodatek:
Kod, kt?ry uniemo?liwia popchni?cie gracza na fieldy.

Wystarczy pod:
[CPP]if(!toTile && creatureMoving && creatureMoving == creature){
//change level begin
Tile* downTile = getTile(to_x, to_y, to_z+1);
//diagonal begin
if(!downTile)
{ [/CPP]
Doda?:
[CPP]if (toTile){
ItemVector::iterator brn;
for (brn = toTile->downItems.begin(); brn != toTile->downItems.end(); brn++)
{
if (playerMoving && (*brn)->getID() == 1492 && player != thing || playerMoving && (*brn)->getID() == 1493 && player != thing || playerMoving && (*brn)->getID() == 1494 && player != thing || playerMoving && (*brn)->getID() == 1491 && player != thing || playerMoving && (*brn)->getID() == 1490 && player != thing || playerMoving && (*brn)->getID() == 1487 && player != thing || playerMoving && (*brn)->getID() == 1488 && player != thing || playerMoving && (*brn)->getID() == 1489 && player != thing)
{
player->sendCancel("Nie mozesz popchac gracza na fieldy.");
return;
}
}
}[/CPP]

Have fun.
 
Status
Not open for further replies.
Top