Hi! Welcome to the forum for Platinum Arts Sandbox Free 3D Game Maker. I currently have the forums locked as I am attempting to properly update them.
In the meantime please join the new Discord Server!
If you have any questions please e-mail me through the Platinum Arts website.
In the meantime please join the new Discord Server!
If you have any questions please e-mail me through the Platinum Arts website.
Making NPC's Fight
-
- Member
- Posts: 44
- Joined: April 11th, 2012, 10:14 pm
- Name: Evan Donnelly
Making NPC's Fight
How can I put two types of NPC's into opposing factions so that they attack each other on sight? I want to have guards that are friendly or neutral to you and soldiers that attack them, and also you. But any answer would be helpful if that can't be done.
Helping to map Broken Shield and Revelade Revolution.
- kddekadenz
- Member
- Posts: 423
- Joined: July 17th, 2011, 11:02 am
- Name: kdd
- Contact:
Re: Making NPC's Fight
1) create at least 2 factions in data/rpg/games/yourgame/factions
-> they can be empty, be sure to follow the naming conventions (0.cfg,1.cfg,2.cfg...)
2) Add to critters/.cfg -> r_char_faction number (example: player's cfg: r_char_faction 0; enemie's cfg: r_char_faction 1)
3) add to the script you assigned to the enemie's critter (via r_char_script number) the following code:
and
I hope this helps you 
-> they can be empty, be sure to follow the naming conventions (0.cfg,1.cfg,2.cfg...)
2) Add to critters/.cfg -> r_char_faction number (example: player's cfg: r_char_faction 0; enemie's cfg: r_char_faction 1)
3) add to the script you assigned to the enemie's critter (via r_char_script number) the following code:
Code: Select all
r_script_signal spawn [
r_additem self replacewithnumberofweapon 1
r_equip self replacewithnumberofweapon 0
]
Code: Select all
r_script_signal update [
if (!= (r_get_faction self) (r_get_faction actor)) [
r_action_clear self
r_action_attack self actor
]
]

Kelgar is an advanced RPG beeing developed in Sandbox
-
- Member
- Posts: 44
- Joined: April 11th, 2012, 10:14 pm
- Name: Evan Donnelly
Re: Making NPC's Fight
Thanks. I thought it'd be more complicated than that. I'm liking this forum.
Helping to map Broken Shield and Revelade Revolution.
-
- Member
- Posts: 44
- Joined: April 11th, 2012, 10:14 pm
- Name: Evan Donnelly
Re: Making NPC's Fight
Only problem I'm having is that the console says "actor" is an invalid reference of "incomptible type." It makes no sense because "actor" is used lots my scripts for enemies, although never under "update", only under attacks caused by colliding with the enemy and such. Do you know what I'm doing wrong?
Helping to map Broken Shield and Revelade Revolution.
Re: Making NPC's Fight
The "actor" is not set when update is called (if it is, it's set to NULL).
The bestway to do what you want it to loop through all the entities and act on any you see (r_cansee for that)
The bestway to do what you want it to loop through all the entities and act on any you see (r_cansee for that)
This is not a url, clicking it is pointless
- kddekadenz
- Member
- Posts: 423
- Joined: July 17th, 2011, 11:02 am
- Name: kdd
- Contact:
Re: Making NPC's Fight
You mean like this?Hirato wrote:The "actor" is not set when update is called (if it is, it's set to NULL).
The bestway to do what you want it to loop through all the entities and act on any you see (r_cansee for that)
Code: Select all
if (r_cansee self actor) [
r_action_clear self
r_action_attack self actor
]
Kelgar is an advanced RPG beeing developed in Sandbox