Open jpcsupplies opened 9 years ago
Hopefully you've seen the latest update notes. http://forum.keenswh.com/threads/7368279 "autopilot improvements" "Auto-piloted ships can now evade asteroids and ships without crashing into them."
An excerpt from part of the PB code to the Auto Pilot.
var remote = list[0] as IMyRemoteControl;
remote.ClearWaypoints();
Vector3D player;
bool success = remote.GetNearestPlayer(out player);
if (success)
{
player = remote.GetFreeDestination(player, 200, 15.0f);
remote.AddWaypoint(player, "Player");
remote.SetAutoPilotEnabled(true);
}
GetNearestPlayer
from what I understand only works with remote blocks that are controlled by NPC.
Now that is handy.. now our delivery ships dont end up like a fly on a windscreen hopefully.. and any movies I make wont result in cluster F***s at a single waypoint lol
Also reminds me to update.. woops
@midspace If i read that code above correctly is that inserting waypoints into the autopilot list? So basically that code tastes to me like a seek and destroy logic potentially ?
This enhancement could also work as as separate workshop mod capable of being an API plugin.. sort of a proof of concept, if it used the same connection ID.. it could access our bank file to pay players for completed missions, or bill players for posting missions..? Combined with the improved autopilot ai and tracking; or even pirate encounters this gives almost unlimited potential for things like delivery escort,raid or bounty contracts
Do you think @Spcemarine or your self might be interested in playing with the idea of making a mission/contract mod which can be set to talk to ours?
No, I don't think I'm interested in making a mission/contract mod.
Just browsed through the code a bit and I must say a lot of the code seems familiar to me. Weird. I think I wrote some of it but I cannot remember pushing it to this repo... Just kidding, just treat it kindly. ;P
Midspace has been helping a lot so they are probably not reinventing the wheel.
Feel free to offer advice on it tho, goodness knows i need the help, i was trained in software development under ASIC, BASIC, QBASIC, PASCAL, and Visual Basic 5 - like last century (literally lol) The only C i played with was some map definitions under Lima Bean for a MUD server, and coincidental similarities in perl/cgi.. Compared to that C# is properly/totally doing my head in! :)
Bit of an ongoing joke is calling myself a trained monkey.. since thats my skill level in C# :8ball: For most stuff I am basically converting the C# code to basic or flowcharts in my head to try to figure out what it does.. makes for slow progress lol (especially where parallels dont exist)
No need for reinventing the wheel. Midspace told me that the code is being used here anyway and I have no objections.
I also started programming C# with Space Engineers but I started with Java and that's very similar to C# so it wasn't very difficult and I was never trained in anything concerning software engineering so I was kind of used to teaching myself how to program in C#. So I don't really have advice and since Midspace is here there is no need for another adviser as he might be one of the best you can get in the SE community. ;)
BTT: I wonder a to which extend mods can talk to one another. Is it possible to create some base classes in one mod that can be used in another one? Then you could just create an API for missions / contracts and ppl who want to create some for their servers might just create them based on this mod.
Cannot use classes from one mod in another, as we cannot control the compile of the project and dependancies. The .Net compiler that Keen uses doesn't use any user generated project file. Keen specfies all the desired dependancies and no more to prevent misuse. That basically leaves us sharing the Message classes and the id number for communicating.
In so much as a mod api is concerned, mod makers making mods to talk to our mod, really only need something that allows external mods to add or remove money from a player.. which should be possible under message classes?
Everything else the 3rd party mod can do directly itself, no need to talk to ours... unless someone makes a trade bot for the stock market of course. But most economy systems I've hit in other games are basically only interacting with the player balance - take minecraft/bukkit essentials/essentials economy. It did various interesting things, but mods that talked to it, really only needed to pay (or tax) players balance.
Another method i've mentioned before is the "one hit read" method. Have a data file (eg bank balance) that is not held open, and has a read performed on it prior to making any changes in game. This leaves the file unlocked most of the time and can be written to externally - (eg by a website CGI script)
So any changes made outside of the game, immediately have an in-game effect. The only difficulty of this method is: a: your code needs some sort of on-error-file-locked, retry logic b: if the file gets too big, reading it every time someone types /bal /pay /sell whatever could impact mod performance. c: if either the mod or the external changes are too frequent, the on-error-retry-logic can tie up the mod too. d: if the external program messes up the file; mod or external program needs to deal with that too.. which usually means a backup file.. which makes things slower again processing two files.
Advantages: No need for any crazy changes to the Mod API system - since only the saved data is touched, not the game itself.
Midspace could use one-hit logic on the admin mod MOTD file for example, allowing admins to make changes externally that immediately show up in game.
Writing to the accounts file also requires know the current structure. ergo => api.
A lot of the .net classes to make it safe to do this, just aren't whitelisted by Keen to use in the Mod Api.
It might make a little more sense to have a separate file created, that Econ reads as Input, and once read, deleted, making it transactional. But then, how do you respond back to external requests?
But I'd rather deal with in game API, as it's easier to manage. We just need to publish the required classes needed for communicating with our mod. They can be wrappered for easy use. Just plug in your detail, and Invoke.
Still think the original post idea of contracts is worth looking into more.. at the very least a bounty system, or a delivery contract. Or some sort of missions framework. Delivery contracts have the advantage that our range check logic can be used, bounties have the disadvantage that we still need a way to work out HOW and WHO killed the target of the bounty. Simply using proximity checks might open the possibility of people exploiting the bounty system...
But the seek and destroy code in autopilot does open up the reverse possibility... instead of a bounty, create a kill contract... which launches a guided missile at the target.. rather un-blue mining sort of thing tho.
Would this in an in-game script give us player seeking missiles BTW ? Probably scanrange is limited to chunk size tho.. it looks a lot like the behavior of those small pirate ships.
An excerpt from part of the PB code to the Auto Pilot.
var remote = list[0] as IMyRemoteControl;
remote.ClearWaypoints();
Vector3D player;
bool success = remote.GetNearestPlayer(out player);
if (success)
{
player = remote.GetFreeDestination(player, 200, 15.0f);
remote.AddWaypoint(player, "Player");
remote.SetAutoPilotEnabled(true);
}
Ship requires remote cube. Remote cube ownership has to be set to an NPC identity.
NPC doesn't have to enemy or in different faction.
Ok, for the moment forget everything wrote above.
I was shuttlng ice the other day between europa and blue mining to refill the market as it had been used up, and it was quite fun. I was thinking about what you said in regard to my trade network hud thing using what really should be for missions.. and thought... why dont we use it for missions then?
Something like new players (or anyone online) get issued a "urgent order from %trade network name % for 1000 XX item." the item it chooses for the order would be whatever item the market has the least (or none) of (usually an ore since new players can mine those) and pay some sort of bonus if a player sells that to the market next.
From a logic perspective, this is quite easy to add to our existing /sell command as an extra check to see if a sale matches an "urgent order request"
Since urgent orders are drawn from whatever item we have least of (or none of) these missions probably dont even need to be saved in the database, and can simply exist in the current DS session memory making things even more simple. (after a reboot it would simply generate a new urgent order based on stock levels)
Extended logic - remote npc trade stations could ALSO generate these missions, giving players an incentive to find them. We could even double the reward for every hour the order remains unfilled. (conditional on at least one player being online of course- it would reset if the server was empty)
Basically a simple analogue of the old elite/frontier games "famine in XX star system" which automatically increased food prices if you traded in those areas.
This could also make use of my unfinished "news system" players could type /news to see what current "urgent orders " have been issued by each NPC base.
Sounds pretty damn fun to me, what you think?
(Could also add SOS missions.. "rescue the damsel" a lost player goes /sos for a pick up. (joking!))
"Delivery contract bonus" Transport tycoon style - first person gets a delivery contract for themself (and their faction?) pays extra for sells of that item for a period of time to them and their faction?
See also #70
( https://github.com/jpcsupplies/Economy_mod/issues/70#issuecomment-201081096 )
I am proposing we simplify this to just be deliveries to stations. All the other suggestions above are all cool sounding.. but we need to start somewhere; and many above ideas require modapi changes, major code changes, or would negatively impact sim severely. Plus I like the idea of following the transport tycoon line of logic in a space game. Most of which would work quite well.. (passenger services? lol mail services.. not so much - although with the antenna range thing flying around syncing up peoples faction chat might be an odd occupation, and bounties, short of being able to detect WHO destroyed a block or killed a player.. or using effects like exploding jump drives as a way to confirm (and cause) the kill its not practical yet)
probably need a /contracts command to display currently held delivery subsidys probably need the hud to display some sort of stats on held contracts probably need a /addevent or similar command to manually create contracts in addition to those that are automatically generated by low stock (assuming we allow that to be automatic at all? I say yes otherwise a cool gameplay element may never be used) Contract/subsidys should work with several options: 1 the time limit, 2 the buy limit, and 3 is the bonus a % on top of buy price or a fixed bonus amount., 4 should it advertise the location? 5 should it restrict contracts to between two specific bases?
Adding contracts probably should be allowed by players who own markets too - but given they can move this might be tricky it may need to be limited only to zones that were created on a station - and will be revoked (with a penalty fee paid to holders of contracts?) if the zone is moved before the contract ends.
Eg Screaming Angel has offered a delivery contract for (optional qty ( first 1000)) "missiles" delivered to base "Mutual Assured Rationality", (optional (located at GPS: x y z)), (optional: (transported from base "Mutual Assured Mercantile")) deliveries will attract a bonus (20% | 2 credits) per (item | delivery), for the next (7) days.
Automatic contracts for NPC bases could probably force players to buy the goods from a particular base too (in the case of overstock vs understock?) Eg Blue Mining Inc desperately requires (optional qty: (50,000)) steel plates at trade facility "Hell Outpost" GPS: 1 2 3 (optional: to be transported from "Mars Outpost" GPS 3 2 1) and deliveries of this item will pay a bonus (30% | 0.05) per unit
In the case of specific forced deliveries between bases it could make use of the /load and /unload cargo commands, and pay a bonus for the delivery only.?? Although they were more for allowing market owners/employees to add/remove stock to markets without being billed.
Hmm and we could use the one off "urgent delivery" logic as well I suppose looking at my previous post, which are not persistent, and only really exist client side.. but i dont see any technical reason not to go with presistent subsidies transport tycoon style; other than it requires designing a database instead of just using a memory array, and that read/writes would be slower than purely in memory... I dunno, What are your thoughts there @midspace ?
ok have a test mission up as of last commit, its just investigate 0,0,0 but seems to confirm the system is workable.. :)
looks like our mission system needs to cater for a mission start message a mission complete message and an option mission failure message too
Ok some thoughts here @midspace - Missions should come in two desticnt flavor classes - 1: Procedural missions. These are the automatic missions. At the very least it should be able to: A) Detect if a station has low stock of a defined list of items (eg silver, platinum, iron, ice, uranium etc) create a "bonus delivery" mission for ore types that are low or exhausted. TO npc stations only. Because it will create a target GPS maybe allow players to manually create bonus delivery missions for their own zones. (this allows more lively feeling servers, and has the risk its a trap; and players dont need to expose their trade ships/stations if they dont want to)
B) Can we scan the "last online" data for grids. Any grid which has not seen any of its builders in 3 months (user defined period?) gets added to the automatic "investigate" mission rotation.. this rotation could also include NPC ships that spawn (or went adrift) far from anyone. So we use the "investigate location X" missions randomly and pick a random abandoned grid. (this allows players to deal with abandoned structures; and is more immersive in the process)
C) scripted mission assigned to the "random trigger" may if a random check passes trigger a random scripted mission chain on a random player. (but otherswise does not interact with the scripting system specifically)
2: Scripted missions.
These are configured by a settings file that triggers a mission chain. The start triggers could be defined as specific conditions (such as the demo mission; or completion of certain prior missions, or checking for missions while in proximity of a particular npc station etc) or the chains could be started by semi random events which initiate the mission chain and offer it to someone who has indicated the wish to be advised of missions. (ie the /mission command)
Eg the trigger could be defined as "random / if player bal > 25000" that could trigger an ambush investigate mission (to an npc pirate or admin created grid allocated to this purpose)
These classes of missions could work independantly. The purely procedural missions would run independant of the scripted missions.. although at a later stage the procedural system could also trigger the start of defined scripted missions.. it wont actually concern itself with managing the scripted mission system itself. The procedural managment loop could also be used if we want to tweak how reactive pricing works if we want "delayed" changes instead of instant like now - since the procedural system will be checking stock on hand anyway.
The procedural missions should be possible to add without too much complexity, as we have most of the data (stock on hand, locations of stations) available already. The only question is can we access the last online? if not we could use our own "seen" database and compare with grids in the world.
The "scripted system" can probably be left for now beyond perhaps a placeholder in the procedural mission processing loop.
Works in concert with the ability to buy/sell commodities.. create "delivery contracts" or work contracts for freighter style players to deliver x number of goods to player y pays on completion of delivery
could add new contract styles as we develop mod
contracts: deliver x item to y player resupply fuel to y player rearm ammunition to y player/faction
more nefarious ones - kill player X destroy objective X etc
will require giving the player a GPS coordinate for the delivery
could work a number of ways - easy way - when player x arrives at location y, automatically remove item from inventory and pay the contract
advantages: can use existing modapi abilities; no special blocks needed
disadvantages: we are limited to supply in players inventory, ITS A TRAP could be used to lure freighters to ambushes, not very realistic, you are basically delivering to an empty location and cargos are magically transferred to the buyer who probably isnt anywhere near there
work around, contract could partially pay for partial delivery, allowing player to grab more from his ships stores, and keep getting part paid until the contract is fulfilled, or location could be tied to the buyer, so the delivery doesnt auto transfer unless the buyer is nearby to accept it
technical needs: location and inventory polling based on particular player id, tracking contract conditions and fulfillment; can the mod api allow a player to have a shipment put in his inventory that is bigger than the server allows.. or should we not transfer more than he can carry, requiring some realism as they have to unload their inventory to a crate to get the rest of delivery
hard way - spawn a ship or special cargo block at the delivery location, or require that a place to dock exits; player has to dock and unload the shipment there
advantages - realistic sort of, no limit to cargo size, factions could build trade platforms for deliveries, could use the new auto pilot precision mode for docking; so deliverys could still arrive if the pilot logs off
disadvantages - harder to code, may require custom blocks, needs to prevent the delivery guy simply stealing his cargo back.. so it should lock the block or remove the items as they transfer if a delivery player logs off - how do we complete the delivery..
work arounds - this would definately need the buyer to be nearby; may not be possible to do without changes to keen mod api - as some ways to do it may require removing items from crates automatically
waaaay future milestone enh tho