ommmmmmm / keeperfx

Automatically exported from code.google.com/p/keeperfx
0 stars 1 forks source link

Compare variables with IF statement #515

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently the IF statement compares a variable with a number. The script would 
be quite a bit more powerful – and as such allow the mapmaker to be more 
creative – if it could compare variables instead:

IF([player],[name/number][comparison][name/number])

Some of the possibilities:

REM: Compare red to blue.
IF(PLAYER0,TOTAL_CREATURES >= PLAYER1,TOTAL_CREATURES)
    QUICK_INFORMATION(1,"It is time to attack",PLAYER1)
ENDIF

REM: Punish player for having more than 50% of heroes in his army.
IF(PLAYER0,GOOD_CREATURES >= PLAYER0,EVIL_CREATURES)
    QUICK_INFORMATION(2,"You have to many heroes, a rebellion is imminent.",PLAYER0)
ENDIF

REM: Reward player for effective battle.
IF(PLAYER0,BATTLES_WON > PLAYER0,BATTLES_LOST)
    QUICK_INFORMATION(4,"You fought so well Horny joined you.",PLAYER0)
    ADD_CREATURE_TO_LEVEL(
ENDIF

REM: Make sure the player always has more demonspawn then dragons
IF(PLAYER0,DRAGON >= PLAYER0,DEMONSPAWN)
    NEXT_COMMAND_REUSABLE
    CREATURE_AVAILABLE(DRAGON,PLAYER0,0,0)
ENDIF
IF(PLAYER0,DRAGON < PLAYER0,DEMONSPAWN)
    NEXT_COMMAND_REUSABLE
    CREATURE_AVAILABLE(DRAGON,PLAYER0,1,0)
ENDIF

REM: Save on the number of IF statements needed by using the flag as a variable
IF([condition1])
    IF([condition2])
        IF(condition3]
            IF([condition4A])
                SET_FLAG(PLAYER0,FLAG3,6)
            ENDIF
            IF([Condition4B])
                SET_FLAG(PLAYER0,FLAG3,9)
            ENDIF
        ENDIF
    ENDIF
ENDIF
IF(PLAYER0,BILE_DEMON >= PLAYER0,FLAG3)
    CREATURE_AVAILABLE(BILE_DEMON,PLAYER0,0,0)
ENDIF

REM: Save on number of if statements by comparing variables directly 
IF(PLAYER0,FLAG1 == PLAYER0,FLAG2)
    QUICK_INFORMATION(3,"The planets have alligned.",PLAYER0)
    ADD_CREATURE_TO_LEVEL(
ENDIF

(If implemented it could be further expanded upon with some basic Arithmetic)

Original issue reported on code.google.com by Loobinex on 25 Feb 2015 at 1:00

GoogleCodeExporter commented 9 years ago
I was going to suggest same idea some point, but I was thinking there is too 
much issues on going atm.

but I give plus one for this

Original comment by UnknownM...@Hotmail.com on 25 Feb 2015 at 12:08

GoogleCodeExporter commented 9 years ago
This is only possible when KeeperFX is completely rewritten.

Original comment by mefistotelis on 25 Feb 2015 at 10:11