Back to Index Page generated: Nov 12, 2024, 11:02:04 PM

Expansion Reduce Weapon Damage

Content

Warnings

  1. Information URL mismatch between OXP Manifest and Expansion Manager string length at character position 0

Manifest

from Expansion Manager's OXP list from Expansion Manifest
Description Reduce damage of lasers to player & most npc-ships Reduce damage of lasers to player & most npc-ships
Identifier oolite.oxp.Lone_Wolf.ReduceWeaponDamage oolite.oxp.Lone_Wolf.ReduceWeaponDamage
Title Reduce Weapon Damage Reduce Weapon Damage
Category Mechanics Mechanics
Author Lone_Wolf Lone_Wolf
Version 0.10 0.10
Tags
Required Oolite Version
Maximum Oolite Version
Required Expansions
Optional Expansions
Conflict Expansions
Information URL n/a
Download URL https://wiki.alioth.net/img_auth.php/2/2c/Reduce_Weapon_Damage_0.10.oxz n/a
License CC-BY-SA 4.0 CC-BY-SA 4.0
File Size n/a
Upload date 1610873258

Documentation

Also read http://wiki.alioth.net/index.php/Reduce%20Weapon%20Damage

ReduceWeaponDamage v 0.10 ReadMe & License.txt

--------------------------------------------------------------

License:
This work is licensed under the Creative Commons Attribution-Share Alike 4.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/ 
or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA. 

--------------------------------------------------------------



Background

Oolite 1.80 brought many AI improvements for npc ships.
The increased difficulty meant new players had to learn how to to stay out of trouble very fast or they would die in seconds.
Even veteran players had a hard time starting with a fresh commander.

It looked to me the main difference was that npc had become much better at making shots hit the target.
In http://aegidian.org/bb/viewtopic.php?f=2&t=16837 several approaches to solve this were discussed, and the most promising one was to reduce the damage done by shots.
This required changes in the source code, i started looking for a way to replicate this in 1.80 and found one.

http://aegidian.org/bb/viewtopic.php?f=4&t=16925
My approach there had one big disadvantage : it was very player-centric.

I thought long and hard about the comments there, concluded that reducing damage for both player and npc would have this effect :
increased survivability for player AND npc ships > longer fights 

The code to accomplish this wasn't easy, http://aegidian.org/bb/viewtopic.php?f=4&t=16947 .

--------------------------------------------------------------

Reduce Weapon Damage

reduces damage from laser/missile hits on player ship & most npc ships by 8 .
(the effect on missile hits should barely be noticable) .
This means more shots are needed to kill a ship.

History

v 0.10 First released version

Equipment

This expansion declares no equipment. This may be related to warnings.

Ships

This expansion declares no ships. This may be related to warnings.

Models

This expansion declares no models. This may be related to warnings.

Scripts

Path
Scripts/Reduce_Weapon_Damage.js
"use strict";
this.name           = "Reduce Weapon Damage";
this.author         = "Lone_Wolf";
this.copyright      = "(C) 2014 Lone_Wolf.";
this.licence        = "CC-by-SA 4.0";
this.description    = "Reduce laser/missile damage for ships";
this.version        = "0.10";

// Player ship and all npc-ships that qualify ( see this.shipSpawned handler) will have their own separate instance of this script

// using separate values for player / npc for flexibility .
this._rwd_player_reduction = 8;
this._rwd_npc_reduction = 8;

this.startUpComplete = function()
  {
    // setup handler for player.ship . npc-ships are dealt with by this.shipSpawned handler
    if ( !player.ship.script ) { player.ship.setScript("oolite-default-ship-script.js"); }; // just in case
    if ( player.ship.script.shipTakingDamage ) 
      {
	// there is already a shipTakingDamage handler, store it
	player.ship.script._rwd_player_oldShipTakingDamage = ship.script.shipTakingDamage;
      };
    player.ship.script._RWD = this; // setup pointer
    var new_std = function(amount, whom, type)
      {
	worldScripts["Reduce Weapon Damage"]._rwd_player_ShipTakingDamage(this.ship, amount, whom, type); 
	if ( player.ship.script._rwd_player_oldShipTakingDamage )
	  { 
	    player.ship.script._rwd_oldShipTakingDamage(amount, whom, type); //call the original function 
	   };
      };
    player.ship.script.shipTakingDamage = new_std;
  };

this._rwd_player_ShipTakingDamage = function (whoami, amount, whom, type)
  {
    if ( type != "energy damage" ) { return; }; // only act upon laser / missile damage
    if ( amount != 0 ) { return; }; // if hit penetrated shields, do nothing
    /* shields have absorbed hit, there is no known way to determine the strength of the hit
    * simplest solution to reduce damage is to increase shield strength
    */
    // try to determine whether forward or aft shield is hit
    if( whom && whom.isValid && ( player.ship.vectorForward.dot(player.ship.position.subtract(whom.position) ) > 0 ) ) 
      { 
	// forward shield hit
	player.ship.forwardShield += player.ship.script._RWD._rwd_player_reduction;
      }
    else
      {
	// aft hit
	player.ship.aftShield += player.ship.script._RWD._rwd_player_reduction;
      };
  };

  

this.shipSpawned = function(ship)
  {
    // called for non-player ships only
    if ( !ship || !ship.isPiloted || ship.isThargoid || ship.isStation ) { return; }; // only change npc-ships
    if ( !ship.autoWeapons ) {return; }; // ship properties are not supposed to be altered
    if ( !ship.script ) { ship.setScript("oolite-default-ship-script.js"); }; // just in case
    if ( ship.script.shipTakingDamage ) 
      {
	// there is already a shipTakingDamage handler, store it
	ship.script._rwd_npc_oldShipTakingDamage = ship.script.shipTakingDamage;
      };
    ship.script._RWD = this;
    var new_std = function(amount, whom, type)
      {
	amount = worldScripts["Reduce Weapon Damage"]._rwd_npc_ShipTakingDamage(this.ship, amount, whom, type); 
	if ( ship.script._rwd_npc_oldShipTakingDamage )
	  { 
	    ship.script._rwd_npc_oldShipTakingDamage(amount, whom, type); //call the original function 
	   };
      };
    ship.script.shipTakingDamage = new_std;
};
  
this._rwd_npc_ShipTakingDamage = function (whoami, amount, whom, type)
  {
    if ( type != "energy damage" ) { return amount; }; // only act upon laser / missile damage
    // npc ship, all that's needed is reducing damage amount
    amount -= whoami.script._RWD._rwd_npc_reduction;
    return amount;
  };