Author |
Message |
Shyguy1994
Joined: Wed Nov 26, 2008 7:14 pm Posts: 33 Location: In front of my computer. Ba dum tish.
|
Critical Hits by %?
Finally getting around to ol' Hector again, this time to make his axe score ridiculous critical hits every 1 out of 20 swings or so. I figure a math.ceil sort of thing a la Full-On Assault's spawning system might do the trick, but I'm not sure how to put it together.
tl;dr halp with crits.
|
Mon May 17, 2010 11:15 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Critical Hits by %?
math.random(1,20)
|
Tue May 18, 2010 12:14 am |
|
|
Shyguy1994
Joined: Wed Nov 26, 2008 7:14 pm Posts: 33 Location: In front of my computer. Ba dum tish.
|
Re: Critical Hits by %?
EDIT: Took a proverbial stab in the dark and proverbially stabbed myself in the leg. Even after taking a bunch of different bits of code from a bunch of different people and fixing the "script" up a bit, I've no bloody clue how to get this thing to work. Suffice to say I know nothing about Lua, aside from tutorials, the wiki, and the rest of the forum. Here's the remains of my axe crit lua files, I'll leave em up here until I figure out what I want to do with them. Code: function Update(self)
local theta = ToActor(self.owner):GetAimAngle(true);
if IsSetToBurst = 1 then self.Pos = self.gun.Pos + Vector(math.cos(theta)*10,math.sin(theta)*-10); end self.LifeTime = 1
end
Code: function Update(self)
local crit = 20;
if HeldDevice:IsActivated then if math.random(1,20) == crit then CreateAEmitter ("Splodey Crit"); AEmitter("Splodey Crit"):TriggerBurst("Splodey Crit"); end end
end
|
Tue May 18, 2010 12:27 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Critical Hits by %?
Code: function Create(self) self.CritTimer = Timer() -- Our timer!! end
function Update(self) for actor in MovableMan.Actors do --this makes it so that this code runs on every actor in the scene. 'actor' is used as the variable, but it could be whatever you want. local dist = SceneMan:ShortestDistance(self.Pos, actor.Pos, true).Magnitude --this finds the distance between two points. I put a check in to find the distance, so you'd put this code on a bullet or something. if dist < 4 and self.CritTimer:IsPastMS(500) and math.random(1,20) == 20 then -- if you didn't use the CritTimer, it would make a random roll about 30 times a second, almost guaranteeing a crit. self.Gore = actor --copy the actor. self.Gore.Vel = actor.Vel --give it the same velocity. self.Gore.Pos = actor.Pos --make it spawn in the same place. self.GoreAmount = math.random(1,3) --Find the amount of gore randomly! MUAHAHAAH! actor:GibThis() --KILL THE ACTOR! MUAHAHAHAH! if actor.ClassName == "AHuman" then --Find the Classname to use the right function. for i = 1,self.GoreAmount do --make this code run so many times depending on how many 'i's or 1s are in it. CreateAHuman(self.Gore) --create the pseudo-actor. self.Gore:GibThis() --MAKE IT EXPLODE TO CREATE MORE GORE!!!!! MUAHAHAHAHAAH!! end elseif actor.ClassName == "ACrab" then --same as before but with crabs. might want to put in things for other types. Use elseif to be a bit more efficient. Tables are even better, but I don't know how to use them. for i =1,self.GoreAmount do CreateACrab(self.Gore) self.Gore:GibThis() --BOOOM!! end end end end end Hope it helps.
|
Tue May 18, 2010 9:19 am |
|
|
lolinternets
Joined: Mon May 17, 2010 9:16 pm Posts: 51
|
Re: Critical Hits by %?
could you post that without the comments? its hard to follow with all of that. edit: stupid and lazy of me! but i will do it for eeryone else! Code: function Create(self) self.CritTimer = Timer() end
function Update(self) for actor in MovableMan.Actors do local dist = SceneMan:ShortestDistance(self.Pos, actor.Pos, true).Magnitude if dist < 4 and self.CritTimer:IsPastMS(500) and math.random(1,20) == 20 then self.Gore = actor self.Gore.Vel = actor.Vel self.Gore.Pos = actor.Pos self.GoreAmount = math.random(1,3) actor:GibThis() if actor.ClassName == "AHuman" then for i = 1,self.GoreAmount do CreateAHuman(self.Gore) self.Gore:GibThis() end elseif actor.ClassName == "ACrab" then for i =1,self.GoreAmount do CreateACrab(self.Gore) self.Gore:GibThis() --BOOOM!! end end end end end
|
Tue May 18, 2010 4:49 pm |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Critical Hits by %?
Code: function Create(self) self.CritTimer = Timer() end
function Update(self) for actor in MovableMan.Actors do local dist = SceneMan:ShortestDistance(self.Pos, actor.Pos, true).Magnitude if dist < 4 and self.CritTimer:IsPastMS(500) and math.random(1,20) == 20 then self.Gore = CreateAHuman(actor) self.Gore.Vel = actor.Vel self.Gore.Pos = actor.Pos self.Gore.Sharpness = -231 self.GoreAmount = math.random(1,3) actor:GibThis() for i = 1,self.GoreAmount do MovableMan:AddActor(self.Gore); if actor.Sharpness = -231 then actor:GibThis() end end end end end I made a little mistake in the code.
|
Wed May 19, 2010 4:35 am |
|
|
Shyguy1994
Joined: Wed Nov 26, 2008 7:14 pm Posts: 33 Location: In front of my computer. Ba dum tish.
|
Re: Critical Hits by %?
Not sure where to stick the code - right now I've got it on the MOPixel bullet, but it isn't working. Any ideas?
Attachments:
Devices.ini [7.36 KiB]
Downloaded 191 times
|
Wed May 19, 2010 8:50 pm |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Critical Hits by %?
Last time I tried, self.Pos doesn't seem to work for MOPixels. That would mean it wouldn't be able to check distances, so the code wouldn't do anything. I'm not entirely sure how else you could do it. When you start up CC, press ~ to open up the console, and see what errors it has.
|
Wed May 19, 2010 9:01 pm |
|
|
Grif
REAL AMERICAN HERO
Joined: Sat Jan 27, 2007 10:25 pm Posts: 5655
|
Re: Critical Hits by %?
Huh what? Self.Pos doesn't work for MOPixels? Says who?
|
Thu May 20, 2010 2:32 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Critical Hits by %?
I 'unno, I got some sort of error when I was trying a script one time, and it was saying 'self.Pos? BAD!'.
|
Thu May 20, 2010 3:16 am |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
Re: Critical Hits by %?
MLC, your code doesn't work for three reasons: 1. You're checking if the MOPixel's distance is less than 4 pixels. Considering that the MOPixel is fired at a velocity of 55, the chances of something coming within this range are slim to none. I would suggest doing a raycast or increasing the range. 2. Code: self.Gore = CreateAHuman(actor) In your code, "actor" is a reference to an Actor, not a string. CreateAHuman only takes an actor's name as an argument. You probably mean: Code: self.Gore = CreateAHuman(actor.PresetName) However, this also doesn't work, as you aren't guaranteed that the actor is an AHuman. It could be an ACrab, ACDropShip, ACRocket or just plain Actor. 3. Code: for i = 1,self.GoreAmount do MovableMan:AddActor(self.Gore); if actor.Sharpness = -231 then actor:GibThis() end end You have only created self.Gore once, thus you can only add it once. I'm also not really sure what the sharpness check is for, either.
|
Thu May 20, 2010 3:30 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Critical Hits by %?
Well, I wasn't sure if you could still address the created actor by self.Gore, so I gave it a certain sharpness as a code and made it so any object with that sharpness just blew up. :3
(Also, not only do I not know a thing about tables, I'm also clueless about ray casting.)
Last edited by CrazyMLC on Thu May 20, 2010 4:12 am, edited 2 times in total.
|
Thu May 20, 2010 4:08 am |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
Re: Critical Hits by %?
It won't work the way you think. That's only going to work on the current actor being checked, and only if it's within 4 pixels.
|
Thu May 20, 2010 4:12 am |
|
|
CrazyMLC
Joined: Fri Dec 22, 2006 4:20 am Posts: 4772 Location: Good news everyone!
|
Re: Critical Hits by %?
Oh, right. That might cause it to not work, possibly. Maybe. >_> <_< >_> Code: function Create(self) self.CritTimer = Timer() end
function Update(self) for actor in MovableMan.Actors do local dist = SceneMan:ShortestDistance(self.Pos, actor.Pos, true).Magnitude if dist < 25 and self.CritTimer:IsPastMS(250) and math.random(1,20) == 20 then self.CritTimer:Reset() if actor.ClassName = "AHuman" then self.GoreAmount = math.random(1,3) for i = 1,self.GoreAmount do self.Gore = CreateAHuman(actor.PresetName) self.Gore.Vel = actor.Vel self.Gore.Pos = actor.Pos self.Gore.Sharpness = -231 MovableMan:AddActor(self.Gore); end actor:GibThis() end end if actor.Sharpness = -231 then actor:GibThis() end end end (If it isn't an AHuman it just wont blow up into a big bloody pile.)
Last edited by CrazyMLC on Thu May 20, 2010 4:31 am, edited 1 time in total.
|
Thu May 20, 2010 4:14 am |
|
|
TheLastBanana
DRL Developer
Joined: Wed Dec 13, 2006 5:27 am Posts: 3138 Location: A little south and a lot west of Moscow
|
Re: Critical Hits by %?
Close, but no cigar. Code: self.Gore = CreateAHuman(actor) Check the last post on what I said about this.
|
Thu May 20, 2010 4:30 am |
|
|
|
Who is online |
Users browsing this forum: No registered users |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|