SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 12/07/2016, 02:51 PM   #1
Freaksken
Gangsta
 
Freaksken's Avatar
 
Join Date: Mar 2009
Location: Belgium
Posts: 523
Reputation: 209
Default FCNPC A.I.


FCNPC A.I.
Previously know as "FCNPC Boss like World of Warcraft", but this include is capable of much more than just that. Which is why I decided to change the name.

Introduction:
This include extends on the FCNPC plugin by adding an artificial intelligence system to the NPCs. It provides a wide range of functions and callbacks which allows you to customize nearly anything about the state or the behaviour of the NPC. One of the most notable features is allowing the NPC to have more than just the standard 100 health, say for example 1 million. If however you simply want a plug and play solution, there are also default settings present which makes creating an intelligent NPC as easy as using 1 line of code. Once you get the hang of it though, you can create some pretty impressive NPC systems.

Easy plug and play example:
You can customize a lot if you want to, but you certainly don't have to utilize every function. The simplest use consists of just creating the NPC, spawning it and letting the include handle everything else. The following example filterscript shows how to do exactly that.
Code:
#define FILTERSCRIPT
#include <a_samp>
#include <FAI>
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
	new bossid = FAI_CreateBoss("BigSmoke");
	FCNPC_Spawn(FAI_GetBossNPCID(bossid), 149, 1086.9752, 1074.7021, 10.8382);
	return 1;
}
#endif
The FAI_CreateBoss and FAI_GetBossNPCID functions are provided by this include. The FCNPC_Spawn function is provided by the FCNPC plugin. This shows that you can still use the FCNPC functions as normal.

As you can see, every function of this include is prefixed with FAI_. An NPC created with this include is called a Boss, which is just a remnant from the first implementation (see below). It doesn't mean that you can only create bosses with this include! Normal NPCs without the extra health or abilities work just as well. So don't be put off by the naming scheme.

More advanced examples:
This include provides more than just a simple A.I. system. You can do a lot more than what it looks like at first. The following examples show that it is capable of much more.


MMORPG-like bossfight


Description:
This example was the first script I made with this include. In fact, it was written before I decided to hide the complexity in an include so it would become much easier to use and release it on the forums. This script had the goal to create a bossfight like in the popular MMORPG, World of Warcraft (WOW). It uses most of the features this include provides, including casting spells, showing the healthbar, ...

Mechanics:
  • Increased NPC health
  • Displayed name
  • Displayed health bar
  • Displayed cast bar
  • When the boss is idle, every now and then he will shout in general chat
  • The boss will only attack you when you enter his aggro range, or when you damage him
  • The boss speaks (sound + text) in general chat and will whisper you when certain events occur
  • The boss will cast abilities on players in range and will perform an animation while casting
  • The more health the boss loses, the more aggressive abilities he will use
  • You better don't stand still when you have aggro, or the boss will cast a damaging ability on you
  • When you kill the boss, a reward will be given in the form of dropping loot

Video:
A demonstration can be seen on YouTube. Demonstrations of earlier versions are present as well.

Release thread:
The thread in which I first showed this script can be found here.

Download:
If you would like to play this yourself, you can download it here. It uses Incognito's streamer for objects and pickups. If you don't use Incognito's streamer, define USE_STREAMER as false.


Leatherface/Jason Voorhees/Michael Myers


Description:
This second example script shows that you don't have to use every feature that is provided to add a nice boss-like script to your server. It had the goal to create a horror-like bossfight like you see in many of those 'Leatherface in GTA:SA' videos in which a strong NPC with a lot of health attacks you when you approach it. It is a bit of a mix of The Texas Chain Saw Massacre, Friday the 13th and Halloween.

Mechanics:
  • Increased NPC health
  • Hidden name
  • Hidden health bar
  • Hidden cast bar
  • When you approach the boss, the Halloween theme will start playing for you and the weather and time will change for you
  • When the boss is idle, he will walk on a predefined path and will perform some animations
  • The boss will only attack you when you enter his house, or when you damage him
  • The boss performs a custom walking animation (chainsaw in 1 hand)

Video:
A demonstration can be seen on YouTube.

Release thread:
The thread in which I first showed this script can be found here.

Download:
If you would like to play this yourself, you can download it here. It uses Incognito's streamer for objects and pickups. If you don't use Incognito's streamer, define USE_STREAMER as false.


Single-player-like mission


Description:
This script shows that with creativity, you can create something very impressive. It had the goal to create a mission in the style of Rockstar and GTA SA, but one that you can play with more than just 1 person.

