Jump to content

Working on a Sling mod, trying to code a few odd behaviors.


Recommended Posts

Hello everyone, this is the Walrus's introductory post to the forums.
 
I have started work on a sling mod today, and there are three behaivors I am trying to figure out how to code, or have a bit of code that I think might work, but that I want a second opinion on.
 
The first.
 

local function accmodifier(inst, attacker, target)	if target = "largecreature"		inst.local.sizemod(-20)	else if target= "smallcreature"		inst.local.sizemod(20)	else		inst.local.sizemod(0)	end		if attacker = "wilson"		inst.local.edumod(-10)	else		inst.local.edumod(0)	endend

The goals of this bit of code:
1: To check if creatures are considered big or small, and to set a temporary variable based on this.
 
2: To check if the creature using the missile weapon is wilson, and set a temporary variable based on this.
 
3: The accuracy formula I am working on uses a 1-100 random roll, and then adds the targets sizemod, and the users edumod to to the roll. If the roll is less then the slings maxroll, it hits.
 
4: The goal is to make a series of weapons that as a general hunting tool (Most hunting/trapping I see is of small creatures,) feels very unreliable. When fighting large creatures, it is likely to hit, but it takes a long time to fire, making it difficult to kite with. (This makes it very much a tool made for teamwork.)
 
 
This takes me to my second issue:
 
I see the bit of code which is the function for a shot hitting, but I want to set it up so that when the accuracy roll fails, the projectile harmlessly passes the target, but is still able to collide with other objects.
 

local function onhit(inst, attacker, target)    local impactfx = SpawnPrefab("impact")    if impactfx then	    local follower = impactfx.entity:AddFollower()	    follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0 )		if attacker then	        impactfx:FacePoint(attacker.Transform:GetWorldPosition())		end    end    inst:Remove()end

This seems to have something to do with collision detection. Would I add the hit-roll to the start of this, and make the miss function an else to this?
 
Then thirdly:
 
It seems that projectiles vanish at the end of their range (In the case of darts, at least,) how would I make it so the projectile weapons projectile instead falls to the ground, and makes a noise which makes nearby creatures think the player is where the projectile landed?
 
I intend to make it so you can fire the weapon out of your own pocket at the terrain (with a function similar to placing structures,) or hold it in your hand and fire it at creatures, to make it a useful tool in sheparding animals.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...