Author Topic: Function/Feature Requests  (Read 35536 times)

0 Members and 1 Guest are viewing this topic.

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Function/Feature Requests
Here is a new patch ;)

In as of 7930.

This thread looks like a good place to post this little patch, which adds a kill() function to asteroids. With this, scripts can actually kill asteroids, whereas previously you'd have needed to spawn a fake weapon to hit and destroy them.

In as of 7931.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline m!m

  • 211
Re: Function/Feature Requests
I have another patch which adds the following things:
  • Eyepoint access to the model handle
  • getCollisionDistance() to the collision info handle to get the precomputed distance to the hit point
  • A Disabled variable for the ship handle
  • getTimeUntilExplosion() for the ship handle to get the time until the ship finally explodes
  • A change to the documentation of ad.play3DSound() to reflect that the function also takes position parameters

Thank you for your time

[attachment deleted by a basterd]

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Function/Feature Requests
finally eyepoints. now i can use the eyepoint list from the model instead of having to copy all the data to a fake table.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline Vidmaster

  • 211
  • Inventor of FS2 bullettime ;-)
Re: Function/Feature Requests
A auto-targeting function as seen in WCS that not only fires your guns at your target but also at the selected subsystem and can be toggled on and off with a key.
Devoted member of the Official Karajorma Fan Club (Founded and Led by Mobius).

Does crazy Software Engineering for a living, until he finally musters the courage to start building games for real. Might never happen.

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Function/Feature Requests
need a function to have scripting spew out the current game version and build number and debug mode flag so that i can conditionally evaluate or exclude lines of script based on engine version. if it exists i cant find it.
probibly just return it as a string "version,subversion,subsubversion,buildnum,debug|release" or an table of numbers {version,subversion,subsubversion,build,1|0}, or even a userdata type. not sure which would be more intuitive. idea is you should be able to be able to check this quickly in one line of code as you would with a #ifdef in c.

also need a way to disable transparency of a render target. when drawing bitmaps with transparency to a texture that needs to remain opaque, the transparency information from the bitmaps are drawn to the texture making those areas of the texture transparent. this is undesirable, like when the bitmap will be applied to an object in the game. seems the alpha is overwriting the underlying pixel data when it should be added. being able to change the blending operatione (such as multiplicative, additive, subtractive, etc) would also be completely awesome.
« Last Edit: December 17, 2011, 01:47:23 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline m!m

  • 211
Re: Function/Feature Requests
I'll post the patch I posted a while ago here again as the old one seems to have gotten deleted. Can a SCP coder take a look at it?

Original message below:
I have another patch which adds the following things:
  • Eyepoint access to the model handle
  • getCollisionDistance() to the collision info handle to get the precomputed distance to the hit point
  • A Disabled variable for the ship handle
  • getTimeUntilExplosion() for the ship handle to get the time until the ship finally explodes
  • A change to the documentation of ad.play3DSound() to reflect that the function also takes position parameters

Thank you for your time

[attachment deleted by a ninja]

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Function/Feature Requests
Committed r8199
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Re: Function/Feature Requests
Here's a patch which adds an $On Turret Fired hook, providing hook variables Ship, Weapon and Target. I'll later try to add a handle to the associated subsystem to weapon objects, since I can't pass that as a hook variable (due to subsystems not inheriting from object).

Code: [Select]
Index: ai/aiturret.cpp
===================================================================
--- ai/aiturret.cpp (revision 8215)
+++ ai/aiturret.cpp (working copy)
@@ -21,6 +21,7 @@
 #include "ai/aiinternal.h" //Included last, so less includes are needed
 #include "iff_defs/iff_defs.h"
 #include "weapon/muzzleflash.h"
+#include "parse/scripting.h"
 
 #include <limits.h>
 
@@ -1717,6 +1718,12 @@
  objp=&Objects[weapon_objnum];
  wp=&Weapons[objp->instance];
 
