Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

ScriptAPI changes

Share questions, scripts and tutorials related to the ScriptAPI in SFD.
Forum rules
By using the forum you agree to the following rules.
User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

ScriptAPI changes

Post by Gurt » Thu Mar 03, 2016 5:51 pm

The ScriptAPI as of version v.1.3.0 of the game is what we consider completed. There're no more planned features.
Last edited by Gurt on Fri Dec 25, 2020 1:17 pm, edited 9 times in total.
Reason: Updated notice
4 x
Gurt

User avatar
Creeper
Superfighter
Superfighter
Posts: 172
Joined: Wed Mar 23, 2016 9:44 am
Title: okokok is real #1
SFD Account: Krypa
SFD Alias: Krypa
Started SFD: Pre-Alpha 1.1.6
Location: US
Gender:
Age: 21
Contact:

Post by Creeper » Thu Mar 24, 2016 8:47 am

So wait there are going to be more new triggers?
Last edited by Creeper on Fri Apr 27, 2018 12:19 pm, edited 1 time in total.
0 x
Image

chelog
Fighter
Fighter
Posts: 10
Joined: Sun Mar 20, 2016 10:45 am
Title: 0110111101101011
SFD Alias: chelog
Started SFD: The first public version
Location: Saint-Petersburg, Russia
Gender:
Age: 27
Contact:

Post by chelog » Sun Mar 27, 2016 1:47 pm

How about an event when object is destroyed? Just like OnPlayerDeathTrigger
1 x

User avatar
ShutDownMan
Fighter
Fighter
Posts: 32
Joined: Sat Mar 19, 2016 7:17 pm
Title: Yeah, science!
SFD Alias: ShutDownMan, Devil Shut
Started SFD: 1.2.something
Location: Hu3, Brazil
Gender:
Age: 24
Contact:

Post by ShutDownMan » Sun Apr 10, 2016 10:55 pm

I wanna ask if you will make the Static and Dynamics objects lists enable for read/write on the ScriptAPI.

There's a script I'm making that needs to go through every dynamic object, make a deep copy (or only copy it's name), and remove the object, to spawn it only later, when the player gets near it.

I don't think it's too risky to do that.
0 x
~ShutDownMan

User avatar
TheOriginalCj
Moderator
Moderator
Posts: 177
Joined: Tue Mar 15, 2016 10:28 pm
Title: Lifetime Sentence to SF Wiki
SFD Alias: RedneckJed
Started SFD: PreAlpha 1.1.0
Location: USA
Gender:
Contact:

Post by TheOriginalCj » Mon Apr 11, 2016 4:28 am

I keep forgetting to look for this, but is there a library section of reserved function identifiers? I only ask because I'm now just realizing that some function names are reserved.

As for some of the questions here, I believe some of these API features will require the implementation of a few more triggers, so don't fear, they're here to stay. ;)

EDIT: To add on this list, if any of these are not possible, they should be:

The ability for area triggers to be able to sense if there is a spesific type of projectile in the general area. (i.e. Bullet, Flare, Rocket. etc.)

A command that can get/set the current angle of a revolute joint. (This would be helpful in running an oscillation type of joint, or perhaps even a human powered switch.)
0 x
Superfighters Wiki Founder
The Superfighters Wiki
Join the Wiki!
Danger Ross wrote: What are you doing here wiki-slave?! GET BACK TO WORK!

Antonikon
Fighter
Fighter
Posts: 17
Joined: Sun Apr 17, 2016 4:50 pm
Started SFD: PreAlpha 1.3.1
Gender:
Contact:

Post by Antonikon » Tue Apr 19, 2016 9:56 pm

Gurt wrote:Be able to store and load data from disk (up to a certain maximum (maybe 1MB)) per map/extensionscript as persistent data.
Some time ago I found a temporary solution. I create a string with my data and add "SOMETEXT" in beginning. Then i find this text by Cheat Engine and copy hex data. Then remove all 00 code. Then use hex to ascii converter and copy data to string constant in script.

P.S
Didn't know where to post this "small hack".
3 x

User avatar
dudely-kay
Fighter
Fighter
Posts: 19
Joined: Tue Mar 22, 2016 5:46 pm
Title: Me, myself and I
Started SFD: 1.8.4
Location: tunisia
Gender:

