Page 1 of 1

Joinable Pirate Clan's Mission thingie. WIP

Posted: Sat Jul 12, 2008 2:47 pm
by Amen Brick
Joinable Pirate Clan.oxp

When this works it will offer the choice (if in an anarchy and without a clean record) to join two my two clans: Blitzspears and She_Wolves (in production and I'm very pleased with my new ship designs :) ) If this works out, I'll maybe adapt a Honest joe version for Corporations.

Pros and Cons of Joining a Clan:

Major Pros:

Cleaning of record if docked at Clan Base

Help if you are attacked by other Clan(s) from you're own guys. (Hoping to add a distress beacon that activates if it recognises that you have been hit by an enemy clan ship - I would have preferred a touch button call for help, but I believe that isnt possible)

Access to special equipment

Chance to get mixed up in (maybe even cause!) mass clan battles

Access to missions (in later versions)

Major Cons:

Clans are illegal and your bounty will go up on Joining
Likely to be attacked a lot by other Clan(s)
More difficult to clear your name in clean systems

--

Whenever I add a new clan, I'll add an update of this oxp to make the clan joinable (if it is joinable, some may not be.)


It is probably riddled with mistakes and copypastad from a couple of sources. It's probably horribly cluttered, inefficient and messy, but its my first baby so...

I need to know if it will work (up until the bumf at the bottom) and where the major syntax errors out. Don't point out the syntax errors, tell me the theory briefly and I'll see if I can clear them up myself. I'll learn quicker that way. :)

Code: Select all

{ 
	"Pirate Clan Offer" = ( 
		{ 
			conditions = ("economy_number lessthan 1");//join in anarchy systems only (at the moment)
			do = ( 
				{ 
{
     			conditions = {"mission_legal_status greaterthan 0");// clean livers need not apply.
     			do = ( 
{
			conditions = ("status_string equal STATUS_DOCKED");
			
			do = ( 

			setGuiToMissionScreen,
			"setMissionImage: AbPirateClanoffer.PNG",
			"set: Mission_ClanOffer", 
			"addMissionText: ClanOffer",
			"setMissionChoices: ClanOffer_yesno" 

			conditions = ("mission_ClanOffer", {missionChoice_string equal YES"); 

		    if(Math.random() > 0.09) // Role the Dice to see if Blitzpear offer
			missionVariables.gang1= "Blitzspear" // Blitzspear offer

			if(Math.random() < 0.91) // Role the Dice to see if She Wolves offer
			missionVariables.gang1= "She-Wolves" // She Wolves offer.

//think syntax above is from different language

	{
		conditions = (missionVariables.gang1= "Blitzspear" {missionChoice_string equal YES"); 		
	}
			setGuiToMissionScreen,
			"setMissionImage: AbBlitzspearsplash.PNG",
			"set: Mission_BlitzOFFER", 
			"addMissionText: BlitzOffer",
			"setMissionChoices: BlitzOffer_yesno" 

			conditions = ("mission_BlitzOffer", {missionChoice_string equal YES"); 

			"addMissionText: BlitzOfferYes",
			"awardCredits: 1000",
			"set: Mission_Blitzmember", 

//also set new bounty

			conditions = ("mission_BlitzOffer", {missionChoice_string equal NO"); 

			"addMissionText: JoinOfferNO",
			resetMissionChoice 
							); 
	{	
			conditions = (missionVariables.gang1= "She-Wolves" {missionChoice_string equal YES"); 

			setMissionImage: AbShewolfsplash.PNG",
			"set: Mission_SheWolfOffer", 
			"addMissionText: SheWolfOffer",
			"setMissionChoices: SheWolfOffer_yesno" 

			conditions = ("mission_SheWolfOffer", {missionChoice_string equal YES"); 

			"addMissionText: SheWolfOfferYes",
			"awardCredits: 1000",
			"set: Mission_SheWolfmember", 
	{	
//also set new bounty

			conditions = ("mission_SheWolfOffer", {missionChoice_string equal NO"); 
			"addMissionText: JoinOfferNO",
			resetMissionChoice 
							);

			conditions = missionVariables.gang1="No Offer"// No offers this time.

			setGuiToMissionScreen,
			"set: ClanOffer_NO ", 
			"addMissionText: ClanOfferNo3",
						resetMissionChoice 
							); 
						},

//NOTE: Each new clan pack will need a new scriptversion to update random number generator to be joinable.

[color=red][b]Unfinished waffle below.[/b][/color]
{
    
    conditions = (missionVariables.gang1= "Blitzspear" {missionChoice_string equal YES"); 

    		do = (//Something here to make ships in pirate clan one oxp not attack player.
      }
}
	
 conditions = (missionVariables.gang1= "She-Wolves" {missionChoice_string equal YES"); 
    }
    do = (//Something here to make ships in pirate clan two oxp not attack player.
      }
}

//set up call for help if possible which spawns clan ships to defend or spawns clan ships if attacked by other clan ships only.

//set up calls for help from other clan ships

//set up increased bounty for "illegal gang membership"

Posted: Sat Jul 12, 2008 3:51 pm
by LittleBear
Looks basicaly ok. For legacy you'd need "d100_number greaterthan 9" etc to do a dice roll.

Also you need "gui_screen_string oneof GUI_SCREEN_STATUS, GUI_SCREEN_EQUIP_SHIP, GUI_SCREEN_MARKET, GUI_SCREEN_SHORT_RANGE_CHART" as a condition before you set the screen to the mission screen. The screen maybe in use by another OXP (very likley these days). If you don't check for it then your OXP's commands just get overwritten before the screen displayed and the OXPs clash.

You'll also need to add a variable in the first condition eg "my_mission_brief_given undefined" and then set it to true when you give the brief. ATM the script will loop. As long as your docked in an anarchy, the condition of docked and economly less than 1 are always true, so Oolite will keep resetting to the mission screen (ie player is locked in and can't trade save launch etc!). do a "reset: my_mission_brief_given" on lauching leaving hyperspace or whatever when you want to re-active the option of the briefing been given again.

Posted: Mon Jul 14, 2008 5:39 am
by Commander McLane
LittleBear wrote:
Also you need "gui_screen_string oneof GUI_SCREEN_STATUS, GUI_SCREEN_EQUIP_SHIP, GUI_SCREEN_MARKET, GUI_SCREEN_SHORT_RANGE_CHART" as a condition before you set the screen to the mission screen.
I would recommend "gui_screen_string notequal GUI_SCREEN_MISSION" instead of that monster (working since 1.69 or so). It doesn't really make a lot of sense anymore to write scripts for versions prior to that.

@ Amen: If you do anything in the line of "More difficult to clear your name in clean systems", please be aware that Anarchies.oxp does a major overhaul of who the player's bounty is calculated, making it more difficult to clear you name in any system. Depending on what you are doing, you could end up with an OXP that is practically incompatible with Anarchies.oxp.

There is of course no reason not to go for that, but you (and your potential players) should be aware of the fact.

Posted: Mon Jul 14, 2008 10:54 am
by Amen Brick
Cool. Thanks for the tips.

Just got work out how to get clan ships attacking each other. Any idea how i can set that up so that certain models firing trigger the 'distress call'?

Posted: Mon Jul 14, 2008 11:32 am
by LittleBear
You'd need the command "broadcastDistressMessage" in AI.

Posted: Mon Jul 14, 2008 11:36 am
by Amen Brick
lol, now I need to know how to write ai messages...

Seriously, I thnk i can cope with basic scripts, missiontext,planetinfo, etc. AI... not sure. Looks hard for a bear of very little brain*






*jk, am brain god^




^jk, really am not.

Posted: Tue Jul 15, 2008 7:20 am
by Commander McLane
LittleBear wrote:
You'd need the command "broadcastDistressMessage" in AI.
That's not enough. Because it is hardcoded that only police ships react to distress calls. All other ships ignore them.

So practically you can't use the method for a pirate clan.

Posted: Tue Jul 15, 2008 12:25 pm
by Amen Brick
basic Clan distress call work path (I imagine)

Shot at by Pirate --> Check to see what model shooting --> On result ship from opposing Clan --> Spawn random ships from own clan somewhere random (so feels more 'real') in system --> own clan ships head towards you --> random chance that spawning own clan ship leads to enemy clan ships converging on your position leading to clan battle.

Also need ai set up so that ships from one clan attack other clans on radar detection so that not all enemy clan ships choose player as target when other targets are possible.

Seems simple enough (!). Just haven't got a clue where to start.

Posted: Tue Jul 15, 2008 1:52 pm
by LittleBear
Have a look at the randomhitspatrolAI. This should be easy to mod to do what you want. ATM it seraches for ships with the role pirate, thargoid or any ships with a criminal record (including the player) and attacks the first ship it finds that is a viable target. As each ship in the group makes its own scan, a Random Hits Patrol breaks formation and attacks when the group encounters targets, each ship picking its own traget from the enemy group. If you do the same but have checks for the role of your enemy clan ships and either a scanForRandomMerchanment (this finds all trade ships including the player) or just a straight forward scanForShipWithRole: player will locate the player. I'll post some code when not at work.

If you make one ship the Clan Leader and assine other members of the clan as escorts then they will defend each other, as you can use escortAI or a modded form. If the ships are set up as a group then they will regard an "attack on one as an attack on all".

Posted: Tue Jul 15, 2008 2:13 pm
by Amen Brick
Thanks LB. Now I have to get to grips with assigning custom roles, but maybe I'll pick that up from your oxp. :)

Posted: Tue Jul 15, 2008 6:29 pm
by LittleBear
Somthing like this should do it:-

Code: Select all

"LOOK_FOR_TARGETS" = {
ENTER = ("scanForNearestShipWithRole: pirate_clan_wolf");
        "ATTACKED" = ("setTargetToPrimaryAggressor, "setStateTo: ATTACK_SHIP"); 
        "INCOMING_MISSILE" = (fightOrFleeMissile, setTargetToPrimaryAggressor, "setStateTo: ATTACK_SHIP"); 
		"TARGET_FOUND" = (setTargetToFoundTarget, "setStateTo: ATTACK_SHIP"); 
        	"NOTHING_FOUND" = (setTargetToSystemStation, "setStateTo: LOOK_FOR_TARGETS2"); 
EXIT = ();
	UPDATE = ("pauseAI: 1.0", "scanForNearestShipWithRole: pirate_clan_wolf");
	};
Rinse and Repeat with LOOK_FOR_TARGETS2 3 4 (however many you need), replacing the role with police, trader player (whatever you want them to attack). The ship looks in target order so if you have pirate_wolf_clan, police, player (say). The ship looks for ships with the role pirate_clan_wolf if one is about it attacks that, if it doesn't spot one the looks for police ships and if none are about it looks for the player. The last look_for_targets need to put the ship into some Navigation state (fly to the planet, nearest pirate base - using co-ordinates, the planet, sun or whatever), with peroidic scans for targets as it flys to where its going.

Posted: Tue Jul 15, 2008 9:41 pm
by Eric Walch
For AI scripting I advise to look at the wiki in the OXP howto AI page. Specially at the bottom there are a few very useful new scan functions. Specially scanForNearestShipHavingRole: would be useful. Add this role to all clan members. Even when the ship is not added by this role, when it is on his role list, it will find him.

This are all new functions that came in use after LB's random hits saw daylight.

Posted: Wed Jul 16, 2008 8:12 am
by Eric Walch
Hello Amen Brick,

For mission offering you always have to make sure you are not overwriting other mission offers. (I already had three offers on the same docking) Specially with the next two commands you have to check first if they are not already in use:

setGuiToMissionScreen
setMissionChoices: ClanOffer_yesno


The fists check is already mentioned by others but also the second command needs a check first: missionChoice_string undefined. Without this check you could overwrite the choices of an other offer before that oxp can read out this choices.

When you plan to write more than a few program lines you should consider doing it in Java Script. The start is probably more difficult but after that it is easier in use. Look inside Military Fiasco It contains both types of scripts that do the exactly the same. One script is used by 1.65 oolite and the other by the current oolite versions.

Also UPS-courier contains scripts in both versions. USP grew to complex to be used as sample code, but in the script folder I added a script with name demoScript.js. That is an template for a mission offering script with all the relevant checks in place. You just have to add your own stuff. It contains comment and probably it should get a place of its own once in future. I appreciate comment on that one how usable it is.