+ parent_ship->last_fired_turret = turret;
+ turret->last_fired_weapon_info_index = wp->weapon_info_index;
+
+ Script_system.SetHookObjects(3, "Ship", &Objects[parent_objnum], "Weapon", objp, "Target", &Objects[turret->turret_enemy_objnum]);
+ Script_system.RunCondition(CHA_ONTURRETFIRED, 0, NULL, &Objects[parent_objnum]);
+
  //nprintf(("AI", "Turret_time_enemy_in_range = %7.3f\n", ss->turret_time_enemy_in_range));
  if (weapon_objnum != -1) {
  wp->target_num = turret->turret_enemy_objnum;
Index: parse/scripting.cpp
===================================================================
--- parse/scripting.cpp (revision 8215)
+++ parse/scripting.cpp (working copy)
@@ -71,7 +71,8 @@
  {"On Weapon Fired", CHA_ONWPFIRED, 0},
  {"On Weapon Selected", CHA_ONWPSELECTED, 0},
  {"On Weapon Deselected", CHA_ONWPDESELECTED, 0},
- {"On Gameplay Start", CHA_GAMEPLAYSTART, 0}
+ {"On Gameplay Start", CHA_GAMEPLAYSTART, 0},
+ {"On Turret Fired", CHA_ONTURRETFIRED, 0}
 };
 
 int Num_script_actions = sizeof(Script_actions)/sizeof(flag_def_list);
