コード例 #1
0
ファイル: Mob.cpp プロジェクト: snopboy/JourneyClient
	void Mob::nextmove()
	{
		if (canmove)
		{
			switch (stance)
			{
			case HIT:
			case STAND:
				setstance(MOVE);
				flip = randomizer.nextbool();
				break;
			case MOVE:
			case JUMP:
				if (canjump && phobj.onground && randomizer.below(0.25f))
				{
					setstance(JUMP);
				}
				else
				{
					switch (randomizer.nextint(2))
					{
					case 0:
						setstance(STAND);
						break;
					case 1:
						setstance(MOVE);
						flip = false;
						break;
					case 2:
						setstance(MOVE);
						flip = true;
						break;
					}
				}
				break;
			}

			if (stance == MOVE && canfly)
			{
				flydirection = nextdirection(randomizer);
			}
		}
		else
		{
			setstance(STAND);
		}
	}
コード例 #2
0
ファイル: paramed.c プロジェクト: iamgreaser/kevedit
int parameditoption_id(displaymethod * d, ZZTworld * w, ZZTtile tile, dialogComponent * opt)
{
	int num;   /* General use number */

	switch (opt->id) {
		case ID_PROGRAM:
			editprogram(d, tile.param);
			return 2;
		case ZZT_DATAUSE_PASSAGEDEST:
			tile.param->data[2] = boarddialog(w, tile.param->data[2], "Passage Destination", 0, d);
			return 2;
		case ZZT_DATAUSE_CHAR:
			num = charselect(d, tile.param->data[0]);
			if (num != -1)
				tile.param->data[0] = num;
			return 1;
		case ZZT_DATAUSE_LOCKED:
			tile.param->data[1] = !tile.param->data[1];
			return 1;
		/* 8-bit numbers */
		case ZZT_DATAUSE_TIMELEFT:
			/* For values under ten, toggle between 0 and 9 */
			if (tile.param->data[zztParamDatauseLocate(opt->id)] < 10) {
				if (tile.param->data[zztParamDatauseLocate(opt->id)] == 0)
					tile.param->data[zztParamDatauseLocate(opt->id)] = 9;
				else
					tile.param->data[zztParamDatauseLocate(opt->id)] = 0;
				return 1;
			}
		case ZZT_DATAUSE_DUPRATE:
		case ZZT_DATAUSE_SENSITIVITY:
		case ZZT_DATAUSE_INTELLIGENCE:
		case ZZT_DATAUSE_RESTTIME:
		case ZZT_DATAUSE_SPEED:
		case ZZT_DATAUSE_DEVIANCE:
		case ZZT_DATAUSE_STARTTIME:
		case ZZT_DATAUSE_PERIOD:
			/* Require user to inc/dec for values under 9 */
			if (tile.param->data[zztParamDatauseLocate(opt->id)] < 9)
				return 0;
		case ID_CYCLE:
		case ID_DATA0:
		case ID_DATA1:
		case ID_DATA2:
			/* zero's are special */
			if (str_equ(opt->text, "0", 0)) opt->text[0] = '\x0';
			if (dialogComponentEdit(d, opt, 3, LINED_NUMBER) == LINED_OK) {
				sscanf(opt->text, "%d", &num);
				/* No exceeding the bounds of an 8-bit number */
				if (num > 255) num = 255;
				/* zero's are special */
				if (opt->text[0] == '\x0') num = 0;

				/* Is this lame, or what? */
				/* We could put the above in a function and use
				 * the top level switch only, but why bother? */
				switch (opt->id) {
					case ID_CYCLE:
						tile.param->cycle = num; break;
					case ID_DATA0:
						tile.param->data[0] = num; break;
					case ID_DATA1:
						tile.param->data[1] = num; break;
					case ID_DATA2:
						tile.param->data[2] = num; break;
					default:
						tile.param->data[zztParamDatauseLocate(opt->id)] = num;
						break;
				}
			}
			return 1;
		/* signed 8-bit values -- ack! */
		case ID_XSTEP:
		case ID_YSTEP:
			/* almost like regular 8-bits... */
			/* zero's are special */
			if (str_equ(opt->text, "0", 0)) opt->text[0] = '\x0';
			if (dialogComponentEdit(d, opt, 4, LINED_SNUMBER) == LINED_OK) {
				sscanf(opt->text, "%d", &num);
				/* No exceeding the bounds of a signed 8-bit number */
				if (num > 127) num = 127;
				if (num < -128) num = -128;
				/* zero's are special */
				if (opt->text[0] == '\x0') num = 0;
				if (opt->id == ID_XSTEP) tile.param->xstep = num;
				else tile.param->ystep = num;
			}
			return 1;
		// c/p from above --GM
		case ID_XPOS:
		case ID_YPOS:
			/* almost like regular 8-bits... */
			/* zero's are special */
			if (str_equ(opt->text, "0", 0)) opt->text[0] = '\x0';
			if (dialogComponentEdit(d, opt, 4, LINED_SNUMBER) == LINED_OK) {
				sscanf(opt->text, "%d", &num);
				/* No exceeding the bounds of a signed 8-bit number */
				if (num > 127) num = 127;
				if (num < -128) num = -128;
				/* zero's are special */
				if (opt->text[0] == '\x0') num = 0;
				if (opt->id == ID_XPOS) tile.param->x = num;
				else tile.param->y = num;
			}
			return 1;
		case ID_FIRERATE:
			if (str_equ(opt->text, "0", 0)) opt->text[0] = '\x0';
			if (dialogComponentEdit(d, opt, 3, LINED_NUMBER) == LINED_OK) {
				int firerateindex = zztParamDatauseLocate(ZZT_DATAUSE_FIRERATEMODE);
				sscanf(opt->text, "%d", &num);
				/* No exceeding the bounds of a 7-bit number */
				if (num > 127) num = 127;
				/* zero's are special */
				if (opt->text[0] == '\x0') num = 0;

				tile.param->data[firerateindex] &= 0x80;
				tile.param->data[firerateindex] |= num;
			}
			return 1;
		case ID_BIND:
			num = tile.param->bindindex;
			if (num == 0)
				num = -1;  /* For #bind, 0 means none */

			num = paramlistdialog(d, zztBoardGetBlock(w), num, "Select object to bind with");

			if (num == -1)
				num = 0;
			tile.param->bindindex = num;
			return 1;
		case ID_INSTRUCTION:
			/* zero's are special */
			if (str_equ(opt->text, "0", 0)) opt->text[0] = '\x0';
			if (dialogComponentEdit(d, opt, 6, LINED_SNUMBER) == LINED_OK) {
				sscanf(opt->text, "%d", &num);
				/* zero's are special */
				if (opt->text[0] == '\x0') num = 0;
					tile.param->instruction = num;
			}
			return 1;
		case ID_LEADER:
		case ID_FOLLOWER:
			if (opt->id == ID_LEADER)
				num = tile.param->leaderindex;
			else
				num = tile.param->followerindex;
			if (num == 0xFFFF)
				num = -1;  /* For #bind, 0 means none */

			num = paramlistdialog(d, zztBoardGetBlock(w), num, "Select object to bind with");

			if (num == -1)
				num = 0xFFFF;
			if (opt->id == ID_LEADER)
				tile.param->leaderindex = num;
			else
				tile.param->followerindex = num;
			return 1;
		case ID_PROJECTILE:
			tile.param->data[zztParamDatauseLocate(ZZT_DATAUSE_FIRERATEMODE)] ^= 0x80;
			return 1;
		case ZZT_DATAUSE_OWNER:
			tile.param->data[zztParamDatauseLocate(opt->id)] = !tile.param->data[zztParamDatauseLocate(opt->id)];
			return 1;
		case ID_DIRECTION:
			{
				char xstep, ystep;
				num = getdirection(tile.param->xstep, tile.param->ystep);
				num = nextdirection(num);
				getxystep(&xstep, &ystep, num);
				tile.param->xstep = xstep;
				tile.param->ystep = ystep;
			}
			return 1;
	}

	/* No change occured if we reach this point */
	return 0;
}