Exemplo n.º 1
0
int16 CBattleEntity::GetRangedWeaponDelay(bool tp)
{
    CItemWeapon* PRange = (CItemWeapon*)m_Weapons[SLOT_RANGED];
    CItemWeapon* PAmmo = (CItemWeapon*)m_Weapons[SLOT_AMMO];

    // base delay
    int delay = 240;

    if (PRange != nullptr && PRange->getDamage() != 0) {
        delay += ((PRange->getDelay() * 60) / 1000);
    }

    if (PAmmo != nullptr && PAmmo->isThrowing())
    {
        // this is a throwing weapon
        delay += ((PAmmo->getDelay() * 60) / 1000);
    }

    delay = (((delay - getMod(MOD_RANGED_DELAY)) * 1000) / 110);

    //apply haste and delay reductions that don't affect tp
    if (!tp)
    {
        delay = delay * ((float)(100 + getMod(MOD_RANGED_DELAYP)) / 100);
    }
    else {

        if (PAmmo != nullptr && PAmmo->getDamage() != 0 && !PAmmo->isThrowing()) {
            delay += ((PAmmo->getDelay() * 60) / 1000);
        }
    }
    return delay;
}
int DnDCharacter::makeSave(QString type, QString, int bonus){
    if(type == "will")
        return die->roll() + getMod("wisdom")+ getValue(type).toInt() + bonus;
    else if(type == "fortitude")
        return die->roll() + getMod("constitution") + getValue(type).toInt() + bonus;
    else
        return die->roll() + getMod("dexterity") + getValue(type).toInt() + bonus;
}
int DnDCharacter::makeRoll(QString type, QString mod, int bonus){
    if(type == "attack")
        return makeAttack(type, mod,bonus);
    else if(type == "will" || type == "fortitude" || type == "reflex")
        return makeSave(type,mod,bonus);
    else if(type == "None")
        return die->roll() + getMod(mod) + bonus;
    else
        return die->roll() + getValue(type).toInt() + getMod(mod) + bonus;
}
Exemplo n.º 4
0
uint16 CBattleEntity::GetRangedWeaponDmg()
{
    uint16 dmg = 0;
    if (m_Weapons[SLOT_RANGED])
    {
        if ((m_Weapons[SLOT_RANGED]->getReqLvl() > GetMLevel()) && objtype == TYPE_PC)
        {
            uint16 scaleddmg = m_Weapons[SLOT_RANGED]->getDamage();
            scaleddmg *= GetMLevel() * 3;
            scaleddmg /= 4;
            scaleddmg /= m_Weapons[SLOT_RANGED]->getReqLvl();
            dmg += scaleddmg;
        }
        else
            dmg += m_Weapons[SLOT_RANGED]->getDamage();
    }
    if (m_Weapons[SLOT_AMMO])
    {
        if ((m_Weapons[SLOT_AMMO]->getReqLvl() > GetMLevel()) && objtype == TYPE_PC)
        {
            uint16 scaleddmg = m_Weapons[SLOT_AMMO]->getDamage();
            scaleddmg *= GetMLevel() * 3;
            scaleddmg /= 4;
            scaleddmg /= m_Weapons[SLOT_AMMO]->getReqLvl();
            dmg += scaleddmg;
        }
        else
            dmg += m_Weapons[SLOT_AMMO]->getDamage();
    }
    return dmg + getMod(MOD_RANGED_DMG_RATING);
}
Exemplo n.º 5
0
/* -------------------------------------------------------------------- */
void verbosebaud(void)
{
    char c, f = 0;
    long t;

    if (debug)
        outCon('[');

    t = cit_timer();

    while (gotCarrier() && cit_timer() < (t + 6) && !KBReady()) {
        if (MIReady()) {
            c = (char) getMod();
        } else {
            c = 0;
        }

        if (debug && c) {
            outCon(c);
        }
        if (f) {
            switch (c) {
                case '\n':
                case '\r':      /* CONNECT */
                    baud(0);
                    if (debug)
                        outCon(']');
                    return;
                case '1':       /* CONNECT 1200 */
                    baud(1);
                    if (debug)
                        outCon(']');
                    return;
                case '2':       /* CONNECT 2400 */
                    baud(2);
                    if (debug)
                        outCon(']');
                    return;
                case '4':       /* CONNECT 4800 */
                    baud(3);
                    if (debug)
                        outCon(']');
                    return;
                case '9':       /* CONNECT 9600 */
                    baud(4);
                    if (debug)
                        outCon(']');
                    return;
                default:
                    break;
            }
        }
        if (c == 'C') {
            if (debug) {
                outCon('@');
            }
            f = 1;
        }
    }
}
Exemplo n.º 6
0
void greeting(void)
{
    int messages;
    char dtstr[80];

    if (loggedIn)
        terminate(FALSE, FALSE);
    echo = BOTH;

    setdefaultconfig();
    initroomgen();
    cleargroupgen();
    if (cfg.accounting)
        unlogthisAccount();

    delay(100);

    if (newCarrier)
        hello();

    mPrintf("\n Welcome to %s, %s", cfg.nodeTitle, cfg.nodeRegion);
    mPrintf("\n Running %s v%s", softname, version);
# ifdef ALPHA_TEST
    mPrintf("\n Alpha Test Site");
# endif
# ifdef BETA_TEST
    mPrintf("\n Beta Test Site");
# endif
#ifdef FLOPPY
	mPrintf("\n Floppy edition");
#endif
    doCR();
    doCR();

    cit_strftime(dtstr, 79, cfg.vdatestamp, 0L);
    mPrintf(" %s", dtstr);

    if (!cfg.forcelogin) {
        mPrintf("\n H for Help");
        mPrintf("\n ? for Menu");
        mPrintf("\n L to Login");
    }
    getRoom(LOBBY);

    messages = talleyBuf.room[thisRoom].messages;

    doCR();

    mPrintf("  %d %s ", messages,
    (messages == 1) ? "message" : "messages");

    doCR();

    while (MIReady())
        getMod();
    logBuf.linesScreen = 23;
}
Exemplo n.º 7
0
uint16 CBattleEntity::GetRangedWeaponRank()
{
    if (m_Weapons[SLOT_RANGED])
    {
        return (m_Weapons[SLOT_RANGED]->getDamage() + getMod(MOD_RANGED_DMG_RANK)) / 9;
    }
    //Unhandled Scenario
    DSP_DEBUG_BREAK_IF(true);
    return 0;
}
Exemplo n.º 8
0
uint16 CBattleEntity::GetSubWeaponDmg()
{
    if (m_Weapons[SLOT_SUB])
    {
        if ((m_Weapons[SLOT_SUB]->getReqLvl() > GetMLevel()) && objtype == TYPE_PC)
        {
            uint16 dmg = m_Weapons[SLOT_SUB]->getDamage();
            dmg *= GetMLevel() * 3;
            dmg /= 4;
            dmg /= m_Weapons[SLOT_SUB]->getReqLvl();
            return dmg + getMod(MOD_SUB_DMG_RATING);
        }
        else
            return m_Weapons[SLOT_SUB]->getDamage() + getMod(MOD_SUB_DMG_RATING);
    }
    //Unhandled Scenario
    DSP_DEBUG_BREAK_IF(true);
    return 0;
}
Exemplo n.º 9
0
uint16 CBattleEntity::RACC(uint8 skill, uint16 bonusSkill)
{
    int skill_level = GetSkill(skill) + bonusSkill;
    uint16 acc = skill_level;
    if (skill_level > 200)
    {
        acc = 200 + (skill_level - 200)*0.9;
    }
    acc += getMod(MOD_RACC);
    acc += battleutils::GetRangedAccuracyBonuses(this);
    acc += AGI() / 2;
    if (this->objtype == TYPE_PET && ((CPetEntity*)this)->getPetType() == PETTYPE_AUTOMATON)
    {
        acc += ((CCharEntity*)PMaster)->PMeritPoints->GetMeritValue(MERIT_FINE_TUNING, (CCharEntity*)PMaster);
    }

    return ((100 + getMod(MOD_RACCP)) * acc) / 100 +
        dsp_min(((100 + getMod(MOD_FOOD_RACCP)) * acc) / 100, getMod(MOD_FOOD_RACC_CAP));
}
Exemplo n.º 10
0
int16 CBattleEntity::GetWeaponDelay(bool tp)
{
    if (StatusEffectContainer->HasStatusEffect(EFFECT_HUNDRED_FISTS) && !tp)
    {
        return 1700;
    }
    uint16 MinimumDelay = m_Weapons[SLOT_MAIN]->getDelay(); // Track base delay.  We will need this later.  MOD_DELAY is ignored for now.
    uint16 WeaponDelay = m_Weapons[SLOT_MAIN]->getDelay() - getMod(MOD_DELAY);
    if (m_Weapons[SLOT_MAIN]->getSkillType() == SKILL_H2H)
    {
        if (!StatusEffectContainer->HasStatusEffect(EFFECT_FOOTWORK))
        {
            WeaponDelay -= getMod(MOD_MARTIAL_ARTS) * 1000 / 60;
        }
    }
    else if (m_Weapons[SLOT_SUB]->getDmgType() > 0 &&
             m_Weapons[SLOT_SUB]->getDmgType() < 4)
    {
        MinimumDelay += m_Weapons[SLOT_SUB]->getDelay();
        WeaponDelay += m_Weapons[SLOT_SUB]->getDelay();
        //apply dual wield delay reduction
        WeaponDelay = WeaponDelay * ((100.0f - (float)getMod(MOD_DUAL_WIELD)) / 100.0f);
    }

    //apply haste and delay reductions that don't affect tp
    if (!tp)
    {
        // Cap haste at appropriate levels.
        int16 hasteMagic = (getMod(MOD_HASTE_MAGIC) > 448) ? 448 : getMod(MOD_HASTE_MAGIC);
        int16 hasteAbility = (getMod(MOD_HASTE_ABILITY) > 256) ? 256 : getMod(MOD_HASTE_ABILITY);
        int16 hasteGear = (getMod(MOD_HASTE_GEAR) > 256) ? 256 : getMod(MOD_HASTE_GEAR);
        WeaponDelay = WeaponDelay * ((float)(1024 - hasteMagic - hasteAbility - hasteGear) / 1024);
    }
    WeaponDelay = WeaponDelay * ((float)(100 + getMod(MOD_DELAYP)) / 100);

    // Global delay reduction cap of "about 80%" being enforced.
    // This should be enforced on -delay equipment, martial arts, dual wield, and haste, hence MinimumDelay * 0.2.
    // TODO: Could be converted to value/1024 if the exact cap is ever determined.
    MinimumDelay -= (MinimumDelay * 0.8);
    WeaponDelay = (WeaponDelay < MinimumDelay) ? MinimumDelay : WeaponDelay;
    return WeaponDelay;
}
Exemplo n.º 11
0
long long getMod(long long a, long long b) {
	if (b == 1) {
		return a;
	}
	long long ans = getMod(a, b / 2);
	ans = (ans * ans) % p_1;
	if (b % 2 == 1) {
		ans = (ans * a) % p_1;
	}
	return ans;
}
Exemplo n.º 12
0
/* -------------------------------------------------------------------- */
BOOL checkCR(void)
{
    int i;

    for (i = 0; i < 50; i++)
    {
        pause(1);
        if (MIReady()) if (getMod() == '\r') return FALSE;
    }
    return TRUE;
}
Exemplo n.º 13
0
        /// @brief Returns an unique color based of `mStr`'s hash.
        inline const auto& getUniqueColor(const std::string& mStr)
        {
            static std::unordered_map<std::string, Console::Color> map;

            if(map.count(mStr) == 0)
            {
                static int lastColorIdx{2};
                map[mStr] = Console::Color(getMod(lastColorIdx++, 2, 7));
            }

            return Console::setColorFG(map[mStr]);
        }