Post by dudely-kay » Wed Apr 20, 2016 12:50 pm

This suggestion might be silly (or in the wrong place) , but can you add methods that allow you to get or edit the characteristics of a player's skin (IProfile) or create a whole new skin ?
something like : (IProfile) skin.GetSkinColour() or (IProfile) skin.SetAccessory()

If you're creative enough, you can find good uses of such methods, for example : in case you're creating a zombie map and you want to make the "zombified" players' skins looks a bit the original skin
3 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Tue Apr 26, 2016 8:05 pm

Updated the planned ScriptAPI changes with extensions ScriptAPI only features.

Being able to modify IProfile through the ScriptAPI might be something we'll consider once we start with bots.
2 x
Gurt

User avatar
Motto73
Superfighter
Superfighter
Posts: 316
Joined: Mon May 09, 2016 7:35 am
Title: Lazy ass
SFD Account: Motto73
Started SFD: Multiplayer Test Demo
Location: Sunny City
Gender:
Age: 24

Post by Motto73 » Mon Aug 01, 2016 12:42 pm

The System.IO is a lovely thing. But that could not be used straight, because that would be quite, well, dangerous. But if you can do it, it would be great if we are allowed to write the data to a file and find it there when needed!
0 x
Image

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Mon Aug 01, 2016 2:17 pm

Motto73 wrote:The System.IO is a lovely thing. But that could not be used straight, because that would be quite, well, dangerous. But if you can do it, it would be great if we are allowed to write the data to a file and find it there when needed!
It will not be allowed to use System.IO in the ScriptAPI. You will have to use functions/classes provided by the ScriptAPI in some way.
2 x
Gurt

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Mon Aug 01, 2016 4:02 pm

I've a question, all the code in the map script is executed as single thread?


I'm creating an AI sketch provided with pathfinding and shooting, the problem is that this heavy code seems the be executed in the game simulation thread (so multiple enemy equals huge lag), if you put while(true) the entire game simulation will freeze and you forced to kill the process.

There will ever be the possibility to run pieces of code in a separate thread? Probably meanwhile there will be already the official artificial intelligence and probably never multithreading will see the light, due for possible security issues.
2 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Tue Aug 02, 2016 10:00 am

JakSparro98 wrote:I've a question, all the code in the map script is executed as single thread?
...
There will ever be the possibility to run pieces of code in a separate thread?
No. The whole ScriptAPI is an afterthought and was never planned from the start to be a part of SFD. The ScriptAPI will always run in the main thread for SFD's update logic to prevent other issues such as racing conditions, deadlocks, crashes, apphangs and other problems related to "unsafe" threading when manipulating the game world in SFD. The Script also runs in a sandbox environment in another AppDomain to limit the user to prevent harmful code such as System.IO calls - this also makes the code run slower.

I have been thinking about terminating calls to the script that takes too long to run (like a while(true)) to prevent hanging but it's not the focus right now.

In general: Keep any code fast and simple to execute as it must always terminate.

You could redesign your code so it process a few iterations on your pathfinding logic before "pausing" and wait for the next update cycle and process a few more iterations.
1 x
Gurt

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Tue Aug 02, 2016 2:31 pm

Gurt wrote: The ScriptAPI will always run in the main thread for SFD's update logic to prevent other issues such as racing conditions, deadlocks, crashes, apphangs and other problems related to "unsafe" threading when manipulating the game world in SFD. The Script also runs in a sandbox environment in another AppDomain to limit the user to prevent harmful code such as System.IO calls - this also makes the code run slower.
theoretically racing conditions and deadlocks are problem of who writes the script if something is not in sync or there are multiple variable assignment without an order. There wouldn't be a problem if (like you said for the while cycle) is defined a time slice for possible deadlocks, also the script sandbox would parse the code one time entirely and not when it is executed.
Gurt wrote: You could redesign your code so it process a few iterations on your pathfinding logic before "pausing" and wait for the next update cycle and process a few more iterations.
so it needs to be completed in a couple of cycles?

Currently the pathfinding build the entire path and terminates, every second since the enemy is spawned the function is invoked but works only if the new goal node is changed, after a bit of enemy istances the pathfinding is always in execution, one time for enemy3 another for the enemy7 and more the path is complex more the while cycle make the thread hangs costantly for a few milliseconds.

The path can be reused but if some enemies are pointing another player there will be different path calculation.

eventually I want to ask if the CPU AI of the classic SuperFighters was divided in threads (probably yes because of lack of third party programmers).

I know this could be off topic, I will open another in case the discussion continues.
0 x

User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 1884
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 34

Post by Gurt » Thu Aug 04, 2016 6:48 pm

You're bringing up problems that's more or less generic for pathfinding algorithms in general.

In SFD you're limited to what you can do and can't do in the ScriptAPI.
Everything is executed in the update thread for SFD.
You can not create your own threads.

I suggest you apply some sort of round robin over your enemies when you solve the path finding. That's pretty much what we did in SF to avoid it hooging the CPU when there're many CPUs.
1 x
Gurt

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Mon Aug 15, 2016 4:13 pm

A possible addition on the IPlayer class...may be usefull an IsHit boolean when you cannot record a state with Is.Staggering or Is.Falling for a player... today a simple melee/projectile hit on a crate or on a player isn't handled.
1 x

User avatar
Motto73
Superfighter
Superfighter
Posts: 316
Joined: Mon May 09, 2016 7:35 am
Title: Lazy ass
SFD Account: Motto73
Started SFD: Multiplayer Test Demo
Location: Sunny City
Gender:
Age: 24

Post by Motto73 » Mon Sep 19, 2016 1:59 pm

The health can be manipulated via Script_Api, but stamina can't. Please make it avaible, it's a big problem for me in these custom modes, where this needs to be changed.
 ! Message from: KliPeH
Merged a separate bump into this post.
1: OnHitEvent

In the very basics something happens when any object is damaged.

We could two ways to use this:
1. Through script: We could have a listener to listen to certain hits, liek when any object is damaged

OnHitEvent(baseobject TargetObject, DamageType1 damageType, float damageAmount, baseObject damager, bool Destroyed)

targetObject = the object that is damaged, damageType = Type of damage, damageAmount = how much damage, damager = damaging object(null if projectile), Destroyed = If the object is destroyed.

2. Through a trigger: We could have another trigger, a OnHitTrigger. I could just call for a specified script method when 1.Any object/2. Any targeted object is damaged. It would call with OnHitEvent, not with TriggerArgs.

*1 We would need another enum for this: DamageType.Projectile, Melee, Fall(or collisions just), fire and explosion.

2. OnDestroyedEvent

Basically the same as above, but only calls if the object is destroyed.

Please comment and answer when you are able!
1 x
Image

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Thu Nov 03, 2016 11:21 pm

Could be added an attribute with the name of the player's used language in the game.

This provides an enum type with a language list for choosing a standard language rather than a free name format given by the translation tool (first 100/50 spoken languages to choose).

It can be accessed from the IUser class to specify which player is processed by the API.

Could also be usefull to use with the individual message popup already planned, the script can behave differently depending of what language is used and if there are available messages for that language.
2 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Sun Feb 12, 2017 4:46 pm

With my last script request I notice that we would need of a command that prevent an object from being destroyed next tick, for instance if I catch with "DestructionInitiated" a true response then I can cancel object destruction with an ipotetic "CancelDestructionInitiated" and reset his health.
3 x

User avatar
JakSparro98
Superfighter
Superfighter
Posts: 530
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 25

Post by JakSparro98 » Mon Mar 06, 2017 10:49 pm

I have other three entries for the IPlayer class:

IsBazookaRiding: boolean, true if a player is riding a bazooka rocket, false if not

GetManualAimAngle: float, gets the angle in degreer/radiants of half circle (0 to 180 because with FacingDirection
we can check the side the aiming is)

IsChatTyping: boolean, true if a player have opened the chat, false if not.
3 x

Armadyl5
Superfighter
Superfighter
Posts: 119
Joined: Sun Mar 20, 2016 9:50 am
Started SFD: 1.2.1
Gender:
Age: 25

Post by Armadyl5 » Sat Mar 11, 2017 12:39 am

I want to suggest adding an "infinite block" as a command
1 x
Never Surrender !

Always Fight For Your Rights , and Don't Let Your Friends Down .

Post Reply