Mercurial > sumwars
changeset 5:038918a365d3 branch_net
=zeitabhaengige Effekte quantisiert
author | wuha |
---|---|
date | Mon, 22 Sep 2008 09:47:53 +0000 |
parents | 66b3e9199244 |
children | 7e04df9d6938 |
files | src/core/creature.cpp src/core/dmgprojectile.cpp src/core/event.h src/core/priest.cpp src/core/warrior.cpp src/core/world.cpp src/core/world.h src/gl_gui/network.cpp |
diffstat | 7 files changed, 165 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/creature.cpp Sun Sep 21 21:58:33 2008 +0000 +++ b/src/core/creature.cpp Mon Sep 22 09:47:53 2008 +0000 @@ -2365,15 +2365,17 @@ // besondere zeitabhaengige Effekte berechnen if (getWorld()->isServer()) { - if (m_base_attr_mod.m_special_flags & FLAMEARMOR) + if (m_base_attr_mod.m_special_flags & FLAMEARMOR && getWorld()->timerLimit(2)) { // Flammenruestung - + + // Schaden fuer Flammenruestung setzen Damage d; - d.m_min_damage[Damage::FIRE] = time*m_base_attr_mod.m_magic_power*0.0003; - d.m_max_damage[Damage::FIRE] = time*m_base_attr_mod.m_magic_power*0.0005; + d.m_min_damage[Damage::FIRE] = 500*m_base_attr_mod.m_magic_power*0.0003; + d.m_max_damage[Damage::FIRE] = 500*m_base_attr_mod.m_magic_power*0.0005; d.m_multiplier[Damage::FIRE]=1; + d.m_attacker_fraction = getTypeInfo()->m_fraction; list<ServerWObject*> res; res.clear(); @@ -2407,14 +2409,14 @@ // Statusmods behandeln if (getState()==STATE_ACTIVE) { - if (getWorld()->isServer()) + if (getWorld()->isServer() && getWorld()->timerLimit(2)) { // Vergiftet if (m_dyn_attr.m_status_mod_time[Damage::POISONED]>0) { // Schaden pro Sekunde 1/60 der HP DEBUG5("poisoned"); - m_dyn_attr.m_health -= time*m_base_attr_mod.m_max_health / 60000; + m_dyn_attr.m_health -= 500*m_base_attr_mod.m_max_health / 60000; m_event_mask |= Event::DATA_HP; } @@ -2423,7 +2425,7 @@ { // Schaden pro Sekunde 1/90 der HP (bei 0 Feuerresistenz) DEBUG5("burning"); - m_dyn_attr.m_health -= (100-m_base_attr_mod.m_resistances[Damage::FIRE])*time*m_base_attr_mod.m_max_health / 9000000; + m_dyn_attr.m_health -= (100-m_base_attr_mod.m_resistances[Damage::FIRE])*500*m_base_attr_mod.m_max_health / 9000000; m_event_mask |= Event::DATA_HP; } } @@ -3398,7 +3400,7 @@ if (getState() != STATE_ACTIVE) return; - DEBUG4("take Damage %i",getId()); + DEBUG5("take Damage %i",getId()); // Testen ob der Verursacher des Schadens feindlich gesinnt ist if (getWorld()->getRelation(d->m_attacker_fraction,this) != HOSTILE) { @@ -3599,22 +3601,19 @@ m_base_attr_mod.m_max_health += mod->m_dstrength*5; m_base_attr_mod.m_attack_speed += mod->m_ddexterity*3; - if (mod->m_dmagic_power>0) - { - DEBUG("magic power mod %i",mod->m_dmagic_power); - } + m_base_attr_mod.m_attack_speed +=mod->m_dattack_speed; // Modifikationen feststellen - if (mod->m_dwalk_speed!=0) + if (mod->m_dwalk_speed!=0 ) { m_event_mask |= Event::DATA_WALK_SPEED; } - if (mod->m_dattack_speed !=0) + if (mod->m_dattack_speed !=0 || mod->m_ddexterity!=0) { m_event_mask |= Event::DATA_ATTACK_SPEED; } - if (mod->m_dmax_health !=0) + if (mod->m_dmax_health !=0 || mod->m_dstrength!=0) { m_event_mask |= Event::DATA_MAX_HP; } @@ -3688,11 +3687,11 @@ { m_event_mask |= Event::DATA_WALK_SPEED; } - if (mod->m_dattack_speed !=0) + if (mod->m_dattack_speed !=0 || mod->m_ddexterity!=0) { m_event_mask |= Event::DATA_ATTACK_SPEED; } - if (mod->m_dmax_health !=0) + if (mod->m_dmax_health !=0 || mod->m_dstrength!=0) { m_event_mask |= Event::DATA_MAX_HP; } @@ -4143,6 +4142,7 @@ if (event->m_data & Event::DATA_WALK_SPEED) { + DEBUG("walk changed for %i",getId()); cv->toBuffer(getBaseAttrMod()->m_walk_speed); } @@ -4277,6 +4277,7 @@ if (event->m_data & Event::DATA_WALK_SPEED) { + DEBUG("walk speed changed for %i",getId()); cv->fromBuffer(getBaseAttrMod()->m_walk_speed); }
--- a/src/core/dmgprojectile.cpp Sun Sep 21 21:58:33 2008 +0000 +++ b/src/core/dmgprojectile.cpp Mon Sep 22 09:47:53 2008 +0000 @@ -272,7 +272,7 @@ } } - if (m_type == FIRE_WALL) + if (m_type == FIRE_WALL && m_world->timerLimit(2)) { // Typ Feuersaeule @@ -290,7 +290,7 @@ // Schaden austeilen hit = (*i); float m = m_damage.m_multiplier[Damage::FIRE]; - m_damage.m_multiplier[Damage::FIRE] *= dtime; + m_damage.m_multiplier[Damage::FIRE] *= 500; hit->takeDamage(&m_damage); m_damage.m_multiplier[Damage::FIRE] = m; }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/core/event.h Mon Sep 22 09:47:53 2008 +0000 @@ -0,0 +1,110 @@ +#ifndef EVENT_H +#define EVENT_H + +#include "charconv.h" + +/** + * \struct Event + * \brief beschreibt ein Ereignis in der Spielwelt + */ +struct Event +{ + enum EventType + { + OBJECT_CREATED =1, + OBJECT_DESTROYED = 2, + OBJECT_STAT_CHANGED =3, + + PROJECTILE_CREATED = 5, + PROJECTILE_DESTROYED = 6, + PROJECTILE_STAT_CHANGED = 7, + + PLAYER_JOINED = 10, + PLAYER_QUIT = 11, + PLAYER_CHANGED_REGION = 12, + }; + + /** + * \var EventType m_type + * \brief Gibt die Art des Events an + */ + EventType m_type; + + enum ObjectData + { + DATA_COMMAND =0x1, + DATA_ACTION =0x2, + DATA_HP = 0x4, + DATA_MAX_HP = 0x8, + DATA_EFFECTS = 0x10, + DATA_STATUS_MODS = 0x20, + DATA_TIMER = 0x40, + DATA_STATE = 0x80, + DATA_WALK_SPEED = 0x100, + DATA_ATTACK_SPEED = 0x200, + DATA_NEXT_COMMAND = 0x400, + DATA_ABILITIES = 0x800, + DATA_ATTRIBUTES = 0x1000, + DATA_FLAGS = 0x2000, + DATA_EXPERIENCE=0x4000, + DATA_MOVE_INFO = 0x8000, + DATA_LEVEL = 0x10000, + }; + + enum ProjectileData + { + DATA_GEOMETRY = 0x1, + DATA_SPEED = 0x2, + DATA_PROJ_STATE = 0x4, + DATA_GOAL_OBJECT = 0x8, + DATA_TYPE = 0x10, + DATA_PROJ_TIMER = 0x20, + DATA_MAX_RADIUS = 0x40, + }; + + /** + * \var int m_data + * \brief Bitmaske die angibt welche Daten gesendet werden + */ + int m_data; + + /** + * \var int m_id + * \brief ID des Objektes, das das Ereignis erzeugt hat + */ + int m_id; + + /** + * \fn void toString(CharConv* cv) + * \brief Konvertiert das Objekt in einen String und schreibt ihn in der Puffer + * \param buf Ausgabepuffer + * \return Zeiger hinter den beschriebenen Datenbereich + */ + void toString(CharConv* cv) + { + cv->toBuffer((char) m_type); + cv->toBuffer(m_data); + cv->toBuffer(m_id); + } + + /** + * \fn void fromString(CharConv* cv) + * \brief Erzeugt das Objekt aus einem String + * \param buf Objekt als String + * \return Zeiger hinter den gelesenen Datenbereich + */ + void fromString(CharConv* cv) + { + char ctmp; + cv->fromBuffer(ctmp); + m_type = (EventType) ctmp; + cv->fromBuffer(m_data); + cv->fromBuffer(m_id); + } + +}; + + + +#endif +
--- a/src/core/priest.cpp Sun Sep 21 21:58:33 2008 +0000 +++ b/src/core/priest.cpp Mon Sep 22 09:47:53 2008 +0000 @@ -41,7 +41,7 @@ dyn->m_experience=0; dyn->m_health = 200; - dyn->m_health = 1000; + dyn->m_health = 200; bas->m_max_experience = 100; // bas->m_level =1;
--- a/src/core/warrior.cpp Sun Sep 21 21:58:33 2008 +0000 +++ b/src/core/warrior.cpp Mon Sep 22 09:47:53 2008 +0000 @@ -70,7 +70,7 @@ for (i=1;i<6;i++) bas->m_abilities[i]=0; - bas->m_abilities[0] = 0x3f1f; + bas->m_abilities[0] = 0xffffff; bas->m_attack_range =1; bas->m_special_flags=0;
--- a/src/core/world.cpp Sun Sep 21 21:58:33 2008 +0000 +++ b/src/core/world.cpp Mon Sep 22 09:47:53 2008 +0000 @@ -1157,6 +1157,21 @@ void World::update(float time) { + // Timer weiterzaehlen und Limits feststellen + float timer_max[3]; + timer_max[0] = 250; timer_max[2] = 500; timer_max[3] = 1000; + for (int i=0; i<3; i++) + { + m_timer[i] += time; + m_timer_limit[i] = false; + if (m_timer[i] > timer_max[i]) + { + m_timer[i] -= timer_max[i]; + m_timer_limit[i] = true; + } + } + + m_events->clear(); DEBUG5("update %f",time);
--- a/src/core/world.h Sun Sep 21 21:58:33 2008 +0000 +++ b/src/core/world.h Mon Sep 22 09:47:53 2008 +0000 @@ -495,6 +495,12 @@ { return m_server; } + + bool timerLimit(int i) + { + return m_timer_limit[i]; + } + //Private stuff private: @@ -567,5 +573,17 @@ * \brief Liste der globalen Events beim aktuellen update */ list<Event>* m_events; + + /** + * \var float m_timer[3] + * \brief Timer a 250, 500 und 1000 ms + */ + float m_timer[3]; + + /** + * \var bool m_timer_limit[3] + * \brief ist true, wenn der betreffende Timer gerade in dem Tick abgelaufen ist + */ + bool m_timer_limit[3]; }; #endif //WORLD_H