Modifying core game method?

Started by NoImageAvailable, January 25, 2015, 04:19:47 PM

Previous topic - Next topic

NoImageAvailable

I'm pretty new to C# and DLLs in general so bear with me please. What I am trying to do is modify the HitReportFor method to cut shotDistance down to a quarter. How could I go about that?
"The power of friendship destroyed the jellyfish."

Wastelander

There's no standard way to override core game classes, only where provided (I.E. where an XML lets you define your own class).

What are you trying to accomplish? Reduce the effect of range on fired weapons?

NoImageAvailable

Quote from: Wastelander on January 29, 2015, 04:32:51 PM
There's no standard way to override core game classes, only where provided (I.E. where an XML lets you define your own class).

What are you trying to accomplish? Reduce the effect of range on fired weapons?

Yes. I implemented a custom Verb_Shoot which uses its own HitReportFor method and weapons will work just fine. However, the Pawn class still calls the method from Verb_LaunchProjectile, generating a faulty accuracy report for the tooltip and since it is typecast I can't simply hide the method.
"The power of friendship destroyed the jellyfish."

Rikiki

The M&Co. Laser weapons mod contains an example of how to override the core Verb_LaunchProjectile class (Verb_ShootWithCustomWarmup).
Have a look at it. :)

NoImageAvailable

Quote from: Rikiki on January 29, 2015, 05:31:53 PM
The M&Co. Laser weapons mod contains an example of how to override the core Verb_LaunchProjectile class (Verb_ShootWithCustomWarmup).
Have a look at it. :)

I looked at it but it seems to me like its also just a custom version of Verb_Shoot. The problem is that Verse.Pawn.GetTooltip() uses this:
Verb_LaunchProjectile verb_LaunchProjectile = pawn.equipment.Primary.PrimaryVerb as Verb_LaunchProjectile;
Meaning any class inheriting from Verb_LaunchProjectile will use the vanilla HitReportFor method and since I changed the hit chance calculations on the weapon it will produce inaccurate values.
"The power of friendship destroyed the jellyfish."

Rikiki

OK, I see your point.
This will be very hard to modify then... :P

NoImageAvailable

Quote from: Rikiki on January 30, 2015, 05:22:09 AM
OK, I see your point.
This will be very hard to modify then... :P

Yeah, I'll probably just accept it and move on to something easier. Like figuring out how to make a projectile spawn another projectile. ::)
"The power of friendship destroyed the jellyfish."

skullywag

#7
projectiles tick, therefore you have a method in which to spawn your other proj.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

NoImageAvailable

Quote from: skullywag on January 30, 2015, 01:01:16 PM
projectiles tick, therefore you have a method in which to spawn your other proj.

Thanks for the hint, I'll probably have a look at it this weekend and see if I can make some kind of rocket-propelled grenade effect.
"The power of friendship destroyed the jellyfish."