d2quest.c 3.43 KB
#include "d2char.h"
#include "d2quest.h"

void getCheckpointDescriptions(unsigned int quest, const char* *descriptions[16]) {
    memcpy(descriptions,(&checkpointDescriptions) + (quest * 16 * sizeof(const char*)), 16 * sizeof(const char*));
}

uint16_t getQuestStatus(D2QuestData* d, unsigned int quest, unsigned int difficulty) {
    if(quest >= D2S_QUEST_DEN_OF_EVIL && quest <= D2S_QUEST_SISTERS_TO_THE_SLAUGHTER) {
        return d->quests[difficulty].actData[D2S_ACT1].questCheckpoints[quest];
    } else if(quest >= D2S_QUEST_RADAMENT_LAIR && quest <= D2S_QUEST_SEVEN_TOMBS) {
        return d->quests[difficulty].actData[D2S_ACT2].questCheckpoints[quest - D2S_QUEST_RADAMENT_LAIR];
    } else if(quest >= D2S_QUEST_GOLDEN_BIRD && quest <= D2S_QUEST_GUARDIAN) {
        return d->quests[difficulty].actData[D2S_ACT3].questCheckpoints[quest - D2S_QUEST_GOLDEN_BIRD];
    } else if(quest >= D2S_QUEST_FALLEN_ANGEL && quest <= D2S_QUEST_TERROR_END) {
        return d->quests[difficulty].actData[D2S_ACT4].questCheckpoints[quest - D2S_QUEST_FALLEN_ANGEL];
    } else if(quest >= D2S_QUEST_SIEGE_ON_HARROGATH && quest <= D2S_QUEST_EVE_OF_DESTRUCTION) {
        return d->quests[difficulty].expansionAct.questCheckpoints[quest - D2S_QUEST_SIEGE_ON_HARROGATH];
    }
    return D2S_QUEST_UNKNOWN;
}

int isQuestStarted(D2QuestData* d, unsigned int quest, unsigned int difficulty) {
    // TODO
    return 0;
}

int isQuestRewardCollected(D2QuestData* d, unsigned int quest, unsigned int difficulty) {
    // TODO
    return 0;
}

int isQuestCompleted(D2QuestData* d, unsigned int quest, unsigned int difficulty) {
    // TODO
    return 0;
}

void setQuestStarted(D2QuestData* d, unsigned int quest, unsigned int difficulty, int bool) {
    // To reset the quest, just zero out the whole thing
    // To set as started, just set the 2nd bit and clear the rest 

    // TODO
}

void setQuestRewardCollected(D2QuestData* d, unsigned int quest, unsigned int difficulty, int bool) {
    // To reset, just clear bit 0 and set bit 1.
    // Do the inverse to set reward as collected (but why whould you tho???)

    // TODO
}

void setQuestCompleted(D2QuestData* d, unsigned int quest, unsigned int difficulty, int bool) {
    // To reset, clear bit 0, bit 12 and bit 13 (13 is kinda optional since it will be cleared by 
    // the game when loading the savegame).
    // To set as completed, just set bit 0 and bit 12 and clear bit 1
    
    // TODO
}

int getSpecialQuestStatus(D2QuestData* d, unsigned int specialQuestState, unsigned int difficulty) {
    int ret = 0;
    switch(specialQuestState) {
        case D2S_SPECIALQUEST_AKARA_RESPEC:
            ret = d->quests[difficulty].akaraRespecData & D2S_QUEST_STATUS_REWARD_AVAILABLE;
        break;
    }
    return ret;
}

void setSpecialQuestStatus(D2QuestData* d, unsigned int specialQuestState, unsigned int difficulty, int bool) {
    switch(specialQuestState) {
        case D2S_SPECIALQUEST_AKARA_RESPEC:
            if(bool) {
                // This operation only makes sense if the quest is actually completed, otherwise ignore request
                if(isQuestCompleted(d,D2S_QUEST_DEN_OF_EVIL,difficulty)) {
                    d->quests[difficulty].akaraRespecData = 0x8001;
                }
            } else {
                // See above comment
                if(isQuestCompleted(d,D2S_QUEST_DEN_OF_EVIL,difficulty)) {
                    d->quests[difficulty].akaraRespecData = 0x2002;
                }
            }
        break;
    }
}