Page 29 of 45

Re: The Feudal States

Posted: Fri Apr 15, 2011 4:17 pm
by Ramirez
The feudal-challengerhomeAI is only there to return the NPC to the station once the challenge has been completed, so really there's no need to trigger more flee actions. Try removing the following lines from the GO_TO_STATION state:

Code: Select all

ATTACKED = ("setStateTo: FLEE"); 
FIGHTING = ("setStateTo: FLEE");
FLEEING = ("setStateTo: FLEE");

Re: The Feudal States

Posted: Sat Apr 16, 2011 2:02 am
by Switeck
zsozso wrote:
I tried with all setAI replaced by switchAI in feudal-target.js, but the stackOverflow errors still occur. The only difference is that now the log does not mention the script feudal-target.js, only feudal-challengerhomeAI.plist such as :

Code: Select all

[ai.error.stackOverflow]: ***** ERROR: AI stack overflow for <ShipEntity 0xe80eed0>{"Prinz-Class Zerstoerer (Erinain)"} in feudal-challengerhomeAI.plist: FLEE -- stack:

  [ai.error.stackOverflow.dump]:  31: feudal-challenger2AI.plist: ATTACK_SHIP
  [ai.error.stackOverflow.dump]:  30: feudal-challengerhomeAI.plist: FLEE
  [ai.error.stackOverflow.dump]:  29: feudal-challengerhomeAI.plist: FLEE
Then this keeps repeating several times. So there seems to be some internal problem in the AI plist state-machine itself.
This may be distantly related to:
https://bb.oolite.space/viewtopic.php?f=3&t=9638
...Where a Thargoid warship got:
12:42:51.609 [ai.message.failed.overflow]: ***** ERROR: AI pending messages overflow for 'Thargoid Warship 647'; pending messages:

Re: The Feudal States

Posted: Sun Apr 17, 2011 1:07 am
by zsozso
Ramirez wrote:
The feudal-challengerhomeAI is only there to return the NPC to the station once the challenge has been completed, so really there's no need to trigger more flee actions. Try removing the following lines from the GO_TO_STATION state:

Code: Select all

ATTACKED = ("setStateTo: FLEE"); 
FIGHTING = ("setStateTo: FLEE");
FLEEING = ("setStateTo: FLEE");
This worked! I see no more error messages after removing those, and the defeated ship now turns around and heads back to the base (Hunting Lodge) while before it kept going away (fleeing) indefinitely.

Thanks a lot!

Re: The Feudal States

Posted: Mon Apr 18, 2011 12:39 pm
by Ramirez
Version 1.10 of The Feudal States is now up at my site. Changes include:
  • A Japanese-themed set of houses for Galaxy 6
  • fix to the AI stack overflow error
  • improved mission descriptions
  • a new 'Tribute' mission type involving the lesser feudal states
  • improvement to the promotion handling script
  • repositioning of hunting lodges for compatability with FarSun and other such OXPs
  • various minor fixes and cleanups
Enjoy!

Re: The Feudal States

Posted: Thu Apr 21, 2011 3:07 pm
by zsozso
Playing a bit more with this OXP while also doing some other missions, I found something that bothered me. I understand the rule of no missiles or bombs for the challenge, but I do not like the way it is enforced by simply calling player.ship.awardEquipment("EQ_MISSILE_REMOVAL"). Usually, I have a Missile Machine (5,000Cr, needs high tech level to buy) and other expensive and hard to find bombs equipped, so simply losing them (or even selling them off prior to challenge) is a royal PITA -- meaning Pain In The Armoury, of course. So I'd much prefer a temporary impounding by the Hunting Lodge, so that you get back all your equipment once you dock back after the fight, just like it restores energy bomb and cloaking device that are temporary disabled.

I have managed to add this temporary missile/bomb impounding functionality to the feudal-challenge.js script by extending the following two functions:

Code: Select all

this.disableSystems = function()
{
	if(player.ship.equipmentStatus("EQ_CLOAKING_DEVICE") == "EQUIPMENT_OK")
		{	player.ship.setEquipmentStatus("EQ_CLOAKING_DEVICE", "EQUIPMENT_DAMAGED")
			player.consoleMessage("Cloaking Device disabled")
		}
		
	if(player.ship.equipmentStatus("EQ_ENERGY_BOMB") == "EQUIPMENT_OK")
		{	player.ship.setEquipmentStatus("EQ_ENERGY_BOMB", "EQUIPMENT_DAMAGED")
			player.consoleMessage("Energy Bomb disabled")
		}
	this.storeMissileArray = player.ship.missiles;
	player.ship.awardEquipment("EQ_MISSILE_REMOVAL")
	player.ship.awardEquipment("EQ_FEUDAL_FLARE_MINE")
}

