Sample: Monster Advanced Example

From SkyCorp Global
Jump to: navigation, search
Note - this monster is a modification for The Underworld. Visit the new Mods Portal for more mods, mods on the wiki are no longer maintained. You can put it in-game by visiting the Debug Mod Control Panel in the debug rooms and browse to this mod or copy/paste the JSON below into the program window.

Monster Details

Demonstrates an script-powered monster using the Monster Advanced type.

The monster will not notice the player immediately, and during combat, occasionally heal itself.

Author: SkyCorp

JSON

{
	"type": "MONSTERADVANCED",
	"id": "Sample Monster Advanced Example",
	"description": {
		"literalString": "A test monster demonstrating a basic setup for the Monster Advanced type."
	},
	"tickRest": {
		"programVoid": true
	},
	"tickAttack": {
		"programVoid": true
	},
	"defaultText": {
		"alert": "The test monster notices your approach.",
		"lustOk": "The test monster does a sexy dance, arousing you.",
		"lustFails": "The test monster attempts to do a sexy dance, but falls over clumsily.",
		"attackOk": "The test monster strikes you.",
		"attackFails": "The test monster lunges forward, but misses you.",
		"playerUse": "You have your way with the defeated test monster.  W/ Insemination.",
		"playerDefeat": "The test monster has its way with you.  W/ Insemination"
	},
	"initialValues": {
		"escapeChance": 0.75,
		"hp": 3,
		"lustMax": 3,
		"meleeAttackPlayerDamage": 1,
		"meleeAttackPlayerAccuracy": 0.75,
		"lustAttackPlayerDamage": 15,
		"lustAttackPlayerAccuracy": 0.75,
		"lustAttackChance": 0.49,
		"meleeAttackMonsterAccuracy": 0.95,
		"lustAttackMonsterAccuracy": 0.95,
		"inseminationAttemptOnPlayerVictory": true,
		"inseminationAttemptOnPlayerDefeat": true,
		"name": "Testmon"
	},
	"defeatTf": {
		"tfTime": "The test monster transforms you a little bit.",
		"tfTotal": "The test monster has finished transforming you.",
		"tfEscapeFailure": "You didn't escape from the test monster.",
		"tfEscapeSuccess": "You escape from the test monster!",
		"tfAccept": "You relax your body, giving into the monster for now...",
		"bodyType": "FOX"
	},
	"luac": "G0x1YVEAAQQEBAgAHAAAAEBtb25zdGVyQWR2YW5jZWRFeGFtcGxlLmx1YQAAAAAAAAAAAAAAAgIJAAAAAUAAA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EAQUABAIGAAQAcgIABGMBBABZAA4AFAAIABkBCAEGAAgCFAAAAhsBCAZyAgADBAAMAAUEDAFUAgQAcQAABBQAAAAaAQwAcQIAAHgCAAAUAAAAGgEAAHECAAB4AgAAPAAAABAUAAAB0aGlzAAQNAAAAaXNQbGF5ZXJIZXJlAAQSAAAAZGVmYXVsdFRpY2tBdHRhY2sABAUAAABtYXRoAAQHAAAAcmFuZG9tAAMAAAAAAAAAAAMAAAAAAAAkQAMAAAAAAAAQQAQLAAAATWFpblNjcmVlbgAEDAAAAGFkZEdhbWVUZXh0AAQFAAAAVGhlIAAECAAAAGdldE5hbWUABAgAAAAgaGVhbHMgAAQOAAAAdGhlbXNlbHZlcyEKCgAEDAAAAHJlc2V0SFBMdXN0AAAAAAAiAAAAJwAAACcAAAAnAAAAJwAAACcAAAAoAAAAKAAAACgAAAApAAAALQAAAC0AAAAtAAAALQAAAC0AAAAtAAAALQAAAC4AAAAuAAAALgAAAC4AAAAuAAAALgAAAC4AAAAvAAAALwAAAC4AAAAwAAAAMAAAADAAAAAxAAAANQAAADUAAAA1AAAANgAAAAAAAAAAAAAACQAAAAEAAAABAAAAAgAAAAIAAAAdAAAABwAAADYAAAAiAAAANgAAAAAAAAAAAAAA"
}

Lua Source

idleCounter = 0
TURNS_TO_NOTICE = 3

-- This function is called when the monster is resting.
-- With this override, we will instruct the monster to not immediately notice
-- the player.
function tickRest()
	
	-- State functions are called regardless of whether the player is present
	-- or not.  But the monster shouldn't wake up unless the player is here.
	if not this.isPlayerHere() then		
		idleCounter = 0; -- Not waiting around if player isn't here
		return;
	end
	
	-- This monster will take a couple extra turns to notice the player. 
	idleCounter = idleCounter + 1;
	
	if idleCounter < TURNS_TO_NOTICE then
		-- Not yet long enough for the monster to notice the player.
		MainScreen.addGameText("The " .. this.getName() .. " doesn't seem " ..
			"to notice you yet...\n\n");
		return;
	end
	
	-- The player has waited around a bit, so notice them.
	this.setState("ATTACK");
	GameText.printText(this.getTextPrefix() .. "ALERT");
end

-- This function is called each game tick when the monster is attacking the
-- player.  With our override, we will make the monster occasionally heal
-- themselves instead of doing the usual attack logic.
function tickAttack()
	
	-- State functions are called regardless of whether the player is present
	-- or not.  But the monster should fall back to default logic if the
	-- player isn't here (causing them to return to rest state).
	if not this.isPlayerHere() then		
		this.defaultTickAttack();
		return;
	end 
	
	-- Occasionally heal ourselves as our move
	if math.random(0, 10) < 4 then
		MainScreen.addGameText("The " .. this.getName() .. " heals " ..
			"themselves!\n\n");
		this.resetHPLust();
		return;
	end
	
	-- Otherwise fallback to usual attack logic
	this.defaultTickAttack();
end