Here you can find answered ScriptAPI topics.
-
jamisco
- Superfighter

- Posts: 67
- Joined: Sun Nov 06, 2016 11:34 pm
- Title: Da God
- SFD Account: Jamisco
- SFD Alias: Jamisco
- Started SFD: either late 2015 or early 2016
- Location: Somewhere in the east of the United states
- Gender:
- Age: 105
Post
by jamisco » Fri Jun 30, 2017 8:36 pm
so I tried doing something like this
Code: Select all
while (player.isDead != true)
{
player.AddCommand(new PlayerCommand(PlayerCommandType.AttackOnce));
}
the game will crash because off infinite loop, how do you guys recommend I go about this?
0 x
Is it better to be feared or respected... please, is it too much to ask for both?
-
JakSparro98
- Superfighter

- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 27
Post
by JakSparro98 » Fri Jun 30, 2017 9:22 pm
jamisco wrote: ↑Fri Jun 30, 2017 8:36 pm
so I tried doing something like this
Code: Select all
while (player.isDead != true)
{
player.AddCommand(new PlayerCommand(PlayerCommandType.AttackOnce));
}
the game will crash because off infinite loop, how do you guys recommend I go about this?
Avoid infinite loops until we finally get coroutines to do code like that, you can solve this easily by adding the player.AddCommand under a function evoked by an UpdateTrigger, then you can replace the while condition with an if.
0 x
-
jamisco
- Superfighter

- Posts: 67
- Joined: Sun Nov 06, 2016 11:34 pm
- Title: Da God
- SFD Account: Jamisco
- SFD Alias: Jamisco
- Started SFD: either late 2015 or early 2016
- Location: Somewhere in the east of the United states
- Gender:
- Age: 105
Post
by jamisco » Fri Jun 30, 2017 11:21 pm
how do I do that?

0 x
Is it better to be feared or respected... please, is it too much to ask for both?
-
JakSparro98
- Superfighter

- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 27
Post
by JakSparro98 » Sat Jul 01, 2017 12:39 am
Code: Select all
public void repeat(TriggerArgs arg){
if (player.isDead != true)
player.AddCommand(new PlayerCommand(PlayerCommandType.AttackOnce));
}
Then you have to make this executed by a trigger by adding the method name in the method property of the trigger, but since you have declare an IPlayer named "player" this won't work, this code is purely for code visualization, you could re-get the bot reference in this function (another game.get... ) and then apply the command.
Off Topic
From what I understood you're focused on making advanced bots isn't it? I'm trying something similar and I can assure you that is not even simple, with 2-3 thousand lines of code I barely managed to make a stable movement system and started the weapon pickup system, anyway now, with you, we are 3 or 4 people trying this

.
Good luck.
0 x
-
kirill240
- Fighter

- Posts: 18
- Joined: Mon Jan 09, 2017 1:01 pm
- SFD Account: Mr.A woman's heart
Post
by kirill240 » Tue Jul 04, 2017 9:45 pm
JakSparro98 wrote: ↑Sat Jul 01, 2017 12:39 am
Code: Select all
public void repeat(TriggerArgs arg){
if (player.isDead != true)
player.AddCommand(new PlayerCommand(PlayerCommandType.AttackOnce));
}
Then you have to make this executed by a trigger by adding the method name in the method property of the trigger, but since you have declare an IPlayer named "player" this won't work, this code is purely for code visualization, you could re-get the bot reference in this function (another game.get... ) and then apply the command.
Off Topic
From what I understood you're focused on making advanced bots isn't it? I'm trying something similar and I can assure you that is not even simple, with 2-3 thousand lines of code I barely managed to make a stable movement system and started the weapon pickup system, anyway now, with you, we are 3 or 4 people trying this

.
Good luck.
What do you think about
it (link)?
Either you have tried little or you and your friends do not have much experience in this
0 x
-
JakSparro98
- Superfighter

- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 27
Post
by JakSparro98 » Wed Jul 05, 2017 5:38 pm
kirill240 wrote: ↑Tue Jul 04, 2017 9:45 pm
What do you think about
it (link)?
Either you have tried little or you and your friends do not have much experience in this
Armadyl did an awesome job, unfortunately for me, that was the easiest one, all the code I tried to write in these months are mainly for creating a movement system like the original SuperFighters, only now I'm currently trying to make it follow and pickup best weapons on the ground and make it to shoot... it's a lot of work that needs to be adapted with the whole AI system, and also I think Gurt will finish to implement bots before I will be able to close this project and see his might.
I don't think I've understood what you tried to say with "you and your friends do not have much experience in this", but above all, was you talking with jamisco or with me?
0 x
-
Gurt
- Lead Programmer

- Posts: 1887
- Joined: Sun Feb 28, 2016 3:22 pm
- Title: Lead programmer
- Started SFD: Made it!
- Location: Sweden
- Gender:
- Age: 36
Post
by Gurt » Thu Jul 06, 2017 9:40 pm
As said before: the commands are not designed to create an AI (neat that it's possible to some extend though) - it's designed to create small controlled events for the campaigns (like "cutscenes").
0 x
Gurt
-
JakSparro98
- Superfighter

- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 27
Post
by JakSparro98 » Fri Jul 07, 2017 5:38 pm
Gurt wrote: ↑Thu Jul 06, 2017 9:40 pm
As said before: the commands are not designed to create an AI (neat that it's possible to some extend though) - it's designed to create small controlled events for the campaigns (like "cutscenes").
I perfectly know this, but I only want to demonstrate the power of the script API, that can even make entirely code-written CPU-controlled players (it's also a challenge to prove to myself how far can I go deeper in the code).
Futhermore I didn't started this project because I think my version will be better than the official one, first because I'm never experienced nothing like that, and second because a script will never beat a pure c# code.
0 x