Mechanics:
  • Cutscenes with sound dialog and subtitles
  • Mission objective subtitles
  • Vehicles take damage from bullet weapons
  • Enemies die instantly from headshots
  • Enemies drop their weapons when they die
  • Cops with regular pistols drop nightsticks as well when they die
  • When you melee hit a cop with a regular pistol, he will switch to his nightstick and try to melee you
  • SWAT enemies have 50 health, FBI and Army has 60 and all others have 30
  • The skill level of the players is set to 0 for all skills (to simulate the "New Game" feel)
  • When one of your party members die, the mission ends and you get a SP-like Mission Failed screen
  • Disabled entering vehicles (driver and passenger) to keep players from venturing too far from the mission area
  • This mission can be played with 2 to 4 players. The skins they can have are CJ, Sweet, Ryder or Big Smoke. Say there are only 2 players, the skins will be CJ and Sweet, but what skin player1 and player2 get are random
  • There is a minimum of 2 players, because there will be a small teamworking section that needs more than 1 player of course
  • Various difficulties that change some parameters like NPC health, NPC accuracy, friendly fire, ...
  • 20 NPCs are used during the whole mission. The NPCs get created on FS load and get destroyed on FS unload. If for some reason not all NPCs connect to the server (if the server is full, or maxnpc is reached) the mission will not be able to start and the few connected NPCs get destroyed again. In other words: There are more than 20 enemies, but the 20 ID's get reused
There are some small bugs that I'm still working on to fix (like Ryder shooting on the car instead of on Pulaski, enemies targetting to soon, sometimes seeing the NPCs spawn, ...). The mission is not finished yet, the video shows everything to about 2/3 of the final product. The textdraws in the top-right will be hidden during cutscenes. Killing a mission-npc will not show up in the kill-feed.

Video:
A demonstration can be seen on YouTube. Demonstrations of earlier versions are present as well.

Release thread:
The thread in which I first showed this script can be found here.

Download:
The script is still being worked on. It will be released when it is finished.

Other scripts:
Have an impressive script you want to share? Don't hesitate and post a reply on this thread! I really want to know what people can come up with by using this include.

Extra features:
  • Ability to change any feature without the need of recreating the boss/spell or waiting for the update timer to tick. The change gets executed immediately and any functionality that uses the feature gets updated automatically.
  • Display large integers with a thousands separator for readability.
  • Ability to display floats with a different decimal mark for languages in which a '.' is not used.
  • Ability to display shortened numbers like 1K or 5M.

Documentation:
The workings of every define, function, callback or feature is extensively explained on the wiki.

Download:
The latest version can be found on the releases page.

Bugs:
Please report any bug with detailed steps on how to reproduce it.

Suggestions:
If you have any constructive criticism or suggestions, please share your opinion.

