//===============SOURCE CODE REFERENCE=============void mob_add_spotted(struct mob_data *md,uint32 char_id){int i;//Check if char_id is already loggedfor(i =0; i < DAMAGELOG_SIZE; i++){if(md->spotted_log[i]== char_id)return;}//Not logged, add char_id to first empty slotfor(i =0; i < DAMAGELOG_SIZE; i++){if(md->spotted_log[i]==0){
md->spotted_log[i]= char_id;return;}}}//==========CODE I MAKE FROM REFERENCE ABOVEvoid mob_add_atker(struct mob_data *md,uint32 char_id){int i;//Check if char_id is already loggedfor(i =0; i < DAMAGELOG_SIZE; i++){if(md->dmglog[i]== char_id)return;}//Not logged, add char_id to first empty slotfor(i =0; i < DAMAGELOG_SIZE; i++){if(md->dmglog[i]==0){
md->dmglog[i]= char_id;return;}}}
Good day everyone,
I am new and still learning in source code and I want to try to make something for my project using lines from the source code itself.
What I am trying to achieve here is to log char IDs of all those who attacked the monster(MVP). I am focusing this one before proceeding to the next step. Did I make it right?
Thank you so much as always,
EDITED:
Or should I use this one? from pc.ccp
void pc_damage_log_add(map_session_data *sd, int id)
{
uint8 i = 0;
if (!sd || !id)
return;
//Only store new data, don't need to renew the old one with same id
ARR_FIND(0, DAMAGELOG_SIZE_PC, i, sd->dmglog[i] == id);
if (i < DAMAGELOG_SIZE_PC)
return;
for (i = 0; i < DAMAGELOG_SIZE_PC; i++) {
if (sd->dmglog[i] == 0) {
sd->dmglog[i] = id;
return;
}
}
}
Question
namerpus18
Good day everyone,
I am new and still learning in source code and I want to try to make something for my project using lines from the source code itself.
What I am trying to achieve here is to log char IDs of all those who attacked the monster(MVP). I am focusing this one before proceeding to the next step. Did I make it right?
Thank you so much as always,
EDITED:
Or should I use this one? from pc.ccp
void pc_damage_log_add(map_session_data *sd, int id) { uint8 i = 0; if (!sd || !id) return; //Only store new data, don't need to renew the old one with same id ARR_FIND(0, DAMAGELOG_SIZE_PC, i, sd->dmglog[i] == id); if (i < DAMAGELOG_SIZE_PC) return; for (i = 0; i < DAMAGELOG_SIZE_PC; i++) { if (sd->dmglog[i] == 0) { sd->dmglog[i] = id; return; } } }
Link to comment
Share on other sites
10 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.