View Single Post
Love & Thunder Love & Thunder's Avatar

JCF Member

Joined: Sep 2011

Posts: 1,101

Love & Thunder has disabled reputation

Jan 10, 2015, 06:12 AM
Love & Thunder is offline
Reply With Quote
It should be possible as a simple sprite swap, I think.

Anyway, I'm having trouble getting an enemy surge working. The code is mostly a modified version of some code from plusEnscripted.
It turns up no errors, and the "Surge incoming" text comes up, but no enemies spawn. The coordinates of where I want to spawn stuff is between 237 and 247 widthwise, and 35 heightwise, according to JCS.
Code:
uint elapsed = 0;
bool surge = false;
int slain = 0;
const int SLAINTARGET = 10;
bool surgeover = false;

void onMain() {
    if (surge == false) {
        elapsed = 0;
    } else {
        elapsed ++;
    }
    if ((jjTriggers[5] == true) && (surgeover == false) == true) {
        if (surge == false) {
            jjLocalPlayers[0].showText("@@@@@SURGE INCOMING!", STRING::LARGE);
        }
        doEnemySurge();
    }
}

void doEnemySurge() {
    if (surge == false) {
        surge = true;
    }
    if (slain < SLAINTARGET) {
        if (elapsed % 70 == 0) { //Once per second
            uint16 randomTarget = (237 + (jjRandom()&15)) * 32;
            jjOBJ@ obj = jjObjects[jjAddObject(OBJECT::LIZARD, randomTarget, 1120)];
            obj.state = STATE::FALL;
        }
    } else { //slain >= SLAINTARGET: surge is over
        surgeover = true;
        jjMusicLoad("carrotus.j2b");
        jjLocalPlayers[0].showText("@@@@@SURGE COMPLETE!", STRING::LARGE);
        for (int i = 0; i < jjLocalPlayerCount; i++) {
            jjLocalPlayers[i].limitXScroll(43, 0);
        }
        elapsed = 0;
    }
}
Oh, also I'm triggering it using a trigger crate.

EDIT: Turns out that they're just invisible.
So, now my question is, why are they invisible, and how can I get them visible?
EDIT 2: I've placed other lizards in the level, but the ones coming from this script are still invisible.
EDIT 3: Wait, I fixed it.
Turns out it was the "STATE::FALL" that was the problem. Switching it to either a Float Lizard or removing that line fixes it.

I apologise for the slightly useless post. XD

EDIT 4: New problem: void onObjectHit(jjOBJ@ object, jjOBJ@ bullet, jjPLAYER@ player, int force) isn't triggering.
__________________

Last edited by Love & Thunder; Jan 10, 2015 at 07:08 AM.