New to the forum? Say hello in this topic! Make sure to read the rules.
RULE NR 3 UPDATED: Don't hurt, harass or provoke other forum members or people.

Planned ScriptAPI changes

Share questions and tutorials related to the ScriptAPI and give suggestions for new functions you want to see.
Forum rules
By using the forum you agree to the following rules.
User avatar
Gurt
Lead Programmer
Lead Programmer
Posts: 901
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 27

Planned ScriptAPI changes

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

This is a list over all planned features that suits to be implemented in the ScriptAPI. If they are listed here then they are planned. I might at any time remove and/or add features for the ScriptAPI as time goes on.
  • Console.ShowPopupMessage()
    - Will be changed to be unique per script. The map will list its own popup message first, then any extension scripts in loaded order.
  • Some way to change GameWorld's SpawnChances for items.
  • Be able to change the weather.
  • Change selected colors in some way for tiles.
  • IObjectSpawnWeapon
    - Be able to set/get item spawn chances.
  • IObjectSpawnItemTrigger
    - Be able to set/get item spawn chances.
  • Be able to start and stop listen to certain events in the game.
    • When a user connect and disconnect.
    • Listen to key input from connected users in some way.
    • Listen to specific chat messages from connected users in some way. Restrictions apply:
      • You will not be able to modify the actual content of the message nor listen to whispers/team chats.
      • You will be able to read messages with or without a leading "/". Messages with a leading "/" will first be handled as SFD commands. If none SFD command is found then the command will be available in your script for processing.
      • If you plan to use commands in your script you should consider using a unique prefix to all your commands so you know which commands your script should parse and handle. If you plan to add a command "showmap" (by typing "/showmap") it's unwise to do so in case SFD implements its own command "/showmap" in the future. Instead use a prefix like "/wm showmap" ("wm" could stand for "wizard mod" or some other acronym for example)
    • When the game is over.
  • Be able to send chat messages to individual users or to all users. Restrictions apply: you will not be able to spoof a message from someone else - we might do this by showing a certain icon in front of all text through this message. "/MSG" commands are always red and global for example.
  • Be able to disable automatic spawn of players and only control it through scripting.
  • Be able to store and load data from disk (up to a certain maximum (maybe 1MB)) per map/extensionscript as persistent data.
  • Maybe be able to easily use Serialization to store and retrieve objects in the Game.Data tag.
  • Game.WriteToConsole()
    - This will log everything to a standalone console-window for easy copy-paste and debugging your script.
For extensions scripts:
The goal will be so you can mod/script some more customized rules for your server when hosting. The following things will only be available in extensions scripts and will not be available for map scripts.
  • Be able to read ping of users and auto kick users. Now you can write your own auto kick algorithm if you want.
  • Be able to modify host options like timers, sudden death, close/open slots, change team layouts, map options etc...
  • Be able to change next map in some way.
  • Be able to reset the current score.
  • Be able to stop extension scripts at any time by calling something like "StopScript()". By using this in combination with OnStartup() you will be able to create scripts that only run once (if you need it).
  • Be able to start/stop other extension scripts. Maybe you want certain hours of the day to use certain scripts that modify your server in certain ways.
With the above you should be able to have more control over your server.
Last edited by Gurt on Tue Apr 26, 2016 8:04 pm, edited 1 time in total.
3 x
Gurt

User avatar
Creeper
Superfighter
Superfighter
Posts: 161
Joined: Wed Mar 23, 2016 9:44 am
Title: Kachiba Ma-Nibba
SFD Account: Kreepah
Started SFD: Pre-Alpha 1.1.6
Location: Lithuania
Gender:
Age: 15
Contact:

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

So wait there are going to be more triggers?
I would be pleased becose I like triggers my favourite.

-Creeper
0 x
Been playing Superfighters deluxe for ~4 years. Still hate and love it to every single bit.

chelog
Fighter
Fighter
Posts: 11
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: 21
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: 18
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: 166
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: 20
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: 901
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 27

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: 238
Joined: Mon May 09, 2016 7:35 am
Title: Sunny City Citizen
SFD Account: Motto73
SFD Alias: Motto73, Pack-Man!
Started SFD: Multiplayer Test Demo
Location: Sunny City
Gender:
Age: 18

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
There is the place I live in, and then there's my home, the hideous, brutal and cartoony world of Superfighters Deluxe.

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

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: 257
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 19

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: 901
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 27

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: 257
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 19

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: 901
Joined: Sun Feb 28, 2016 3:22 pm
Title: Lead programmer
Started SFD: Made it!
Location: Sweden
Gender:
Age: 27

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: 257
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 19

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: 238
Joined: Mon May 09, 2016 7:35 am
Title: Sunny City Citizen
SFD Account: Motto73
SFD Alias: Motto73, Pack-Man!
Started SFD: Multiplayer Test Demo
Location: Sunny City
Gender:
Age: 18

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
There is the place I live in, and then there's my home, the hideous, brutal and cartoony world of Superfighters Deluxe.

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

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: 257
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 19

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: 257
Joined: Fri Jul 15, 2016 7:56 pm
Started SFD: PreAlpha 1.0.5
Location: Rome, Italy
Gender:
Age: 19

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.
2 x

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

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

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

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

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest