strange happenings

Blitz3D Forums/Blitz3D Programming/strange happenings

mtnhome3d(Posted 2008) [#1]
I have my AI code and in the code i call moveentity and it does nothing but elsewhere in my code if i call moveentity and it works. whats wrong? here the AI code that has to do with the prob.
If e\state = chase
		PointEntity e\e,p\e:MoveEntity e\e,0,0,1
		EntityColor e\e,0,255,255
		
	;if roam then move around
	ElseIf e\state = roam
		TurnEntity e\e,0,10,0:MoveEntity e\e,0,0,1
		EntityColor e\e,255,255,0
				
	; if attack then shoot at enemy
	ElseIf e\state = attack
		PointEntity e\e,p\e
		EntityColor e\e,255,0,0
		If br > 30
			fire(2)
			br = 0
                endif
        endif
 



Ross C(Posted 2008) [#2]
Is this code in a function? Does the code pass across the type object so the function can work with it? Whats is p\e? Need more info :o)


Ross C(Posted 2008) [#3]
Also, is e/state a string variable? Or:

If e\state = chase


does the chase variable represent a number?

Again, if this is used within a function, make sure the "chase", "roam" and "attack" variables are made global at the start of your code, or else, they won't hold any value when entering a function.

Add a STOP command in the function if it is one, and check the value of e\state. The reason moveentity isn't working, is because it's never called, because e\state doesn't meet any of the criteria of the IF statements


mtnhome3d(Posted 2008) [#4]
heres the whole function. p\e is the player entity e\e is the enemy entity. The states are consts such as chase=2. the function works to the moveentity command. it like its been commented out. it turns, it changes color but wont move.
[edit] the states a globals not consts



Ross C(Posted 2008) [#5]
Hmmm, al seems good. Try putting in a debug line into each of the state evalutions:

If e\state = chase
		PointEntity e\e,p\e:MoveEntity e\e,0,0,1
		EntityColor e\e,0,255,255
                DebugLog(" State = chase. e\e = "+e\e+". p\e = "+p\e)


Do that with each state. Run the code, click the stop on the debugger, and read off what the debug info is. If no debug text comes up telling you the state and the entity handles, then you know there's something up. If it does come up, check to see if the entity handles have numbers except zero attached to them.


mtnhome3d(Posted 2008) [#6]
its all working except for the moveentity. the debuglog returns what it should. i tried translateentity but it didn't work either. i'm not using any external libs.
i'm going to test this on another computer


mtnhome3d(Posted 2008) [#7]
i tested it on a different computer and the problem still presists.


Ross C(Posted 2008) [#8]
Send the code to my email address please.

Last edited 2012


Ross C(Posted 2008) [#9]
Hmm, don't know if this is a typo or whether it would affect your code:

	ElseIf e\state=dead
		EndIf	;<<<<< THIS LINE
		
		TurnEntity e\e,0,3,0
	EndIf


That's one too many End IF's by my count.

EDIT: I'm wrong on that point, but:

	ElseIf e\state = attack
		PointEntity e\e,p\e
		EntityColor e\e,255,0,0
		If br > 30
			fire(2)
			br = 0
	        ElseIf e\state=dead

		EndIf	
		
		TurnEntity e\e,0,3,0
	EndIf


If you indent that, your END IF is in the wrong place. It might cause some problems. It surely should be?

	ElseIf e\state = attack
		PointEntity e\e,p\e
		EntityColor e\e,255,0,0
		If br > 30
			fire(2)
			br = 0
		EndIf	

	ElseIf e\state=dead
		
		TurnEntity e\e,0,3,0
	EndIf



mtnhome3d(Posted 2008) [#10]
ok i sent it. after i sent it i got rid of
	TurnEntity e\e,0,3,0
	EndIf
	MoveEntity e\e,0,-.3,0

and the roam state worked. wierd!. but the rest doesn't work still.


Ross C(Posted 2008) [#11]
Ok, after a quick look, it's pretty easy :o) It was hard at first cause i kept getting killed, BUT, the game just froze. No game over or anything. SO, i increased by hp's to 300000000 odd.

Ok, your problem is your collision response is set to stop upon collision. SO, your tanks can't move anywhere, because there are being forced to stop when colliding with the floor. It's not the right type of collsion response for something that needs to slide along the ground.

Change it to 2 and they come after you! Pretty fast as well hehe.


Const world_col=1,playr=2,enem=3,bul=4,ebul=5
Collisions playr,world_col,2,3
Collisions playr,enem,2,2
Collisions enem,world_col,2,2 <<<< this line changed to 2,2
Collisions bul,world_col,2,1
Collisions bul,enem,2,1
Collisions ebul,world_col,2,1
Collisions ebul,playr,2,1



mtnhome3d(Posted 2008) [#12]
thanks very much. sorry about you getting killed so often. i'll fix that.