Aleada
Unknown Member
- Joined
- Mar 14, 2013
- Messages
- 231
- Reaction score
- 7
I'm sorry if this sounds very noobish to some but I honestly can not figure out how to add "+" and "-" to damage/healing effects. For example, if you get hit for 24 hitpoints it will say "-24"... Here's what I've written so far but it doesn't work :/
game.cpp
protocolgame.cpp
protocolgame.h
game.cpp
Code:
...
TextMessagemessage;
message.position=targetPos;
message.primary.value=realHealthChange;
message.primary.color=TEXTCOLOR_MAYABLUE;
message.sign="+";
...
message.primary.value=manaDamage;
message.primary.color=TEXTCOLOR_BLUE;
message.sign="-";
...
message.primary.value=damage;
message.sign="-";
addMagicEffect(list,targetPos,hitEffect);
...
protocolgame.cpp
Code:
voidProtocolGame::sendTextMessage(constTextMessage&message)
{
NetworkMessagemsg;
msg.AddByte(0xB4);
msg.AddByte(message.type);
switch(message.type){
caseMESSAGE_DAMAGE_DEALT:
caseMESSAGE_DAMAGE_RECEIVED:
caseMESSAGE_DAMAGE_OTHERS:{
msg.AddPosition(message.position);
msg.add<uint32_t>(message.primary.value);
msg.AddByte(message.primary.color);
msg.add<uint32_t>(message.secondary.value);
msg.AddByte(message.secondary.color);
break;
}
caseMESSAGE_HEALED:
caseMESSAGE_HEALED_OTHERS:
caseMESSAGE_EXPERIENCE:
caseMESSAGE_EXPERIENCE_OTHERS:{
msg.AddPosition(message.position);
msg.add<uint32_t>(message.primary.value);
msg.AddByte(message.primary.color);
break;
}
default:{
break;
}
}
msg.AddString(message.text);
msg.AddString(message.sign);
writeToOutputBuffer(msg);
}
protocolgame.h
Code:
structTextMessage
{
MessageClassestype;
std::stringtext;
std::stringsign;
Positionposition;
struct{
int32_tvalue;
TextColor_tcolor;
}primary,secondary;
TextMessage()
{
primary.value=0;
secondary.value=0;
}
};