From eaa3536c027a4f7c1b879b78ab0ecdefcdb4833d Mon Sep 17 00:00:00 2001 From: fusion32 Date: Sun, 8 Jun 2025 19:54:40 -0300 Subject: impl `TCreature::Move` which was absolute hell + some tidying up --- src/crmain.cc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src/crmain.cc') diff --git a/src/crmain.cc b/src/crmain.cc index 5d0f2f3..00cd3e2 100644 --- a/src/crmain.cc +++ b/src/crmain.cc @@ -226,7 +226,9 @@ TCreature::~TCreature(void){ } if(this->LoseInventory != 0){ // LOSE_INVENTORY_NONE ? - for(int Position = 1; Position <= 10; Position += 1){ + for(int Position = INVENTORY_FIRST; + Position <= INVENTORY_LAST; + Position += 1){ Object Item = GetBodyObject(this->ID, Position); if(Item == NONE){ continue; @@ -238,7 +240,7 @@ TCreature::~TCreature(void){ continue; } - Move(0, Item, Corpse, -1, false, NONE); + ::Move(0, Item, Corpse, -1, false, NONE); } } @@ -487,10 +489,8 @@ int TCreature::Damage(TCreature *Attacker, int Damage, int DamageType){ Damage = 0; } - // NOTE(fusion): We're iterating over the victim's inventory to apply - // damage reductions, while the damage is greater than zero. - for(int Position = 1; - Position <= 10 && Damage > 0; + for(int Position = INVENTORY_FIRST; + Position <= INVENTORY_LAST && Damage > 0; Position += 1){ Object Obj = GetBodyObject(this->ID, Position); if(Obj == NONE){ @@ -739,7 +739,9 @@ int TCreature::Damage(TCreature *Attacker, int Damage, int DamageType){ if(Damage == HitPoints){ if(this->Type == PLAYER){ - for(int Position = 1; Position <= 10; Position += 1){ + for(int Position = INVENTORY_FIRST; + Position <= INVENTORY_LAST; + Position += 1){ Object Obj = GetBodyObject(this->ID, Position); if(Obj == NONE){ continue; @@ -2026,11 +2028,11 @@ void ProcessMonsterRaids(void){ } TCreature *Creature = Spawned[random(0, NumSpawned - 1)]; - Object Bag = GetBodyObject(Creature->ID, 3); // BAG ? + Object Bag = GetBodyObject(Creature->ID, INVENTORY_BAG); if(Bag == NONE){ try{ - Bag = Create(GetBodyContainer(Creature->ID, 3), - GetSpecialObject(INVENTORY_CONTAINER), + Bag = Create(GetBodyContainer(Creature->ID, INVENTORY_BAG), + GetSpecialObject(DEFAULT_CONTAINER), 0); }catch(RESULT r){ error("ProcessMonsterRaids: Exception %d bei Rasse %d" -- cgit v1.2.3