Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 76 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 4
Category: CoD4 Scripting
Scripting and coding with Call of Duty 4.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked
Page
Next Page
subscribe
Author Topic: AI go to nodes
Pablo_Abruzzi
General Member
Since: Jan 30, 2010
Posts: 93
Last: Aug 10, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Wednesday, Feb. 24, 2010 06:56 pm
So I want to do AI who is going to node. I create AI and give him:

Key: targetname
Value: sol1

And I create 2 nodes. First:

Key: targetname
Value: nod1

And second:

Key: targetname
Value: nod

I connect actor with nod1 (he go to him when the mission start).
Then I write the script:

Code:

patrol()
{
        guy =getentarray ("sol1", "targetname");
	node = getNode( "nod", "targetname" );
        wik = getNode( "nod1", "targetname" );
        if ( guy IsInGoal( wik ) )
	{
		guy setGoalNode( node );
	        guy waittill ( "goal" );
        }
}


He is going to nod1, but after that he isn't going to node (nod). Why? Something is wrong with condition??
Please help.
Share |
babycop
General Member
Since: Feb 18, 2006
Posts: 488
Last: Feb 27, 2010
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Thursday, Feb. 25, 2010 04:16 am
instead of: guy =getentarray ("sol1", "targetname");

put: guy =getent ("sol1", "targetname");
Share |
Pablo_Abruzzi
General Member
Since: Jan 30, 2010
Posts: 93
Last: Aug 10, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Thursday, Feb. 25, 2010 01:20 pm
babycop writes...
Quote:
instead of: guy =getentarray ("sol1", "targetname");

put: guy =getent ("sol1", "targetname");


No, no.
He isn't going to node.
Something is still wrong.
Share |
voidsource
General Member
Since: May 5, 2007
Posts: 1513
Last: Sep 1, 2013
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Thursday, Feb. 25, 2010 10:44 pm
how is this guy being spawn? is he being spawn from script or trigger or does he load when the map load? how, because that is important. Also when you are using only 1 ent you have to use "getent" not "getentarray" because the word "array" is for more than 1 entity having the same key/values of w/e your calling out.
Share |
Pablo_Abruzzi
General Member
Since: Jan 30, 2010
Posts: 93
Last: Aug 10, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Friday, Feb. 26, 2010 08:24 am
voidsource writes...
Quote:
how is this guy being spawn? is he being spawn from script or trigger or does he load when the map load? how, because that is important. Also when you are using only 1 ent you have to use "getent" not "getentarray" because the word "array" is for more than 1 entity having the same key/values of w/e your calling out.


My actor wasn't spawned.
He was create in editor - I give him only targetname and tagret nod1.
nod1 = targetname of node.
Share |
voidsource
General Member
Since: May 5, 2007
Posts: 1513
Last: Sep 1, 2013
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Friday, Feb. 26, 2010 11:21 pm
so he loads up in the map when your map finishes loading right?
Share |
Pablo_Abruzzi
General Member
Since: Jan 30, 2010
Posts: 93
Last: Aug 10, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Saturday, Feb. 27, 2010 07:25 am
voidsource writes...
Quote:
so he loads up in the map when your map finishes loading right?


Yes.
Share |
babycop
General Member
Since: Feb 18, 2006
Posts: 488
Last: Feb 27, 2010
[view latest posts]
Level 5
Category: CoD4 Scripting
Posted: Saturday, Feb. 27, 2010 02:08 pm
Don't connect him to nod1 via the editor. If you want to give your actor multiple nodes, you have to do it all via scripting. It should prevent some errors from happening. Here's what you probably want:

Code:
patrol()
{
guy =getent ("sol1", "targetname");
node = getNode( "nod", "targetname" );
wik = getNode( "nod1", "targetname" );
guy setgoalnode (wik);
guy waittill ( "goal" );
guy setgoalnode (node);
guy waittill ( "goal" );
}


If that doesn't work, then the problem is with your second node not being close enough to another one to be part of a path.
Share |
Pablo_Abruzzi
General Member
Since: Jan 30, 2010
Posts: 93
Last: Aug 10, 2011
[view latest posts]
Level 3
Category: CoD4 Scripting
Posted: Saturday, Mar. 6, 2010 08:16 am
It doesn't work. Complile - Yes, but sol1 isn't going to nodes. This is all script:

Code:
#include maps\_utility;

#include common_scripts\utility;


main()
{
	maps\_load::main();
       level.player takeallweapons();
       level.player giveWeapon ("m4_grenadier");
       level.player switchToWeapon ("m4_grenadier");
       level.player giveWeapon ("fraggrenade");
       level.player giveWeapon( "smoke_grenade_american" );
       level.player setOffhandSecondaryClass( "smoke" );
	triggers = getEntArray( "trig1", "targetname" );

	array_thread( triggers, ::triggerThink ); 
thread patrol();      
}


patrol()
{
guy =getent ("sol1", "targetname");
node = getNode( "nod", "targetname" );
wik = getNode( "nod1", "targetname" );
guy setgoalnode (wik);
guy waittill ( "goal" );
guy setgoalnode (node);
guy waittill ( "goal" );
}


triggerThink()
{
	spawner = getEnt( self.target, "targetname" );

	for( ;; )
	{
		self waittill ( "trigger" );
		
		guy = spawner stalingradSpawn();

		if ( spawn_failed( guy ) )
		{
                        wait ( 0.05 );
			continue;
		}

                guy thread aiThink();		
               guy waittill ( "death" );	
	}
}


aiThink()
{
	self endon ( "death" );
	
	self.goalradius = 64;
	node = getNode( self.target, "targetname" );
	for ( ;; )
	{
		self setGoalNode( node );
	        self waittill ( "goal" );
	}
}


I don't connect him to nodes in editor.
Share |
voidsource
General Member
Since: May 5, 2007
Posts: 1513
Last: Sep 1, 2013
[view latest posts]
Level 8
Category: CoD4 Scripting
Posted: Saturday, Mar. 6, 2010 06:24 pm
i would like to help you over xfire. If you have it add me, my names voidsource. cause i cant seem to find wat your error is.
Share |
Restricted Access Topic is Locked
Page
Next Page
subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»