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

Members Online

»
0 Active | 6 Guests
Online:

LATEST FORUM THREADS

»
water
CoD4 MP Mapping
Rainbow HELP....
CoD4 MP 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 SP Mapping
CoD 4 mapping and level design for single player.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, supersword, playername, novemberdobby
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Getting a spawner AI to shoot
MidnightMan21
General Member
Since: Aug 11, 2011
Posts: 7
Last: Feb 22, 2013
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Tuesday, Jul. 3, 2012 07:08 pm
I have an spawner AI who spawns after the player touches a trigger. After he spawns, I want to him to shoot his weapon.

Problem:
However, I'm given the following error message: "not an actor".
Here is my script:

Code:
rpg()
{

rpg_guy = getent("rpg_guy1","targetname");
rpg_guy shoot();

}


Obviously, the game will not accept spawner entities as actors. I've never fully understood what a spawner is or how it all works.

How can I have the actor shoot using the proper syntax?

edited on Jul. 3, 2012 07:14 pm by MidnightMan21
Share |
3st0nian
General Member
Since: Jan 14, 2008
Posts: 182
Last: May 24, 2013
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 SP Mapping
Posted: Thursday, Jul. 5, 2012 02:38 am
Add this line somewhere in the main function after the maps\_load::main();
Code:
getent("rpg_guy1","targetname") thread add_spawn_function( ::rpg);

(Above line must be called before the actual actor is spawned)

and then rpg function looks like this
Code:
rpg()
{
self shoot();
}


Hope it works

Share |
MidnightMan21
General Member
Since: Aug 11, 2011
Posts: 7
Last: Feb 22, 2013
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Thursday, Jul. 5, 2012 09:31 am
Thank you! I'll try this.

If you don't mind, can you explain why this works?
What exactly does 'add_spawn_function' do?
When should I use it?

Share |
MidnightMan21
General Member
Since: Aug 11, 2011
Posts: 7
Last: Feb 22, 2013
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Thursday, Jul. 5, 2012 09:57 am
It seems to work.

Thank you very much! :)
Share |
3st0nian
General Member
Since: Jan 14, 2008
Posts: 182
Last: May 24, 2013
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD4 SP Mapping
Posted: Saturday, Jul. 7, 2012 03:25 am
Anything that spawns from this spawner will run this function.
As I understand, spawner is just an entity on map. It is used to spawn an actor(the actual guy that will run and shoot).
So when you use getent, this refers to a static spawner, not an actor spawned from it.
Without add_spawn_function, your code must look like this
Code:
rpg()
{
rpg_spawner = getent("rpg_guy1","targetname");
rpg_guy = rpg_spawner stalingradSpawn();
rpg_guy shoot();
}

rpg_guy = rpg_spawner stalingradSpawn();
This line tells that rpg_guy is an actor spawned from rgp_spawner spawner entity.

Basically you have to spawn all actors manually and make references to them.
But with add_spawn_function, game waits until actors from that spawner has spawned
and then runs given function on them.

This function is very useful with vehicle actors who get spawned automatically with vehicle or if you want
to spawn actors via spawn trigger(like youre doing now). IW has used this function a lot in their scripts.
Share |
MidnightMan21
General Member
Since: Aug 11, 2011
Posts: 7
Last: Feb 22, 2013
[view latest posts]
Level 0
Category: CoD4 SP Mapping
Posted: Saturday, Jul. 7, 2012 10:56 am
Oh, I see!

I find the explanation of the why's and how's of it extremely useful, so I know when to use it properly in the future.

Thank you very much, I really appreciate it!
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 4 : CoD4 SP Mapping

Latest Syndicated News

»
Why console gaming is dying
Quote:Consider this: Dedicated gaming sales — including living-room consoles...
Devs: Games are being dumb...
Click 'read more' to view the contents of this post.
Loadout
Gun Crafting to the Max. edited on Sep. 25, 2012 06:57 pm by Morp...
Introducing the Source Fil...
Surprised this wasn't made a long time ago. Sounds like a nice little feature.
Introducing the Source Fil...
The Source Filmmaker (SFM) is the movie-making tool built and used by us he...

Partners & Friends

»