@@ -279,7 +280,7 @@
  }
  case CHC_WEAPONCLASS:
  {
- if (!(action == CHA_ONWPSELECTED || action == CHA_ONWPDESELECTED || action == CHA_ONWPEQUIPPED || action == CHA_ONWPFIRED)) {
+ if (!(action == CHA_ONWPSELECTED || action == CHA_ONWPDESELECTED || action == CHA_ONWPEQUIPPED || action == CHA_ONWPFIRED || action == CHA_ONTURRETFIRED )) {
  if(objp == NULL || objp->type != OBJ_WEAPON)
  return false;
  else if(stricmp(Weapon_info[Weapons[objp->instance].weapon_info_index].name, scp->data.name) != 0)
@@ -333,7 +334,13 @@
  case CHA_ONWPFIRED: {
  if (! (stricmp(Weapon_info[shipp->weapons.primary_bank_weapons[shipp->weapons.current_primary_bank]].name, scp->data.name) == 0 || (stricmp(Weapon_info[shipp->weapons.secondary_bank_weapons[shipp->weapons.current_secondary_bank]].name, scp->data.name) == 0)))
  return false;
+ break;
  }
+ case CHA_ONTURRETFIRED: {
+ if (! (stricmp(Weapon_info[shipp->last_fired_turret->last_fired_weapon_info_index].name, scp->data.name) == 0))
+ return false;
+ break;
+ }
 
  }
  } // case CHC_WEAPONCLASS
Index: parse/scripting.h
===================================================================
--- parse/scripting.h (revision 8215)
+++ parse/scripting.h (working copy)
@@ -66,6 +66,7 @@
 #define CHA_ONWPSELECTED 24
 #define CHA_ONWPDESELECTED 25
 #define CHA_GAMEPLAYSTART 26
+#define CHA_ONTURRETFIRED 27
 
 // management stuff
 void scripting_state_init();
Index: ship/ship.h
===================================================================
--- ship/ship.h (revision 8215)
+++ ship/ship.h (working copy)
@@ -310,6 +310,7 @@
  float favor_current_facing;        
  ship_subsys *targeted_subsys; // subsystem this turret is attacking
  bool scripting_target_override;
+ int last_fired_weapon_info_index; // which weapon class was last fired
 
  int turret_pick_big_attack_point_timestamp; // Next time to pick an attack point for this turret
  vec3d turret_big_attack_point; // local coordinate of point for this turret to attack on enemy
@@ -708,6 +709,7 @@
  bool shader_effect_active;
 
  int last_fired_point[MAX_SHIP_PRIMARY_BANKS]; //for fire point cylceing
+ ship_subsys *last_fired_turret; // which turret has fired last
 
  // fighter bay door stuff, parent side
  int bay_doors_anim_done_time; // ammount of time to transition from one animation state to another

The ship.h additions were necessary (the other similar workarounds would have been even messier, IMO).

I'm not entirely comfortable committing stuff like this without a chance for someone to review it first, so I'll let this sit here for a day or two first, just in case someone finds something wrong with it.
« Last Edit: January 14, 2012, 04:57:35 pm by zookeeper »

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Function/Feature Requests
^ this kinda thing would probably help improve how my gatling turret system works and will generally better organize my code. will check it out. probably not qualified for the code review though.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Re: Function/Feature Requests
Updated the patch to not cause crashes... :rolleyes:

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Function/Feature Requests
if it hasnt been done already, are there any plans to upgrade lua to 5.2? there are some new goodies, like bit32 library for dealing with bitfields.
« Last Edit: February 29, 2012, 05:39:58 pm by Nuke »
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline zookeeper

  • *knock knock* Who's there? Poe. Poe who?
  • 210
Re: Function/Feature Requests
There's a couple of things I've added recently which I haven't yet mentioned anywhere on the forums:

  • r8457 Added subsystem:getModelName() scripting function, returning the original subsystem name as it appears in the model file, which is useful for example as a unique subsystem identifier.
  • Added weapon:ParentTurret scripting variable, providing a handle to the turret (if any) which fired the weapon. This allows $On Turret Fired hooks to easily get a handle to the fired turret.
  • Added subsystem:TurretLocked scripting variable, providing a way of directly getting/setting the locked status of a turret (also without the random delay incurred by the turret-free SEXP).
  • Added subsystem:NextFireTimestamp scripting variable, exposing the ship_subsys->turret_next_fire_stamp variable to Lua.

I also committed the above $On Turret Fired hook patch.

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Function/Feature Requests
if it hasnt been done already, are there any plans to upgrade lua to 5.2? there are some new goodies, like bit32 library for dealing with bitfields.

Quote from: The Lua 5.2 release notes
...goto statement...

The horror!

Anyway, updating is a good idea.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns

 

Offline m!m

  • 211
Re: Function/Feature Requests
There are some inconsistencies with previous versions which may break the way FreeSpace uses the lua API or a script which relies on a specific behavior although that is unlikely. See this link for a list: http://www.lua.org/manual/5.2/manual.html#8

 

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Function/Feature Requests
most of the changes relate to modules and oop related stuff. heres the changelog from the new manual

things that caught my eye:
like unpack() is now table.unpack()
loadstring has been depricated, and load should be used instead (this affects the way we use cfile to get at external scripts, but only requires switching to load)
math.log10 is depricated
in patterns you must use \0 instead of %z

theres a section on api changes, since ive never implemented lua on the c side im not qualified to point out the anything which may be an issue.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN

 

Offline AndrewofDoom

  • In A.D. 2366 war was beginning
  • 29
  • Permanent yuri goggles.
    • Skype
    • Steam
    • Twitter
Re: Function/Feature Requests
I want a feature to expose the score attribute of a ship class to scripting. It seems silly that this hasn't been done already, yet the score of an event is already accessible. Then again, I'm literally the only person who would even care about such a thing.
My Efforts:
SF Knight

20:08:19   AndrewofDoom: Though I find it mildly disturbing that a loli is giggling to mass destruction.
20:10:01   Spoon: I find it mildly arrousing
20:10:07   AndrewofDoom: Woah
20:10:15   Spoon: sound like my kind of loli
20:10:21   Spoon: and im not even a lolicon

 

Offline Aardwolf

  • 211
  • Posts: 16,384
    • Minecraft
Re: Function/Feature Requests
Score of a ship... isn't that only used for when you kill them? Thinking... why not have a function to award a number of points? (dependent on if you accept the outcome of the mission, ofc.)


 

Offline z64555

  • 210
  • Self-proclaimed controls expert
    • Minecraft
    • Steam
Re: Function/Feature Requests
Would definitely be useful for games/mods that have "bounties" on certain craft. Hopefully later down the road the points system could be augmented to facilitate a money system.  :nod:
Secure the Source, Contain the Code, Protect the Project
chief1983

------------
funtapaz: Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Juche.
z64555: s/J/Do
BotenAlfred: <funtapaz> Hunchon University biologists prove mankind is evolving to new, higher form of life, known as Homopithecus Douche.

 
Re: Function/Feature Requests
Ship:JumpToPoint(Vector3 point)
Makes the ship engages its jump drives and then come back on defined point (Could be used on Alpha 1)

 

Offline The E

  • He's Ebeneezer Goode
  • 213
  • Nothing personal, just tech support.
    • Steam
    • Twitter
Re: Function/Feature Requests
That's much more difficult than it sounds. There are ways to do this using sexps that work quite well and aren't too complicated while allowing a great deal of control over the whole process, so my immediate instinct would be to veto that particular request.
If I'm just aching this can't go on
I came from chasing dreams to feel alone
There must be changes, miss to feel strong
I really need lifе to touch me
--Evergrey, Where August Mourns