a looting mod & several questions

Freeform discussion about anything related to modding Transcendence.
RPC
Fleet Admiral
Fleet Admiral
Posts: 2876
Joined: Thu Feb 03, 2011 5:21 am
Location: Hmm... I'm confused. Anybody have a starmap to the Core?

Yes, if it's showing up something's bad. Can you paste the code? If it is what you posted, you would get an error saying that "we" is not a proper function.

I'll post some code when I get to a computer.
Tutorial List on the Wiki and Installing Mods
Get on Discord for mod help and general chat
Image
Image
Der Tod ist der zeitlose Frieden und das leben ist der Krieg
Wir müssen wissen — wir werden wissen!
I don't want any sort of copyright on my Transcendence mods. Feel free to take/modify whatever you want.
Schnobs
Miner
Miner
Posts: 36
Joined: Fri Mar 23, 2012 8:49 pm

RPC wrote:Yes, if it's showing up something's bad. Can you paste the code? If it is what you posted, [...]
Don't be silly -- the "code" in my last post is no actual code, I thought that was obviuos. It's just meant to illustrate how and where I pieced it into an already-enabled extension.

As to my actual code, I don't ask you (or anybody) to debug it for me: doing it myself is part of the deal. I just don't quite know how to get started with debugging. Anyway, here it comes:

Code: Select all

(block (wrecks loot_ok it)
	(setq wrecks
		(filter (sysFindObject gSource "tM -populated; N:25")   ; give me all wrecks in range, filter runs only against that limited number
			wreck								; for every wreck, do
			(enumWhile (objGetItems wreck "*") loot_ok it	; get all items in hold -- loot_ok=True/NIL it=items
				(block (price vpt)					; here come the actual tests for "filter" ---- vpt=value_per_ton

					(setq price (divide (itmGetActualPrice it) (if (itmIsDamaged it) 2 1)))	; get price, damaged items at half value
					(setq vpt (divide (multiply price 1000) (itmGetMass it)))			; caculate vaue_per_ton
					(setq loot_ok (gr vpt 500))								; set threshold here
					; 
					; this is a bit silly: if vpt is high enough, loot_ok will be set to NIL
					; however, NIL is needed to break the loop
					; we want to break, because:
					; a single worthy item is enough, no need to check the rest
					;
					(if (and value_ok (shpIsFuelCompatible it)) setq (value_ok NIL)))	; we always want usable fuel, regardless of vpt
																; remember, value_ok=TRUE if the value is *not* ok (I should find a better name)
																; TODO: add further tests here
																; like, ammo for installed weapons
			)	; this closes "enumWhile"
		)		; this closes filter, now "wrecks" is populated -- or not.

                (if (gr (count wrecks) 0)										; if the list if of non-zero size
			(enum wrecks wreck										; split it into chunks and
				(sysCreateEffect &oreShockwave; wreck (objGetPos rock))				; make each wreck blink

                	)
		)
	)
)
The fun part ist that I don't have the device installed, so I shouldn't get any scan at all. The (original) code should determine that I don't have the device and not call any scans, so my code shouldn't even run. And yes, I'm sure that I didn't insert my stuff in the wrong place: counting brackets is easy, especially if your editor does it for you. I double-checked when it didn't run, and again before submitting this post: it's (determine if the player can scan (do ore scan) (do loot scan)), only with more brackets and actual code.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

You need to set loot_ok to true initially. Your item enumWhile never runs because of that i would think.

You use value_ok later, but don't define it in a block... is that on purpose?
Get your own Galactic Omni Device
Get it now. It's free!!
Image
Schnobs
Miner
Miner
Posts: 36
Joined: Fri Mar 23, 2012 8:49 pm

alterecco wrote:You need to set loot_ok to true initially. Your item enumWhile never runs because of that I would think.
Thanks!
That's not the only problem, but one I'd never have spotted. Although in hindsight.... <facepalm>
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

Schnobs wrote:
alterecco wrote:You need to set loot_ok to true initially. Your item enumWhile never runs because of that I would think.
Thanks!
That's not the only problem, but one I'd never have spotted. Although in hindsight.... <facepalm>
Just not to be annoying: but probably is because your just testing :
but I think 25 is way too short: you would basically be parked next to it.

I think 180 works fine and I experimented with other numbers in the past: but 180 the engine likes :
I don't know why: it just works better for me.
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
Schnobs
Miner
Miner
Posts: 36
Joined: Fri Mar 23, 2012 8:49 pm

shanejfilomena wrote: Just not to be annoying: but probably is because your just testing :
but I think 25 is way too short: you would basically be parked next to it.
No worries: N:25 gets to the edge of the screen, though only barely, and it doesn't reach into the corners.
Pushing this up to 40 would cover every visible wreck -- any more would be a waste of CPU cycles.

Depending on the situation, you might still want a means to scuttle wrecks.
Schnobs
Miner
Miner
Posts: 36
Joined: Fri Mar 23, 2012 8:49 pm

Guess I've been too smart for my own good:

