Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.
Merged
1 change: 1 addition & 0 deletions scripts/zones/Selbina/npcs/Melyon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require("scripts/zones/Selbina/TextIDs");
require("scripts/globals/settings");
require("scripts/globals/keyitems");
require("scripts/globals/quests");
require("scripts/globals/settings");

-----------------------------------
-- onTrade Action
Expand Down
194 changes: 134 additions & 60 deletions sql/item_latents.sql

Large diffs are not rendered by default.

133 changes: 74 additions & 59 deletions src/map/latent_effect.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
===========================================================================

Copyright (c) 2010-2012 Darkstar Dev Teams
Copyright (c) 2010-2014 Darkstar Dev Teams

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -28,12 +28,12 @@

CLatentEffect::CLatentEffect(LATENT conditionsId, uint16 conditionsValue, uint8 slot, uint16 modValue, int16 modPower)
{
m_ConditionsID = conditionsId;
m_ConditionsValue = conditionsValue;
m_SlotID = slot;
m_ModValue = modValue;
m_ModPower = modPower;
m_Activated = false;
m_ConditionsID = conditionsId;
m_ConditionsValue = conditionsValue;
m_SlotID = slot;
m_ModValue = modValue;
m_ModPower = modPower;
m_Activated = false;
}

CLatentEffect::~CLatentEffect()
Expand All @@ -42,114 +42,129 @@ CLatentEffect::~CLatentEffect()

LATENT CLatentEffect::GetConditionsID()
{
return m_ConditionsID;
return m_ConditionsID;
}

uint16 CLatentEffect::GetConditionsValue()
{
return m_ConditionsValue;
return m_ConditionsValue;
}

uint8 CLatentEffect::GetSlot()
{
return m_SlotID;
return m_SlotID;
}

uint16 CLatentEffect::GetModValue()
{
return m_ModValue;
return m_ModValue;
}

int16 CLatentEffect::GetModPower()
{
return m_ModPower;
return m_ModPower;
}

bool CLatentEffect::IsActivated()
{
return m_Activated;
return m_Activated;
}

CBattleEntity* CLatentEffect::GetOwner()
{
return m_POwner;
return m_POwner;
}

void CLatentEffect::SetConditionsId(LATENT id)
{
m_ConditionsID = id;
m_ConditionsID = id;
}

void CLatentEffect::SetConditionsValue(uint16 value)
{
m_ConditionsValue = value;
m_ConditionsValue = value;
}

void CLatentEffect::SetSlot(uint8 slot)
{
m_SlotID = slot;
m_SlotID = slot;
}

void CLatentEffect::SetModValue(uint16 value)
{
m_ModValue = value;
m_ModValue = value;
}

void CLatentEffect::SetModPower(int16 power)
{
m_ModPower = power;
m_ModPower = power;
}

void CLatentEffect::Activate()
{
if( !IsActivated() )
{
//additional effect latents add mod to weapon, not player
if (GetModValue() == MOD_ADDITIONAL_EFFECT)
{
CCharEntity* PChar = (CCharEntity*)m_POwner;
CItemWeapon* weapon = (CItemWeapon*)PChar->getStorage(LOC_INVENTORY)->GetItem(PChar->equip[GetSlot()]);
if( !IsActivated() )
{
//additional effect/dmg latents add mod to weapon, not player
if (GetModValue() == MOD_ADDITIONAL_EFFECT || GetModValue() == MOD_DMG)
{
CCharEntity* PChar = (CCharEntity*)m_POwner;
CItemWeapon* weapon = (CItemWeapon*)PChar->getStorage(LOC_INVENTORY)->GetItem(PChar->equip[GetSlot()]);

weapon->addModifier(new CModifier(MOD_ADDITIONAL_EFFECT, 1));
}
else
{
m_POwner->addModifier(m_ModValue, m_ModPower);
}
weapon->addModifier(new CModifier(GetModValue(), GetModPower()));
}
else
{
m_POwner->addModifier(m_ModValue, m_ModPower);
}

m_Activated = true;
//printf("LATENT ACTIVATED: %d, Current value: %d\n", m_ModValue, m_POwner->getMod(m_ModValue));
}
m_Activated = true;
//printf("LATENT ACTIVATED: %d, Current value: %d\n", m_ModValue, m_POwner->getMod(m_ModValue));
}
}

