December 2014 files

This commit is contained in:
Loki Rautio
2026-03-01 11:00:23 -06:00
parent b691c43c44
commit 8fd3ac6e37
2049 changed files with 260190 additions and 134787 deletions

View File

@@ -6,20 +6,31 @@
OwnerHurtByTargetGoal::OwnerHurtByTargetGoal(TamableAnimal *tameAnimal) : TargetGoal(tameAnimal, 32, false)
{
this->tameAnimal = tameAnimal;
timestamp = 0;
setRequiredControlFlags(TargetGoal::TargetFlag);
}
bool OwnerHurtByTargetGoal::canUse()
{
if (!tameAnimal->isTame()) return false;
shared_ptr<Mob> owner = tameAnimal->getOwner();
shared_ptr<LivingEntity> owner = dynamic_pointer_cast<LivingEntity>( tameAnimal->getOwner() );
if (owner == NULL) return false;
ownerLastHurtBy = weak_ptr<Mob>(owner->getLastHurtByMob());
return canAttack(ownerLastHurtBy.lock(), false);
ownerLastHurtBy = weak_ptr<LivingEntity>(owner->getLastHurtByMob());
int ts = owner->getLastHurtByMobTimestamp();
shared_ptr<LivingEntity> locked = ownerLastHurtBy.lock();
return ts != timestamp && canAttack(locked, false) && tameAnimal->wantsToAttack(locked, owner);
}
void OwnerHurtByTargetGoal::start()
{
mob->setTarget(ownerLastHurtBy.lock());
shared_ptr<LivingEntity> owner = dynamic_pointer_cast<LivingEntity>( tameAnimal->getOwner() );
if (owner != NULL)
{
timestamp = owner->getLastHurtByMobTimestamp();
}
TargetGoal::start();
}