Possible upcoming changes/features:
There are some things left that I want to implement, but I always get new ideas, so the list keeps growing. The following list items will be implemented someday, but I can't give a specific date or priority.
  • Spell mana.
  • Spell range.
  • Spell cooldown.
  • Status effects (buffs and debuffs).
  • Status effects stacks.
  • Switch aggro (Currently the boss will only switch to another player if his target becomes invalid. You can't for example overaggro right now. You can however manually switch the target with FAI_SetBossTarget).
  • Exclude players from threat, aggrorange and displayrange.
  • Party/raid-like system.
  • Make the general defines boss/spell specific.
  • Change to plugin, so everything is shared server-wide. Currently only the callbacks are called server-wide. This would also remove the FAI_MAX_BOSS and FAI_MAX_SPELL defines.

Changelog:
See changelog.

License:
See license.

Credits:
Many people have (indirectly) contributed to make this system possible. See credits to see who.
__________________
Always keep in mind that a lot of people are active on this forum in their spare time.
They are sacrificing time they could easily spend on things they would rather do, to help you instead.


[Include] FCNPC A.I. - [Tutorial] Speedometer - [WIP] Single-player-like Mission - [Other] List of all my work

Last edited by Freaksken; 20/07/2017 at 04:03 AM.
Freaksken is online now   Reply With Quote
Old 12/07/2016, 03:21 PM   #2
n0minal
Banned
 
Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,101
Reputation: 704
Default Re: FCNPC Boss like World of Warcraft

That's really creative, I really love the idea of making custom Quests on the game where you do have to be in group to complete, +8reps
n0minal is offline   Reply With Quote
Old 12/07/2016, 03:26 PM   #3
Freaksken
Gangsta
 
Freaksken's Avatar
 
Join Date: Mar 2009
Location: Belgium
Posts: 523
Reputation: 209
Default Re: FCNPC Boss like World of Warcraft

Quote:
Originally Posted by n0minal View Post
That's really creative, I really love the idea of making custom Quests on the game where you do have to be in group to complete, +8reps
Thank you very much . With the tools I gave, you could even script a whole Dungeon or Raid.
__________________
Always keep in mind that a lot of people are active on this forum in their spare time.
They are sacrificing time they could easily spend on things they would rather do, to help you instead.


[Include] FCNPC A.I. - [Tutorial] Speedometer - [WIP] Single-player-like Mission - [Other] List of all my work
Freaksken is online now   Reply With Quote
Old 12/07/2016, 03:34 PM   #4
Jpew
Big Clucker
 
Jpew's Avatar
 
Join Date: Jul 2015
Location: VE
Posts: 102
Reputation: 18
Default Re: FCNPC Boss like World of Warcraft

The spells dude! +rep
Jpew is offline   Reply With Quote
Old 12/07/2016, 03:42 PM   #5
Freaksken
Gangsta
 
Freaksken's Avatar
 
Join Date: Mar 2009
Location: Belgium
Posts: 523
Reputation: 209
Default Re: FCNPC Boss like World of Warcraft

Quote:
Originally Posted by Jpew View Post
The spells dude! +rep
Yeah . You can script a spell with pretty much any outcome you want.
__________________
Always keep in mind that a lot of people are active on this forum in their spare time.
They are sacrificing time they could easily spend on things they would rather do, to help you instead.


[Include] FCNPC A.I. - [Tutorial] Speedometer - [WIP] Single-player-like Mission - [Other] List of all my work
Freaksken is online now   Reply With Quote
Old 12/07/2016, 04:03 PM   #6
n0minal
Banned
 
Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,101
Reputation: 704
Default Re: FCNPC Boss like World of Warcraft

Would be cool if you give bosses New powers such as spell smokes and even blind the players
n0minal is offline   Reply With Quote
Old 12/07/2016, 04:16 PM   #7
Ritzy
High-roller
 
Ritzy's Avatar
 
Join Date: Jun 2014
Location: GPS failed.
Posts: 1,465
Reputation: 107
Default Re: FCNPC Boss like World of Warcraft

Wow.
Ritzy is offline   Reply With Quote
Old 12/07/2016, 04:22 PM   #8
Freaksken
Gangsta
 
Freaksken's Avatar
 
Join Date: Mar 2009
Location: Belgium
Posts: 523
Reputation: 209
Default Re: FCNPC Boss like World of Warcraft

Quote:
Originally Posted by n0minal View Post
Would be cool if you give bosses New powers such as spell smokes and even blind the players
That is currently possible by creating a new spell with WOW_CreateSpell(Full) and when WOW_OnBossStopCasting gets called you create the smoke object at the XYZ coordinates you want. Take a look in the example script on how the spells shown in the video work. It's easy to adapt the behaviour to your needs or to create a new spell entirely.
__________________
Always keep in mind that a lot of people are active on this forum in their spare time.
They are sacrificing time they could easily spend on things they would rather do, to help you instead.


[Include] FCNPC A.I. - [Tutorial] Speedometer - [WIP] Single-player-like Mission - [Other] List of all my work
Freaksken is online now   Reply With Quote
Old 12/07/2016, 04:25 PM   #9
JustMe.77
Huge Clucker
 
JustMe.77's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 273
Reputation: 63
Default Re: FCNPC Boss like World of Warcraft

This is a great release, you've put much effort in it !
JustMe.77 is offline   Reply With Quote
Old 12/07/2016, 05:38 PM   #10
Whyd
Huge Clucker
 
Whyd's Avatar
 
Join Date: Sep 2012
Location: /
Posts: 422
Reputation: 30
Default Respuesta: FCNPC Boss like World of Warcraft

I was waiting this release, nice!
Whyd is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] NPC - FCNPC MBJ Português/Portuguese 10 16/03/2017 08:14 PM
FCNPC GOD mod bug HELP :( peti784 Scripting Help 0 07/09/2016 05:57 PM
Need help with FCNPC valerastar Scripting Help 1 05/05/2016 08:54 AM
Help Me FCNPC Pagle Scripting Help 0 30/07/2015 07:11 AM
FCNPC help blackwave Scripting Help 1 20/04/2014 04:36 AM


All times are GMT. The time now is 02:56 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.