Page 1 of 2

annoying error

Posted: Sun Sep 06, 2009 10:58 am
by dude77
i made a small map and got 1 allied soldier to follow me, when i go into a room with a german in it it freezes and quits me out from the game and on the console it says this:

~~script error: cannot cast 'NIL' to float
wait self.waittime (global/friendly.scr, 1172)

~~script error: cannot cast 'NIL' to float
while (isalive self) (global/friendly.scr, 228)

***********************************
ERROR: Command Overflow. Possible infinite loop in thread.
***********************************
----- server shutdown -----
==== shutdown game ====

-----------------------------------



any help :(

Posted: Mon Sep 07, 2009 3:22 am
by Aprop
Can you post your map scripts?
Do you have any infinite loops in scr, like

Code: Select all

while(1)
{
      ......
}
without 'wait' cmds inside?
...or try setting waittime to float, on initialization, eg:
$myaliedsoldier.waittime = 5 //see m3l2.scr for correct value

Posted: Mon Sep 07, 2009 7:19 am
by dude77
xec global/auto.scr

level waittill prespawn
level waittill spawn

//---------------------------------------------------------------------------
main:
//---------------------------------------------------------------------------

waitthread InitPlayer
end


level.friendly1.targetname = friend1
level.friendly2.targetname = friend2
level.friendly3.targetname = friend3

thread FriendWait

end

$friend1.destination = $player
$friend2.destination = $player
$friend3.destination = $player

// Sets the type of friendly soldier
$friend1.friendtype = 1
$friend2.friendtype = 1
$friend3.friendtype = 1

// stagger how far away they keep from their destinations
$friend1.distance = 175
$friend2.distance = 225
$friend3.distance = 250

// setup the friendlies to follow the player...
$friend1 thread global/friendly.scr::friendlythink
$friend2 thread global/friendly.scr::friendlythink
$friend3 thread global/friendly.scr::friendlythink

end


----------------------------------------------------

there dosent appear to be any loops but the computer dosent seem to like the last part of the script, apparently that loops, u know more about this than me.

write back asap

Posted: Mon Sep 07, 2009 9:43 am
by Smithy
exec global/auto.scr

level waittill prespawn
level waittill spawn

//---------------------------------------------------------------------------
main:
//---------------------------------------------------------------------------

waitthread InitPlayer //You have no "InitPlayer" thread in your script, me thinks you copied this from a stock map or test_ai?
end

level.friendly1.targetname = friend1
level.friendly2.targetname = friend2
level.friendly3.targetname = friend3

thread FriendWait //You have no "FriendWait" thread in your script

end

$friend1.destination = $player
$friend2.destination = $player
$friend3.destination = $player

// Sets the type of friendly soldier
$friend1.friendtype = 1
$friend2.friendtype = 1
$friend3.friendtype = 1

// stagger how far away they keep from their destinations
$friend1.distance = 175
$friend2.distance = 225
$friend3.distance = 250

// setup the friendlies to follow the player...
$friend1 thread global/friendly.scr::friendlythink
$friend2 thread global/friendly.scr::friendlythink
$friend3 thread global/friendly.scr::friendlythink

end
exec global/auto.scr

level waittill prespawn
level waittill spawn

//----------------------------------------------------------------------------
main:
//----------------------------------------------------------------------------

thread FriendInit //or waitthread FriendInit

end

//----------------------------------------------------------------------------
FriendInit:
//----------------------------------------------------------------------------


level.friendly1.targetname = friend1
level.friendly2.targetname = friend2
level.friendly3.targetname = friend3


$friend1.destination = $player
$friend2.destination = $player
$friend3.destination = $player

// Sets the type of friendly soldier

$friend1.friendtype = 1
$friend2.friendtype = 1
$friend3.friendtype = 1

// stagger how far away they keep from their destinations

$friend1.distance = 175
$friend2.distance = 225
$friend3.distance = 250

// setup the friendlies to follow the player...

$friend1 thread global/friendly.scr::friendlythink
$friend2 thread global/friendly.scr::friendlythink
$friend3 thread global/friendly.scr::friendlythink

end
I think that would be better?

Posted: Mon Sep 07, 2009 3:24 pm
by dude77
didnt seem to help, as soon as my ally encounters the german it freezes up and exits the game :evil:

Posted: Mon Sep 07, 2009 8:40 pm
by Aprop
Do you have any triggers near that room?
Remove'em...
and replace exec global/auto.scr with exec global/friendly.scr

Posted: Tue Sep 08, 2009 6:58 am
by dude77
i dont have any triggers
i'll change that and see how it goes
thanks

Posted: Tue Sep 08, 2009 7:12 am
by dude77
Aprop wrote:Do you have any triggers near that room?
Remove'em...
and replace exec global/auto.scr with exec global/friendly.scr

i done that but now the music wont play and he wont follow me, but the error dosent come up?
thanks
any other ideas?

Posted: Sat Sep 12, 2009 3:23 pm
by dude77
please people i really want to know how to get this working!!! if u manage to get allied soldiers to follow you AND attack enemy soliders in a single game tell me how you did it, i wont need an error solution if u can tell me!!
:D

Posted: Thu Sep 17, 2009 3:16 pm
by Smithy
dude77 wrote:please people i really want to know how to get this working!!! if u manage to get allied soldiers to follow you AND attack enemy soliders in a single game tell me how you did it, i wont need an error solution if u can tell me!!
:D
Just realised, at the top you said you have 1 ally, this script is for 3 allies lol. Thus "friendly1 2 3" etc...

You need to have 3 and give each ally a targetname of friendly.

I.E.

Key: $targetname

Value: friendly

Then you need to set their #fnum, you can also set their #friendtype.

I.E.

Key: #fnum

Value: 1

Key: #fnum

Value: 2

Key: #fnum

Value: 3


Otherwise you'll have to edit the script again for just one ally.

exec global/auto.scr

level waittill prespawn
level waittill spawn

//----------------------------------------------------------------------------
main:
//----------------------------------------------------------------------------

thread FriendInit //or waitthread FriendInit

end

//----------------------------------------------------------------------------
FriendInit:
//----------------------------------------------------------------------------


level.friendly1.targetname = friend1


$friend1.destination = $player


// Sets the type of friendly soldier

$friend1.friendtype = 1

// stagger how far away they keep from their destinations

$friend1.distance = 175

// setup the friendlies to follow the player...

$friend1 thread global/friendly.scr::friendlythink

end
Give him an #fnum of 1 and the $targetname friendly.

Posted: Fri Sep 18, 2009 7:55 pm
by dude77
it still dosent work!! he follows me fine, but when he meets an enemy it still freezes!!
theres defenitely something wrong with the script, i took it out and he kills enemies fine....
maybe i didnt understand your post,
could you possibly do the script for me?

thanks

Posted: Mon Oct 05, 2009 3:05 am
by Aprop
You can use your own script to control soldiers... this should work for you, of course you have to change $cappy to your soldier targetname

Code: Select all

main:

level waittill spawn
wait 1
$cappy thread follow $player 1000 5


end



follow local.player local.distance local.wait:		

self.destination = local.player
self.distance = local.distance

if (self.distance <= 10)
{
	self.distance = 50
}

while (isalive self)
{

	if !(vector_within self.origin self.destination.origin self.distance)
	{
		self runto self.destination
	}
	wait local.wait
}
end
ps:
dude, I'd like to see your map and scr file to find out what cause crash....

Posted: Tue Oct 13, 2009 7:07 pm
by dude77
um, ok, thanks for the post by the way,
havent tried it yet, how do i send you my map file??

Posted: Tue Oct 13, 2009 9:39 pm
by HeavenBound
Post it. lol

Posted: Wed Oct 14, 2009 7:00 am
by dude77
yeah but how?? theres no option to 'post map',
i would if i new how!?