Giter VIP home page Giter VIP logo

damagecore's Introduction

DamageCore

DamageCore is an extension module for the Wire Expression 2 Chip. It enables players to detect and/or deal damage to other entities.

Workshop Installation

The DamageCore is available on the Steam Workshop! Go to the DamageCore Workshop Page and press Subscribe. For can go to the Expression 2 Core Collection for more extensions.

Manual Installation

Clone this repository into your steamapps\common\GarrysMod\garrysmod\addons folder using this command if you are using git:

git clone https://github.com/sirpapate/damagecore.git

Documentation

Events

Declaration Replacing Description
event damage(Victim:entity, Damage:damage) runOnDmg, dmgClk, lastDamage, lastDamageVictim Triggered when an entity takes damage.
event trackedDamage(Victim:entity, Damage:damage) Triggered when an entity in the list of tracked (with "E:trackDamage()") entities takes damage.
event playerDamage(Victim:entity, Damage:damage) Triggered when a player takes damage.

Tick Functions

Function Return Description
runOnDmg(N) If set to 1, E2 will run when an entity takes damage.
runOnDmg(N,E) If set to 1, E2 will run when specified entity takes damage.
runOnDmg(N,R) If set to 1, E2 will run when specified entities take damage.
E:trackDamage() E2 will run when the specified entity takes damage.
T:trackDamage() E2 will run when the specified entities take damage.
E:stopTrackDamage() E2 will no longer run when the specified entity takes damage.
R:stopTrackDamage() E2 will no longer run when the specified entities take damage.
getDamageTrackedEntities() R Returns a array of all tracked entities.
E:isDamageTracked() N Returns 1 if the entity is tracked. Returns 0 otherwise.
dmgClk() N Returns 1 if the chip is being executed because of a damage event. Returns 0 otherwise.
lastDamage() XDM Returns the last damage.
lastDamageVictim() E Returns the victim of the last damage.

Damage Type

Function Return Description
damage() XDM Makes an empty damage.
XDM:clone() XDM Returns a copy of the damage.
XDM:toTable() T Converts the damage into a table.
XDM:getDamage() N Returns the damage amount.
XDM:getAttacker() E Returns the attacker of damage.
XDM:getForce() V Returns a vector representing the damage force.
XDM:getPosition() V Returns the position where the damage was or is going to be applied to.
XDM:getType() N Returns a bitflag which indicates the damage type of the damage.
XDM:getInflictor() E Returns the inflictor of the damage. This is not necessarily a weapon.
XDM:isBulletDamage() N Returns 1 if the damage was caused by a bullet.
XDM:isExplosionDamage() N Returns 1 if the damage contains explosion damage.
XDM:isFallDamage() N Returns 1 if the damage contains fall damage.
XDM:setDamage(N) XDM Sets the amount of damage. Returns itself.
XDM:setAttacker(E) XDM Sets the attacker of the damage. Returns itself.
XDM:setForce(V) XDM Sets the directional force of the damage. Returns itself.
XDM:setPosition(V) XDM Sets the position of where the damage gets applied to. Returns itself.
XDM:setType(N) XDM Sets the damage type. Returns itself.
XDM:setInflictor(E) XDM Sets the inflictor of the damage for example a weapon. Returns itself.

Applying Damage Functions

Function Return Description
canDamage(E) N Returns 1 if the entity can be damaged by the player.
E:takeDamage(XDM) Applies the damage specified by the damage info to the entity.
E:takeDamage(N,E) Applies the specified amount of damage to the entity. (Damage Amount)
E:takeDamage(N,E) Applies the specified amount of damage to the entity. (Damage Amount, Attacker)
E:takeDamage(N,E,E) Applies the specified amount of damage to the entity. (Damage Amount, Attacker, Inflictor)
blastDamage(XDM,V,N) Applies spherical damage based on damage info to all entities in the specified radius. (Damage, Position, Radius)
blastDamage(E,E,V,N,N) Applies explosion damage to all entities in the specified radius. (Attacker, Inflictor, Position, Radius, Damage Amount)

damagecore's People

Contributors

sirpapate avatar

Stargazers

 avatar viral32111 avatar

Watchers

James Cloos avatar

Forkers

cfc-servers

damagecore's Issues

CCIP

sv: Expression 2 (LOCATOR_E2_WIP_volume control_DEADLYSHIT!): entities/gmod_wire_expression2/core/custom/damagecore.lua:545: attempt to call method 'CPPICanDamage' (a nil value)

when trying to kill an NPC this issue comes up and then the e2 has to be reset in order to work..........i removed a line of code that when i tried to kill an NPC before it would flat out crash the server/game but now it does this can you please redo this wonderful addon to allow killing players/and npc with out an issue? cause my server uses it and when this issue comes up its game breaking :(

Access violation crash on blast damage

Not exactly sure why, but using blast damage causes gmod to crash.
E2 code that i used was only using the standard e2 functions and DamageCore.
Here's a Lua traceback from the minidump:

-Lua Stack Traces-
Client
Not in Lua call OR Lua has panicked

Server
0. BlastDamageInfo - [C]:-1
1. (null) - entities/gmod_wire_expression2/core/custom/damagecore.lua:654
2. (null) - entities/gmod_wire_expression2/core/core.lua:34
3. pcall - [C]:-1
4. (null) - entities/gmod_wire_expression2/core/core.lua:134
5. (null) - entities/gmod_wire_expression2/core/core.lua:34
6. pcall - [C]:-1
7. Execute - lua/entities/gmod_wire_expression2/init.lua:132
8. Execute - entities/gmod_wire_expression2/core/timer.lua:13
9. (null) - entities/gmod_wire_expression2/core/timer.lua:33

MenuSystem
Not in Lua call OR Lua has panicked

I had this crash 3 times, and they all have the same error.
It might also be my awful E2 coding abilities, but the error does not occure always, and the
E2 code is validated.

damagecore's `damage` type uses an invalid type ID

In E2, type IDs must be one character other than 'x', or three characters and begin with an x. The damage type's ID is dmg. This breaks things like E2Helper, and would break extra hard if another extension added a type with ID d or m or g.

I've just added a check to Wiremod to prevent this kind of thing from happening, which means that in the July 2018 Release, instead of damagecore breaking E2Helper, it will instead fail to load with the error:

There was an error loading the custom/damagecore.lua extension. Please report this to its developer.
entities/gmod_wire_expression2/core/custom/damagecore.lua:95: malformed type ID 'dmg' - type IDs must be one character long, or three characters long starting with an x

weird issue dont know how to fix

my e2 uses this core and ever single time i try to use it on a player i get this error: sv: Expression 2 (LOCATOR_E2_COMPLETE_WITH_DISH_updatedmost_22A): entities/gmod_wire_expression2/core/custom/damagecore.lua:323: bad argument #1 to 'pairs' (table expected, got number)

Functionality now builtin to E2

damage type and pretty much all functionality from this extension is builtin to wiremod now.

wiremod/wire#2628
wiremod/wire#2675

A lot of users that have both wiremod and this extension are encountering issues and I think it would be best if you added a disclaimer to the workshop or something that this is the case.

You could also add this to the top of the core file to print out a warning or prevent itself from running:

if WireLib.CanDamage then ... end

But that part is more on our side to handle registerType conflicts better.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.