this.restoreSystems = function()
{	if(player.ship.equipmentStatus("EQ_CLOAKING_DEVICE") == "EQUIPMENT_DAMAGED")
		{	player.ship.setEquipmentStatus("EQ_CLOAKING_DEVICE", "EQUIPMENT_OK")
			player.consoleMessage("Cloaking Device re-enabled")
		}
		
	if(player.ship.equipmentStatus("EQ_ENERGY_BOMB") == "EQUIPMENT_DAMAGED")
		{	player.ship.setEquipmentStatus("EQ_ENERGY_BOMB", "EQUIPMENT_OK")
			player.consoleMessage("Energy Bomb re-enabled")
		}
	player.ship.awardEquipment("EQ_MISSILE_REMOVAL")
	for(restoreCounter = 0;restoreCounter<this.storeMissileArray.length;restoreCounter++)
        { 
		player.ship.awardEquipment(this.storeMissileArray[restoreCounter].equipmentKey); 
	}
}
In addition to the above changes, I had to remove all other calls to player.ship.awardEquipment("EQ_MISSILE_REMOVAL") and also make sure that function disableSystems() is only called once -- in release 1.10 it is called twice, once when accepting the challenge and again when the ship is launched from the station, I just kept the later one. The player.ship.awardEquipment("EQ_FEUDAL_FLARE_MINE") call is also moved into the disableSystems() call so it is not needed in its original place.

Ramirez, if you agree with this little tweak, I would be thankful if you included it in future releases.

Re: The Feudal States

Posted: Thu Apr 21, 2011 3:26 pm
by Zireael
I think that tweak is nice...

Re: The Feudal States

Posted: Thu Apr 21, 2011 3:37 pm
by Mauiby de Fug
Ooh, nice!

Re: The Feudal States

Posted: Thu Apr 21, 2011 3:48 pm
by Ramirez
Many thanks - I had been putting this off as for some reason I thought it was too difficult to do, but it looks like it's quite simple after all. Plus, I'll need to use the same method for the Guerilla War OXP as well.

I have no problem with putting this in; also I'll look to using it in the tournament script as well as there are instances there where I need to remove a player's missiles temporarily. Will get onto it when I have a moment.

Re: The Feudal States

Posted: Thu Apr 21, 2011 4:32 pm
by Commander McLane
Another addition would be to rename the functions to this.$disableSystems and this.$restoreSystems, and generally putting a '$' in front of all self-defined functions (as opposed to event handlers). Don't forget to put it in also in the places where the functions are called.

Ahruman would be grateful.

Re: The Feudal States

Posted: Thu Apr 21, 2011 4:40 pm
by Thargoid
Rather than damaging them, I would suggest removing the cloak and e-bomb and awarding a dummy piece of equipment in each case that does nothing other than act as a place-holder that the original item has been removed. Then when you want to restore, if the placeholder dummy is present then remove it and re-award the original.

In the code above if the repair system is installed, or if it's done on a Caduceus or a Vortex then the relevant systems will kick in and try and repair (and re-award) the items which isn't what you want.

The placeholder method works well, a few of my OXPs use it (for example the ECM Jammer in TCAT).

The missile removal and re-award technique is basically how the multi-missile bay system works in the Vortex too.

Re: The Feudal States

Posted: Thu Apr 21, 2011 5:28 pm
by zsozso
Indeed, Thargoid is right, I've seen the MAC kick in and repair my e-bomb during challenge as I use a Vortex ship.

BTW, the Vortex multi-missile bay system was the code that "inspired" me to do the above tweak -- you may call it stealing or borrowing code as well :wink:
But I did make a simplification by skipping the stringification and stored in local variable instead of mission variable.

Re: The Feudal States

Posted: Thu Apr 21, 2011 5:50 pm
by JD
The disable/repair technique might also present a cheap way of getting some already damaged equipment fixed.

Re: The Feudal States

Posted: Thu Apr 21, 2011 7:40 pm
by Commander McLane
zsozso wrote:
But I did make a simplification by skipping the stringification and stored in local variable instead of mission variable.
Which is fine, as long as the player cannot save and reload his game between the switches. If he could and would, all local variables would be gone.

Re: The Feudal States

Posted: Thu Apr 21, 2011 9:10 pm
by Lone_Wolf
Commander McLane wrote:
zsozso wrote:
But I did make a simplification by skipping the stringification and stored in local variable instead of mission variable.
Which is fine, as long as the player cannot save and reload his game between the switches. If he could and would, all local variables would be gone.
That sounds like a small change in the challenge duel code is due, since it now states that returning to the lodge (without winning ..) or jumping out of system forfeits the challenge.
Maybe make it so that docking anywhere means you forfeit the challenge ?

(main station alone is not enough, as with save anywhere you can save from other stations also)

Given that the challenge is done 'in the spririt of chivalry' , it seems rude to keep your opponent waiting ...

Re: The Feudal States

Posted: Thu Apr 21, 2011 9:42 pm
by Thargoid
Lone_Wolf wrote:
(main station alone is not enough, as with save anywhere you can save from other stations also)
Actually it is, as even save anywhere does save at the main station. It just cleverly moves you to it, enables the save and then moves you back to where you originally were. So you will be docked at the main station when you do save.