void CLatentEffect::Deactivate()
{
if( IsActivated() )
{
//remove the modifier from weapon, not player
if (GetModValue() == MOD_ADDITIONAL_EFFECT)
{
CCharEntity* PChar = (CCharEntity*)m_POwner;
CItemWeapon* weapon = (CItemWeapon*)PChar->getStorage(LOC_INVENTORY)->GetItem(PChar->equip[GetSlot()]);

//ensure the additional effect is fully removed from weapon
for (uint8 i = 0; i < weapon->modList.size(); ++i)
{
if (weapon->modList.at(i)->getModID() == MOD_ADDITIONAL_EFFECT)
weapon->modList.at(i)->setModAmount(0);
}
}
else
{
m_POwner->delModifier(m_ModValue, m_ModPower);
}

m_Activated = false;
//printf("LATENT DEACTIVATED: %d\n", m_ModValue);
}
if( IsActivated() )
{
//remove the modifier from weapon, not player
if (GetModValue() == MOD_ADDITIONAL_EFFECT || GetModValue() == MOD_DMG)
{
CCharEntity* PChar = (CCharEntity*)m_POwner;
CItemWeapon* weapon = (CItemWeapon*)PChar->getStorage(LOC_INVENTORY)->GetItem(PChar->equip[GetSlot()]);

int16 modPower = GetModPower();

if (weapon != NULL && (weapon->isType(ITEM_ARMOR) || weapon->isType(ITEM_WEAPON)))
{
if (GetModValue() == MOD_ADDITIONAL_EFFECT)
{
for (uint8 i = 0; i < weapon->modList.size(); ++i)
{
//ensure the additional effect is fully removed from the weapon
if (weapon->modList.at(i)->getModID() == MOD_ADDITIONAL_EFFECT)
{
weapon->modList.at(i)->setModAmount(0);
}
}
}
else
{
weapon->addModifier(new CModifier(GetModValue(), -modPower));
}
}

}
else
{
m_POwner->delModifier(m_ModValue, m_ModPower);
}

m_Activated = false;
//printf("LATENT DEACTIVATED: %d\n", m_ModValue);
}
}

void CLatentEffect::SetOwner(CBattleEntity* Owner)
{
m_POwner = Owner;
m_POwner = Owner;
}
8 changes: 5 additions & 3 deletions src/map/latent_effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ enum LATENT
LATENT_STATUS_EFFECT_ACTIVE = 13, //status effect on player - PARAM: EFFECTID
LATENT_FOOD_ACTIVE = 49, //food effect (foodId) active - PARAM: FOOD ITEMID
LATENT_NO_FOOD_ACTIVE = 14, //no food effects active on player
LATENT_PARTY_MEMBERS = 16, //party has members other than self - PARAM: # OF MEMBERS
LATENT_PARTY_MEMBERS = 15, //party size # - PARAM: # OF MEMBERS
LATENT_PARTY_MEMBERS_IN_ZONE = 16, //party size # and members in zone - PARAM: # OF MEMBERS
LATENT_AVATAR_IN_PARTY = 21, //party has a specific avatar - PARAM: same as globals/pets.lua (21 for any avatar)
LATENT_JOB_IN_PARTY = 22, //party has job - PARAM: JOBTYPE
LATENT_ZONE = 23, //in zone - PARAM: zoneid
Expand All @@ -72,10 +73,11 @@ enum LATENT
LATENT_WEAPON_BROKEN = 47,
LATENT_IN_DYNAMIS = 48,
LATENT_JOB_LEVEL_BELOW = 50, //PARAM: level
LATENT_JOB_LEVEL_ABOVE = 51 //PARAM: level
LATENT_JOB_LEVEL_ABOVE = 51, //PARAM: level
LATENT_WEATHER_ELEMENT = 52 //PARAM: 0: NONE, 1: FIRE, 2: EARTH, 3: WATER, 4: WIND, 5: ICE, 6: THUNDER, 7: LIGHT, 8: DARK
};

#define MAX_LATENTEFFECTID 52
#define MAX_LATENTEFFECTID 53

/************************************************************************
* *
Expand Down
Loading