help making level accurate equipment

Freeform discussion about anything related to modding Transcendence.
Post Reply
Drako Slyith
Fleet Officer
Fleet Officer
Posts: 1036
Joined: Wed Feb 03, 2010 4:28 am
Location: Researching how to make St. Kats star go supernova.
Contact:

I'm working on the Pilgrims/Freelancers mod. One idea was to make them start with near level accurate equipment. I drew up a few lines for the weapon:

Code: Select all

					(setq sysLevel (subtract (sysGetLevel) 2))
					(if (leq sysLevel 0)
						(setq sysLevel 1)
					)
					(setq weapList (itmGetTypes "w"))
					(shuffle weapList)
					(setq condition true)
					(enumWhile weapList condition item
						(block nil
							(if (eq sysLevel (objGetLevel item))
								(block nil
									(setq condition Nil)
									(objAddItem gSource (itmCreate (itmGetUNID item) 1))

								)
							)
						)
					)
I have all the variables blocked btw.
I think the problem is that it isn't getting a weapon. My idea is to enumWhile over all the weapons in a list that is shuffled so they can all have different weapons, and stop once it finds a weapon that works. But when I dbgLogged everything I think the problem is it won't get the item. (I'm adding it to the cargo hold because I already have code in place to install it automatically)
Image
Image
Play in over 100 systems in a network. Play the 2011 Mod Of the Year
and the highest rated mod on Xelerus, The Network.
Play the July Mod of the Month, Fellow Pilgrims!
Play My other mods as well
(Drako Slyith)* I am a person
(Eliza chatbot)> Do you believe it is normal to be a person?
shanejfilomena
Fleet Officer
Fleet Officer
Posts: 1533
Joined: Tue Mar 22, 2011 8:43 pm
Location: Alaska
Contact:

You mean like this? to get something near the level of the player system or the player?
I think you might be able to adapt this set up :

(block (level)
;; we'll add some code here to dynamically add items to
;; the ship's inventory.
(setq level (sysGetLevel))
(itmEnumTypes "*" theItem
(block Nil
(switch
;; we don't want any common or uncommon
(geq (itmGetFrequency theItem) 10)
Nil

;; we don't want notRandom
(leq (itmGetFrequency theItem) 0)
Nil

;; no items of lvl less than 2 below system level
(leq (itmGetLevel theItem) (subtract level 3))
Nil

;; no items of lvl 2 higher than the system
(geq (itmGetLevel theItem) (add level 3))
Nil

;; if we have a weapon, shield or device add 1 or 2
(itmHasAttribute theItem "MajorItem")
(objAddItem gSource theItem (random 0 2))


)
)
)

# code by Prophet : it was the closest match to what you were asking :

I see the Major difference in the code you have to this being you are trying to specify the "w" where as Prophet uses a "*" and then later in the code specifies so as to drag the argument into a conversation.
Flying Irresponsibly In Eridani......

I don't like to kill pirates in cold blood ..I do it.. but I don't like it..
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

[quote="Drako Slyith"]

Code: Select all

  .. snip ..
  (if (eq sysLevel (objGetLevel item))
  .. snip ..
What does (objGetLevel item) return?

Hint: item is not an object :)

You should also be aware that itmEnumTypes returns a list of UNIDs, so you have to create the item first to use any `itm*` functions. Or you can try an see if you can get the level from the type (UNID) using `typ*` functions.

Also, be careful with naming your variables... `item` is the name of a built in function. In this case it is no so bad, but if you ever needed to use that function within your enum, you would not be able to... my own standard is to use `itm` as the loop variable when looping over items.
Post Reply