[mod idea+work help] Hive behavior

A place to discuss mods in development and concepts for new mods.
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:

Thank you all for all you help. I started working on the feeding code yesterday. I drew up this code for it:
http://paste.neurohack.com/view/Yhrja/.
The problem with it (so far) is that "hunger" keeps being reset at 0, no matter where the ship is. I even put the range on it at 0, and it still keeps setting it at 0. I checked and the timer on the code to increase the hunger works fine.
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?
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?

The problem with it (so far) is that "hunger" keeps being reset at 0, no matter where the ship is.
The problem is that the WaitTimer resets the hunger

Code: Select all

(objSetData gSource "Hunger" 0)
Then when FeedBehavior is invoked, it also invokes the WaitTimer-- which resets the hunger.

Drako, can you tell me which pastes are the "final" product? I've been keeping tabs on this but I got lost at the last 3 pastes. I don't know how to string them together.
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.
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:

Ok I have the code for the behavior and natural selection in one convenient paste here:http://paste.neurohack.com/view/YNjwR/.

I know the 'WaitTimer resets hunger. I want it to. I think the problem is that the range detector is messed up somewhere, but I don't know where. My idea is that as hunger increases, their search radius for food expands. If the search radius finds a food source, they go to it, then hold on top of it (except for if they're carnivores) and wait for a time, then go back to normal behavior. Carnivores will kill a ship, dock with it for a time then go back to wandering.
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?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

The problem is most likely, in your FeedBahaviour, that when you don't find any ships, your `nearFood' variable stays `nil'. When you compare the distance, it will return 0 or nil, and (leq nil 0) returns `true'. That means your first test for distance in that behaviour results in the events triggering. Also, since `time' is not set at that point, the event will trigger immediately.
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:

Ok thanks.

EDIT: I've managed to find out the problem is it's returning the center of the system. I assume that means that it's returning nil for the "nearFood".
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?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

You can always try a dbgLog your variables (that is what I do when i need to fix things). Nil is identical to system center, or 0,0 coordinates.
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've managed to identify the problem as the search criteria. I even copy pasted from the "EncountersVol1.xml" and it still won't work.
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?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

Can you paste the bit that is not working? It can be a bit hard to go through the big pastes looking for something you don't know what is :)
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:

The part I think isn't working is this:

Code: Select all

			(switch 
				(eq (objGetData gSource "Astrovore") true)
					(block nil
						(setq nearFood (sysFindObject gSource "t:asteroid; N:60;"))
						(if (eq nearFood true)
						(objSendMessage gPlayership nil "found an asteroid")
						(shpCancelOrders gPlayership)
						(shpOrder gPlayership 'goto nearFood)
						)
						(objSendMessage gPlayership nil nearFood)
						
					)
				(eq (objGetData gSource "Carnivore") true)
					(block nil
						(setq nearFood (sysFindObject gSource "sN+unid:&scAdaptiveAIShip; N:60"))
					)
				(eq (objGetData gSource "Solar") true)
					(block nil
						(setq nearFood (sysFindObject gSource "t:star; N:60"))
					)
				(setq nearFood (sysFindObject gSource "t:asteroid; N:60"))
			)
It's supposed to select the nearest food source and set it as "nearFood". If it isn't any of the categories, the default is to eat asteroids.
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?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

OK


(eq (objGetData gSource "Astrovore") true)

You dont need the comparison to true in the switch. If the objGetData returns
any value that is not nil, then it will be true.


(sysFindObject gSource "t:asteroid; N:60;")

I am not sure t:asteroid is a legal criteria (check the wiki page)
You can try "t +asteroid +N:60"


The first: (if (eq nearFood true) ...

Again, you don't need to compare nearFood to true. If it is not nil it is true
Also, you have no block after the `if', so the only expression that will be run
is the objSendMessage. Remember your blocks!


A bit later, criteria "t:star ..."

Again, i don't think t:star is valid. Use "t +star"
Look for other criteria you made like that and correct them.


Hope that helps
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 looked in the xml, and the criteria for asteroids is copied directly from the Ferian data. Also, in Worlds.xml stars have the attribute "star".
I figured that you didn't have to use (eq value true) but I wanted to isolate the problem, so I used what I knew would work.
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?
User avatar
alterecco
Fleet Officer
Fleet Officer
Posts: 1658
Joined: Wed Jan 14, 2009 3:08 am
Location: Previously enslaved by the Iocrym

In that case all i can see is the missing block
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 dbgLog'ed nearFood and I got a list back, so that's the problem I think. I have "n" in the search criteria so it shouldn't be returning a list, so I'm very confused.

EDIT: I changed the search criteria to "n+t:asteroid" and nothing dbgLog'ed so I think it is returning nil now.
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?
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?

If you want the nearest object, use "N" in the search criteria.

Lowercase "n" in the search criteria will return anything within X light- seconds.
Uppercase "N" in the search criteria will return the nearest object to the source.
(Come on... let me be right this time...)
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.
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 scrapped my old eating behavior code and started from scratch. I already got the carnivore behavior working. But I'm working on the code for the solar behavior, and I need to know if there is a way to make some code come into effect after the ship has completed their orders. I know you can make the ship do orders one after another, but can you do the same things with timers, i.e.

Code: Select all

(block nil
(shpOrder gSource 'goto food)
(sysAddObjTimerEvent 90 gSource 'backToWandering)
)

EDIT: Nevermind, I got it to work. Yay! now my solar behavior is working, so now I just have to make the asteroid behavior.
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?
Post Reply