Exemplo n.º 14
0
void CBattleEntity::UpdateHealth()
{
    int32 dif = (getMod(MOD_CONVMPTOHP) - getMod(MOD_CONVHPTOMP));

    health.modmp = ((health.maxmp) * (100 + getMod(MOD_MPP)) / 100) + dsp_min((health.maxmp * m_modStat[MOD_FOOD_MPP] / 100), m_modStat[MOD_FOOD_MP_CAP]) + getMod(MOD_MP);
    health.modhp = ((health.maxhp) * (100 + getMod(MOD_HPP)) / 100) + dsp_min((health.maxhp * m_modStat[MOD_FOOD_HPP] / 100), m_modStat[MOD_FOOD_HP_CAP]) + getMod(MOD_HP);

    dif = (health.modmp - 0) < dif ? (health.modmp - 0) : dif;
    dif = (health.modhp - 1) < -dif ? -(health.modhp - 1) : dif;

    health.modhp += dif;
    health.modmp -= dif;

    if (objtype == TYPE_PC)
    {
        health.modhp = dsp_cap(health.modhp, 0, 9999);
        health.modmp = dsp_cap(health.modmp, 0, 9999);
    }

    health.hp = dsp_cap(health.hp, 0, health.modhp);
    health.mp = dsp_cap(health.mp, 0, health.modmp);

    updatemask |= UPDATE_HP;
}
Exemplo n.º 15
0
QStringList CModList::getRequirements(QString modname)
{
	QStringList ret;

	if (hasMod(modname))
	{
		auto mod = getMod(modname);

		for (auto entry : mod.getValue("depends").toStringList())
			ret += getRequirements(entry);
	}
	ret += modname;

	return ret;
}
Exemplo n.º 16
0
/* -------------------------------------------------------------------- */
int findbaud(void)
{
    char noGood = TRUE;
    int  Time = 0;
    int  baudRunner;                    /* Only try for 60 seconds      */

    while (MIReady())   getMod();               /* Clear garbage        */
    baudRunner = 0;
    while (gotCarrier() && noGood && Time < 120)
    {
        Time++;
        baud(baudRunner);
        noGood = checkCR();
        if (noGood) baudRunner = (baudRunner + 1) % (3 /* 2400 too */);
    }
    return !noGood;
}
Exemplo n.º 17
0
int16 CBattleEntity::GetAmmoDelay(bool tp)
{
    CItemWeapon* PAmmo = (CItemWeapon*)m_Weapons[SLOT_AMMO];

    int delay = 240;
    if (PAmmo != nullptr && PAmmo->getDamage() != 0) {
        delay += ((PAmmo->getDelay() * 60) / 1000);
    }

    delay = (((delay - getMod(MOD_RANGED_DELAY)) * 1000) / 110);
    //don't think delay reduction affects cooldown time
    //if (!tp)
    //{
    //	delay = delay * ((float)(100 + getMod(MOD_RANGED_DELAYP))/100);
    //}
    return delay;
}
Exemplo n.º 18
0
int main() {
	while (scanf("%I64d%I64d", &p_1, &a_1) != EOF) {
		if (!p_1 && !a_1) {
			break;
		}
		if (isPrime(p_1)) {
			printf("no\n");
		}
		else {
			long long ans = getMod(a_1, p_1);
			if (ans == a_1) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}
	return 0;
}
Exemplo n.º 19
0
void CBattleEntity::UpdateHealth()
{
    int32 dif = (getMod(MOD_CONVMPTOHP) - getMod(MOD_CONVHPTOMP));

    health.modmp = ((health.maxmp + getMod(MOD_MP)) * (100 + getMod(MOD_MPP)) / 100) + dsp_min((health.maxmp * m_modStat[MOD_FOOD_MPP] / 100), m_modStat[MOD_FOOD_MP_CAP]);
    health.modhp = ((health.maxhp + getMod(MOD_HP)) * (100 + getMod(MOD_HPP)) / 100) + dsp_min((health.maxhp * m_modStat[MOD_FOOD_HPP] / 100), m_modStat[MOD_FOOD_HP_CAP]);

    dif = (health.modmp - 0) <  dif ?  (health.modmp - 0) : dif;
    dif = (health.modhp - 1) < -dif ? -(health.modhp - 1) : dif;

    health.modhp += dif;
    health.modmp -= dif;

    health.hp = dsp_cap(health.hp, 0, health.modhp);
    health.mp = dsp_cap(health.mp, 0, health.modmp);
}
Exemplo n.º 20
0
/* -------------------------------------------------------------------- */
int getModStr(char *str)
{
    long tm;
    int l = 0, c;

    tm = cit_timer();

    if (debug)
        cPrintf("[");

    while (
        (cit_timer() - tm) < 4
        && !KBReady()
        && l < 40
    ) {
        if (MIReady()) {
            c = getMod();

            if (c == 13 || c == 10) {   /* CR || LF */
                str[l] = EOS;
                if (debug)
                    cPrintf("]\n");
                return TRUE;
            } else {
                if (debug)
                    cPrintf("%c", c);
                str[l] = (char) c;
                l++;
            }
        }
    }

    if (debug)
        cPrintf(":F]\n");

    str[0] = EOS;

    return FALSE;
}
Exemplo n.º 21
0
/* -------------------------------------------------------------------- */
int getModStr(char *str)
{
    long tm;
    int  l = 0, c;

    time(&tm);

    if (debug) cPrintf("[");

    while (
             (time(NULL) - tm) < 4 
          && !KBReady() 
          && l < 40 
          )
    {
        if (MIReady())
        {
            c = getMod();

            if (c == 13 || c == 10) /* CR || LF */
            {
                str[l] = NULL;
                if (debug) cPrintf("]\n");
                return TRUE;
            }else{
                if (debug) cPrintf("%c", c);
                str[l] = (char)c;
                l++;
            }
        }
    }

    if (debug) cPrintf(":F]\n");

    str[0] = NULL;

    return FALSE;
}
Exemplo n.º 22
0
KeyCombi::KeyCombi(std::wstring text)
	: _mods(0), _key(0)
{
	std::wstringstream ss(text);
	std::wstring part;
	while (std::getline(ss, part, L' '))
	{
		std::transform(std::begin(part), std::end(part), std::begin(part), ::tolower);
		trim(part);
		unsigned char gmod = 0;
		unsigned char gk = 0;
		if( getMod(part, gmod) )
		{
			_mods += gmod;
		}
		else if( getKey(part, gk) )
		{
			_key = gk;
			_keystr = part;
			_keystr[0] = ::toupper(_keystr[0]);
		}
	}
}
Exemplo n.º 23
0
/* -------------------------------------------------------------------- */
BOOL dc15network(BOOL master)
{
    char line[100], line2[100];
    label here, there;
    FILE *file;
    int i, rms;
    time_t t, t2=0;
    BOOL    done = FALSE;
    
    netFailed = FALSE;
    
    if (!gotCarrier()) return FALSE;

    sprintf(line, "%s\\mesg.tmp", cfg.temppath);
    unlink(line);
    
    sprintf(line, "%s\\mailin.tmp", cfg.temppath);
    unlink(line);

    sprintf(line, "%s\\roomreq.in", cfg.temppath);
    unlink(line);
    
    sprintf(line, "%s\\roomreq.out", cfg.temppath);
    unlink(line);

    if((file = fopen(line, "ab")) == NULL)
    {
        perror("Error opening roomreq.out");
        return FALSE;
    }

    for (i=get_first_room(here, there), rms=0;
         i;
         i=get_next_room(here, there), rms++)
    {
        PutStr(file, there);
    }

    PutStr(file, "");
    fclose(file);

    if (master)
    {
        sendRequest();
        if (!gotCarrier()) return FALSE;
        reciveRequest();
    }
    else
    {
        reciveRequest();
        if (!gotCarrier()) return FALSE;
        sendRequest();
    }
    
    if (!gotCarrier() || netFailed) return FALSE;
    
    if (master)
    {
        /* clear the buffer */
        while (gotCarrier() && MIReady())
        {
            getMod();
        }
    }
    
    makeSendFile();
    
    if (!gotCarrier() || netFailed) return FALSE;
        
    /*
     * wait for them to get their shit together 
     */
    cPrintf(" Waiting for transfer.");
    
    outMod('X');
    t2 = 0;
    t = time(NULL); 
    while (gotCarrier() && !done)
    {
        if (time(NULL) > (t + (35 * 60))) /* only wait 35 minutes */
        {
            drop_dtr();
            netFailed = TRUE;
        }
        
        if (MIReady())
        {
            i = getMod();
            if (i == 'X' || node.network != NET_DCIT16)
            {
                done = TRUE;
            }
            else
            {
                if (debug)
                {
                    cPrintf("<%c>", i);
                }
            }
                
        }
        
        /* wake them up! (every second) */
        if (time(NULL) != t2)
        {
            outMod('X');
            t2 = time(NULL);
        }
    }
    
    /* wake them up! */
    for (i=0; i<10; i++)
        outMod('X');
    
    doccr();

    if (!gotCarrier() || netFailed) return FALSE;

    if (master)
    {
        reciveFiles();
        if (!gotCarrier() || netFailed) return FALSE;
        sendFiles();
    }
    else
    {
        sendFiles();
        if (!gotCarrier() || netFailed) return FALSE;
        reciveFiles();
    }
    
    if (netFailed) return FALSE;
    
    cPrintf(" Hangup.");
    doccr();
    
    drop_dtr();

    cPrintf(" Uncompressing message files.");
    doccr();
         
    sformat(line, node.unzip, "d", roomdatain);
    apsystem(line);
         
    unlink(roomdatain);
    
    for (i=0; i<rms; i++)
    {
        sprintf(line,  "room.%d",   i);
        sprintf(line2, "roomin.%d", i);
        rename(line, line2);
    }
        
    sprintf(line,  "%s\\mesg.tmp",   cfg.temppath);
    sprintf(line2, "%s\\mailin.tmp", cfg.temppath);
    rename(line, line2);

    return TRUE;
}
Exemplo n.º 24
0
uint8 CBattleEntity::GetSpeed()
{
    return (animation == ANIMATION_CHOCOBO ? 40 + map_config.speed_mod : dsp_cap(speed * (100 + getMod(MOD_MOVE)) / 100, UINT8_MIN, UINT8_MAX));
}
Exemplo n.º 25
0
 int getModKey() const { return m_key | getMod(); }
Exemplo n.º 26
0
bool CBattleEntity::CanRest()
{
    return !getMod(MOD_REGEN_DOWN) && !StatusEffectContainer->HasStatusEffectByFlag(EFFECTFLAG_NO_REST);
}
Exemplo n.º 27
0
/* -------------------------------------------------------------------- */
int editText(char *buf, int lim)
{
    char ch, x;
    FILE *fd;
    int eom;

    dowhat = PROMPT;

    do {
        outFlag = IMPERVIOUS;
        while (MIReady())   /* flush modem input buffer */
            getMod();
		doCR();
		strcpy(gprompt,"Entry command:");	/* in case of ^A? */
        mtPrintf(TERM_REVERSE,gprompt);
		mPrintf(" ");
        switch (ch = (char) toupper(iChar())) {
            case 'A':
                mPrintf("\bAbort\n ");
                if (strblank(buf))
                    return FALSE;
                else if (getYesNo(confirm, 0)) {
                    heldMessage = TRUE;

                    memcpy(msgBuf2, msgBuf, sizeof(struct msgB));

                    dowhat = DUNO;
                    return FALSE;
                }
                break;
            case 'C':
                mPrintf("\bContinue");
				/* dump message to display */
				outFlag = IMPERVIOUS;
                doCR();
                putheader();
                doCR();
				outFlag = OUTOK;
                mFormat(buf);
                doBS();
                eom = strlen(buf);
                if (eom > 0)
                    buf[eom - 1] = '\0';    /* zap last character ('\n') */
				outFlag = IMPERVIOUS;
                return ERROR;				/* to return to this routine */
            case 'F':
                mPrintf("\bFind & Replace text\n ");
                replaceString(buf, lim, TRUE);
                break;
            case 'P':
                mPrintf("\bPrint formatted\n ");
                doCR();
				outFlag = IMPERVIOUS;
                putheader();
                doCR();
				outFlag = OUTOK;
                mFormat(buf);
                termCap(TERM_NORMAL);
                doCR();
                break;
            case 'R':
                mPrintf("\bReplace text\n ");
                replaceString(buf, lim, FALSE);
                break;
            case 'S':
                mPrintf("\bSave buffer\n ");
                entered++;      /* increment # messages entered */
                dowhat = DUNO;
                return TRUE;
            case 'W':
                mPrintf("\bWord count\n ");
                wordcount(buf);
                break;
            case '?':
                nextmenu("edit", &(cfg.cnt.edittut), 1);
                break;
            default:
                if ((x = (char) strpos((char) tolower(ch), editcmd)) != 0) {
                    x--;
                    mPrintf("\b%s", edit[x].ed_name);
                    doCR();
                    if (edit[x].ed_local && !onConsole) {
                        mPrintf("\n Local editor only!\n ");
                    } else {
                        changedir(cfg.aplpath);
                        if ((fd = fopen("message.apl", "wb")) != NULL) {
                            xPutStr(fd, msgBuf->mbtext);
                            fclose(fd);
                        }
                        readMessage = FALSE;
                        extFmtRun(edit[x].ed_cmd, "message.apl");
                        changedir(cfg.aplpath);
                        if ((fd = fopen("message.apl", "rb")) != NULL) {
                            GetStr(fd, msgBuf->mbtext, cfg.maxtext);
                            fclose(fd);
                            unlink("message.apl");
                        }
                    }
                    break;
                }
                if (!gl_user.expert)
                    nextmenu("edit", &(cfg.cnt.edittut), 1);
                else
                    mPrintf("\n '?' for menu.\n \n");
                break;
        }
    } while (!ExitToMsdos && (haveCarrier || onConsole));
    dowhat = DUNO;
    return FALSE;
}
Exemplo n.º 28
0
LRESULT CALLBACK Win32Loop::processEvent( HWND hwnd, UINT msg,
                                          WPARAM wParam, LPARAM lParam )
{
    Win32Factory *pFactory =
        (Win32Factory*)Win32Factory::instance( getIntf() );
    GenericWindow *pWin = pFactory->m_windowMap[hwnd];

    GenericWindow &win = *pWin;
    switch( msg )
    {
        case WM_PAINT:
        {
            PAINTSTRUCT Infos;
            BeginPaint( hwnd, &Infos );
            EvtRefresh evt( getIntf(),
                            Infos.rcPaint.left,
                            Infos.rcPaint.top,
                            Infos.rcPaint.right - Infos.rcPaint.left + 1,
                            Infos.rcPaint.bottom - Infos.rcPaint.top + 1 );
            win.processEvent( evt );
            EndPaint( hwnd, &Infos );
            return 0;
        }
        case WM_COMMAND:
        {
            EvtMenu evt( getIntf(), LOWORD( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_MOUSEMOVE:
        {
            // Needed to generate WM_MOUSELEAVE events
            TRACKMOUSEEVENT TrackEvent;
            TrackEvent.cbSize      = sizeof( TRACKMOUSEEVENT );
            TrackEvent.dwFlags     = TME_LEAVE;
            TrackEvent.hwndTrack   = hwnd;
            TrackEvent.dwHoverTime = 1;
            TrackMouseEvent( &TrackEvent );

            // Compute the absolute position of the mouse
            int x = GET_X_LPARAM( lParam ) + win.getLeft();
            int y = GET_Y_LPARAM( lParam ) + win.getTop();
            EvtMotion evt( getIntf(), x, y );
            win.processEvent( evt );
            return 0;
        }
        case WM_MOUSELEAVE:
        {
            EvtLeave evt( getIntf() );
            win.processEvent( evt );
            return 0;
        }
        case WM_MOUSEWHEEL:
        {
            int x = GET_X_LPARAM( lParam ) - win.getLeft();
            int y = GET_Y_LPARAM( lParam ) - win.getTop();
            int mod = getMod( wParam );
            if( GET_WHEEL_DELTA_WPARAM( wParam ) > 0 )
            {
                EvtScroll evt( getIntf(), x, y, EvtScroll::kUp, mod );
                win.processEvent( evt );
            }
            else
            {
                EvtScroll evt( getIntf(), x, y, EvtScroll::kDown, mod );
                win.processEvent( evt );
            }
            return 0;
        }
        case WM_LBUTTONDOWN:
        {
            SetCapture( hwnd );
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kLeft,
                          EvtMouse::kDown, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_RBUTTONDOWN:
        {
            SetCapture( hwnd );
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kRight,
                          EvtMouse::kDown, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_LBUTTONUP:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kLeft,
                          EvtMouse::kUp, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_RBUTTONUP:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kRight,
                          EvtMouse::kUp, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_LBUTTONDBLCLK:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kLeft,
                          EvtMouse::kDblClick, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_RBUTTONDBLCLK:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( lParam ),
                          GET_Y_LPARAM( lParam ), EvtMouse::kRight,
                          EvtMouse::kDblClick, getMod( wParam ) );
            win.processEvent( evt );
            return 0;
        }
        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
        case WM_KEYUP:
        case WM_SYSKEYUP:
        {
            // The key events are first processed here and not translated
            // into WM_CHAR events because we need to know the status of
            // the modifier keys.

            // Get VLC key code from the virtual key code
            int key = virtKeyToVlcKey[wParam];
            if( !key )
            {
                // This appears to be a "normal" (ascii) key
                key = tolower( (unsigned char)MapVirtualKey( wParam, 2 ) );
            }

            if( key )
            {
                // Get the modifier
                int mod = 0;
                if( GetKeyState( VK_CONTROL ) & 0x8000 )
                {
                    mod |= EvtInput::kModCtrl;
                }
                if( GetKeyState( VK_SHIFT ) & 0x8000 )
                {
                    mod |= EvtInput::kModShift;
                }
                if( GetKeyState( VK_MENU ) & 0x8000 )
                {
                    mod |= EvtInput::kModAlt;
                }

                // Get the state
                EvtKey::ActionType_t state;
                if( msg == WM_KEYDOWN ||
                    msg == WM_SYSKEYDOWN )
                {
                    state = EvtKey::kDown;
                }
                else
                {
                    state = EvtKey::kUp;
                }

                EvtKey evt( getIntf(), key, state, mod );
                win.processEvent( evt );
            }
            return 0;
        }
        default:
            break;
    }
    return DefWindowProc( hwnd, msg, wParam, lParam );;
}
Exemplo n.º 29
0
void Win32Loop::run()
{
    MSG msg;

    // Compute windows message list
    while( GetMessage( &msg, NULL, 0, 0 ) )
    {
        Win32Factory *pFactory =
            (Win32Factory*)Win32Factory::instance( getIntf() );
        GenericWindow *pWin = pFactory->m_windowMap[msg.hwnd];
        if( pWin == NULL )
        {
            // We are probably getting a message for a tooltip (which has no
            // associated GenericWindow), for a timer, or for the parent window
            DispatchMessage( &msg );
            continue;
        }

        GenericWindow &win = *pWin;
        switch( msg.message )
        {
        case WM_PAINT:
        {
            PAINTSTRUCT Infos;
            BeginPaint( msg.hwnd, &Infos );
            EvtRefresh evt( getIntf(),
                            Infos.rcPaint.left,
                            Infos.rcPaint.top,
                            Infos.rcPaint.right - Infos.rcPaint.left + 1,
                            Infos.rcPaint.bottom - Infos.rcPaint.top + 1 );
            EndPaint( msg.hwnd, &Infos );
            win.processEvent( evt );
            break;
        }
        case WM_COMMAND:
        {
            EvtMenu evt( getIntf(), LOWORD( msg.wParam ) );
            win.processEvent( evt );
            break;
        }
        case WM_MOUSEMOVE:
        {
            // Needed to generate WM_MOUSELEAVE events
            TRACKMOUSEEVENT TrackEvent;
            TrackEvent.cbSize      = sizeof( TRACKMOUSEEVENT );
            TrackEvent.dwFlags     = TME_LEAVE;
            TrackEvent.hwndTrack   = msg.hwnd;
            TrackEvent.dwHoverTime = 1;
            TrackMouseEvent( &TrackEvent );

            // Compute the absolute position of the mouse
            int x = GET_X_LPARAM( msg.lParam ) + win.getLeft();
            int y = GET_Y_LPARAM( msg.lParam ) + win.getTop();
            EvtMotion evt( getIntf(), x, y );
            win.processEvent( evt );
            break;
        }
        case WM_MOUSELEAVE:
        {
            EvtLeave evt( getIntf() );
            win.processEvent( evt );
            break;
        }
        case WM_MOUSEWHEEL:
        {
            int x = GET_X_LPARAM( msg.lParam ) - win.getLeft();
            int y = GET_Y_LPARAM( msg.lParam ) - win.getTop();
            int mod = getMod( msg.wParam );
            if( GET_WHEEL_DELTA_WPARAM( msg.wParam ) > 0 )
            {
                EvtScroll evt( getIntf(), x, y, EvtScroll::kUp, mod );
                win.processEvent( evt );
            }
            else
            {
                EvtScroll evt( getIntf(), x, y, EvtScroll::kDown, mod );
                win.processEvent( evt );
            }
            break;
        }
        case WM_LBUTTONDOWN:
        {
            SetCapture( msg.hwnd );
            EvtMouse evt( getIntf(), GET_X_LPARAM( msg.lParam ),
                          GET_Y_LPARAM( msg.lParam ), EvtMouse::kLeft,
                          EvtMouse::kDown, getMod( msg.wParam ) );
            win.processEvent( evt );
            break;
        }
        case WM_RBUTTONDOWN:
        {
            SetCapture( msg.hwnd );
            EvtMouse evt( getIntf(), GET_X_LPARAM( msg.lParam ),
                          GET_Y_LPARAM( msg.lParam ), EvtMouse::kRight,
                          EvtMouse::kDown, getMod( msg.wParam ) );
            win.processEvent( evt );
            break;
        }
        case WM_LBUTTONUP:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( msg.lParam ),
                          GET_Y_LPARAM( msg.lParam ), EvtMouse::kLeft,
                          EvtMouse::kUp, getMod( msg.wParam ) );
            win.processEvent( evt );
            break;
        }
        case WM_RBUTTONUP:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( msg.lParam ),
                          GET_Y_LPARAM( msg.lParam ), EvtMouse::kRight,
                          EvtMouse::kUp, getMod( msg.wParam ) );
            win.processEvent( evt );
            break;
        }
        case WM_LBUTTONDBLCLK:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( msg.lParam ),
                          GET_Y_LPARAM( msg.lParam ), EvtMouse::kLeft,
                          EvtMouse::kDblClick, getMod( msg.wParam ) );
            win.processEvent( evt );
            break;
        }
        case WM_RBUTTONDBLCLK:
        {
            ReleaseCapture();
            EvtMouse evt( getIntf(), GET_X_LPARAM( msg.lParam ),
                          GET_Y_LPARAM( msg.lParam ), EvtMouse::kRight,
                          EvtMouse::kDblClick, getMod( msg.wParam ) );
            win.processEvent( evt );
            break;
        }
        case WM_KEYDOWN:
        case WM_SYSKEYDOWN:
        case WM_KEYUP:
        case WM_SYSKEYUP:
        {
            // The key events are first processed here and not translated
            // into WM_CHAR events because we need to know the status of
            // the modifier keys.

            // Get VLC key code from the virtual key code
            int key = virtKeyToVlcKey[msg.wParam];
            if( !key )
            {
                // This appears to be a "normal" (ascii) key
                key = tolower( MapVirtualKey( msg.wParam, 2 ) );
            }

            if( key )
            {
                // Get the modifier
                int mod = 0;
                if( GetKeyState( VK_CONTROL ) & 0x8000 )
                {
                    mod |= EvtInput::kModCtrl;
                }
                if( GetKeyState( VK_SHIFT ) & 0x8000 )
                {
                    mod |= EvtInput::kModShift;
                }
                if( GetKeyState( VK_MENU ) & 0x8000 )
                {
                    mod |= EvtInput::kModAlt;
                }

                // Get the state
                EvtKey::ActionType_t state;
                if( msg.message == WM_KEYDOWN ||
                        msg.message == WM_SYSKEYDOWN )
                {
                    state = EvtKey::kDown;
                }
                else
                {
                    state = EvtKey::kUp;
                }

                EvtKey evt( getIntf(), key, state, mod );
                win.processEvent( evt );
            }
            break;
        }
        default:
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
    }
}
//=================//
// Rolling Methods //
//=================//
int DnDCharacter::makeAttack(QString, QString mod,int bonus){
    if(mod == "dexterity")
        return die->roll() + getMod(mod) + getValue("bab").toInt() + bonus;
     else
        return die->roll() + getMod("strength") + getValue("bab").toInt() + bonus;
}