Code: Select all

	(setq worthy_wrecks
	    (filter near_wrecks wreck
		(block (donotloot)
		    (setq donotloot TRUE)
		    (enumWhile (objGetItems wreck "*") donotloot it
Next I go over all items in a wreck, assigning "donotloot=True/Nil" depending on some criteria.
This works, I can see it work on the debug console. However, it does not function as a filter:

As long as there's anything in the hold, the wreck will be added to the "worthy_wrecks" list.
Why is this so?
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

Schnobs wrote:Guess I've been too smart for my own good:

Code: Select all

	(setq worthy_wrecks
	    (filter near_wrecks wreck
		(block (donotloot)
		    (setq donotloot TRUE)
		    (enumWhile (objGetItems wreck "*") donotloot it
Next I go over all items in a wreck, assigning "donotloot=True/Nil" depending on some criteria.
This works, I can see it work on the debug console. However, it does not function as a filter:

As long as there's anything in the hold, the wreck will be added to the "worthy_wrecks" list.
Why is this so?
Loot Auton : http://xelerus.de/index.php?s=mod&id=218
this auton's code should give you more of a working idea you need to filter things out with and how insane it will drive you to build the filter for how you would like it to be ( as in working / worthy and detailed ) you can order the looting of only fuel if you want :)

Sometimes : there are only so many ways to go " BOOM " : communicate with the author of the Auton if you can not figure out a way to adapt the code : sometimes, they have seen a easier way after they spent weeks driving themselves nuts making it work :).
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
Schnobs
Miner
Miner
Posts: 36
Joined: Fri Mar 23, 2012 8:49 pm

I think I solved the enumWhile riddle:

Code: Select all

(filter near_wrecks wreck
   [...]   
          (enumWhile (objGetItems wreck "*") donotloot it
Will return item, item, item until something sets "donotloot" to NIL, thus breaking the loop.
Even if the loop breaks on the first run, it will still return one item.

A list of one item is decidedly not empty, the filter sees this as TRUE. That way, every weck with any item on board will pass the filter.

I tried (if donotloot (setq it Nil)) at the very end of the enumWhile loop, but that made the scanner work in reverse, only flagging worthless wrecks. I have no idea why. Interestingly, it needs to be at the very end of the loop. If I do as much as adding another (dbgOutput "blah") afterwards, the Nil will have no effect whatsoever.
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

If you still need help, could you then post a more complete example? If not, then great. Good work ;) Also, you are welcome to ping me on irc.
Get your own Galactic Omni Device
Get it now. It's free!!
Image
Schnobs
Miner
Miner
Posts: 36
Joined: Fri Mar 23, 2012 8:49 pm

Quoting myself, but hey:
Schnobs wrote:I think I solved the enumWhile riddle:

Code: Select all

(filter near_wrecks wreck
   [...]   
          (enumWhile (objGetItems wreck "*") donotloot it
Will return item, item, item [...]
<buzz sound> WRONG! it shouldn't return items! It should return either True or Nil...

Yes, "filter" accepts pretty much everything. Any string or list will be considered as TRUE, unless the string/list is empty, in which case it's NIL. The single most important thing I didn't get was that I shouldn't return the items, that the items really don't matter, that the only thing that counts is wether I return anything at all.

If anyone's interested, the full code can be found at http://paste.neurohack.com/view/YYvEG/
I'm not 100% confident yet, but it seems to work more often than not.
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

Schnobs wrote:
Atarlost wrote:Wrecks are not active. That's something you can check for in the criteria string for sysfindobject.
Nah, I meant only shipwrecks, not stationwrecks. Both are wrecks and inactive and everything... anyway, that's cosmetic.

I now tried my code for the first time and guess what? It doesn't work.
I attached it to the ore scanner, like this:

Code: Select all

(if we may scan
   (scan asteroids for ore)
   (scan wrecks for loot)
)
Now, OnUpdate I get my code displayed on the screen. Is that alone a hint as to the nature of my mistake?

Code: Select all

<Events>		
			<Scan>
				(block (asteroidList)
					; (setq asteroidList (sysFindObject gSource "t +asteroid; N:90;"))
					; (setq asteroidList (filter asteroidList asteroid (objGetItems asteroid "t +Ore;")))
					(setq asteroidList (moeFineOre gSource 90))
					(enum asteroidList asteroid (sysCreateEffect &efGoodgooblygoo; asteroid (objGetPos asteroid)))
					(objSendMessage gPlayerShip Nil (cat "Detected "(count asteroidList) " ore bearing asteroids"))
				)
			</Scan>
		</Events>
Code by Apemant	: but there are only " so many " ways to do it so it works and they will essentially be replicants of Apemant' code.	
efGoodgooblygoo will not work ( for you that is ) : pick an effect :)

If I am reading it right: your trying to lock on to if the item is on the playership?

go to the Dall Sphere : it has answers : make it sooooooooooo much easier and no errors.
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
Schnobs
Miner
Miner
Posts: 36
Joined: Fri Mar 23, 2012 8:49 pm

shanejfilomena wrote: go to the Dall Sphere : it has answers : make it sooooooooooo much easier and no errors.
I'm afraid I do not understand this, nor why you dug up that old example to do... what exactly?
Anyhoo, now you brought it up again, I might as well explain that bit as well:

This will dump lumps of text on the game screen:

Code: Select all

(if we may scan
   (scan asteroids for ore)
   (scan wrecks for loot)
)
This will work just nicely, thanks:

Code: Select all

(if we may scan
   (block Nil
        (scan asteroids for ore)
        (scan wrecks for loot)
))
In other words, if you want to run more than one function, you need to wrap a (block [...]) around them. Merely adding more brackets won't do. I think it was Azziweaver who pointed that out to me on IRC .
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

The Dall Sphere is an Ancient Artifact : it hold many secrets,
I used it's teachings to stop players from running off with my bribe ....and my ships.

Obviously , if you 'have no use for common code' then you are into something that is going to take longer then the fuel tanks will hold for.

No fears : I live forever. I can wait.
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
Schnobs
Miner
Miner
Posts: 36
Joined: Fri Mar 23, 2012 8:49 pm

OK, no that I finished my game I can think about turning this into a "proper" mod, one that others can use...

I wonder how I can get it into the game. "onUpdate" requires some device or item to work from, right? But I don't want it to eat another device slot, that's for sure. Is it possible to make it a ROM? How?
Post Reply