Crossfire Server, Trunk
ObjectWrapper.cpp
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 2022 the Crossfire Development Team
5  *
6  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7  * welcome to redistribute it under certain conditions. For details, please
8  * see COPYING and LICENSE.
9  *
10  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
11  */
12 
13 #include "ObjectWrapper.h"
14 #include "ResourcesManager.h"
15 #include "CREPixmap.h"
16 
17 ObjectWrapper::ObjectWrapper(AssetWrapper *parent, object *ob, ResourcesManager *resourcesManager) : AssetTWrapper(parent, "empty", ob) {
18  myResourcesManager = resourcesManager;
19 }
20 
22 }
23 
25 {
26  return myResourcesManager->wrap(myWrappedItem->arch, this);
27 }
28 
29 double scale_level(double l) {
30  if (l < 1) {
31  l = 1;
32  }
33  return 10*log(l)+1;
34 }
35 
37  return scale_level(hp()*10/100 + regen()*20/100 + dps()*20/100);
38 }
39 
40 float ObjectWrapper::dps() const {
41  return damage() * FABS(speed()) / MOVE_PER_SECOND;
42 }
43 
44 float ObjectWrapper::regen() const {
45  return con() / 4.0 / MOVE_PER_SECOND;
46 }
47 
49  if (!myWrappedItem->randomitems) {
50  return nullptr;
51  }
53 }
AssetTWrapper< object >::myWrappedItem
object * myWrappedItem
Definition: AssetWrapper.h:104
banquet.l
l
Definition: banquet.py:164
FABS
#define FABS(x)
Definition: define.h:22
log_born.log
log
Definition: log_born.py:28
ObjectWrapper::myResourcesManager
ResourcesManager * myResourcesManager
Definition: ObjectWrapper.h:102
ResourcesManager
Definition: ResourcesManager.h:80
ObjectWrapper::ObjectWrapper
ObjectWrapper(AssetWrapper *parent, object *ob, ResourcesManager *resourcesManager)
Definition: ObjectWrapper.cpp:17
object::arch
struct archetype * arch
Definition: object.h:424
ResourcesManager::wrap
ArchetypeWrapper * wrap(archetype *arch, AssetWrapper *parent)
Definition: ResourcesManager.h:132
guildjoin.ob
ob
Definition: guildjoin.py:42
ObjectWrapper.h
ObjectWrapper::dps
float dps
Definition: ObjectWrapper.h:78
AssetWrapper
Definition: AssetWrapper.h:25
ObjectWrapper::suggested_level
int suggested_level
Definition: ObjectWrapper.h:48
ObjectWrapper::randomItems
QObject randomItems
Definition: ObjectWrapper.h:76
scale_level
double scale_level(double l)
Definition: ObjectWrapper.cpp:29
ResourcesManager.h
ObjectWrapper::regen
float regen
Definition: ObjectWrapper.h:78
ObjectWrapper::~ObjectWrapper
virtual ~ObjectWrapper()
Definition: ObjectWrapper.cpp:21
object::randomitems
struct treasurelist * randomitems
Definition: object.h:395
CREPixmap.h
MOVE_PER_SECOND
static const float MOVE_PER_SECOND
Definition: tod.h:54
ObjectWrapper::arch
QObject arch
Definition: ObjectWrapper.h:73
AssetTWrapper
Definition: AssetWrapper.h:94