- Joined
- May 25, 2009
- Messages
- 100
So there's no way to make the 3rd Person Camera for more than 1 player?
Hello im having a problem using the multiplayer emulation with sharpcraft... keeps telling me "unable to initialize Warcraft III" after attempting to open more than one window at a time... it will open the first but not the rest...
So there's no way to make the 3rd Person Camera for more than 1 player?
GetLocalPlayer()
, if I understand correctly.TriggerRegisterMouseEvent()
and add an action. Now the code gets fire everytime a player clicks the LMB and the action gets called.TriggerRegisterMouseEvent()
isn't a Wc3 native, i can't catch the GetTriggerPlayer()
, so GetLocalPlayer() == GetTriggerPlayer()
doesn't work and GetLocalPlayer() == Player(0)
gets called, even if Player 2 pressed the LMB (Just for Player 1 but i still don't want that).As far as i know it's not possible. For example:
I register a LMB click - event withTriggerRegisterMouseEvent()
and add an action. Now the code gets fire everytime a player clicks the LMB and the action gets called.
But then the function doesn't know which player pressed the button.
BecauseTriggerRegisterMouseEvent()
isn't a Wc3 native, i can't catch theGetTriggerPlayer()
, soGetLocalPlayer() == GetTriggerPlayer()
doesn't work andGetLocalPlayer() == Player(0)
gets called, even if Player 2 pressed the LMB (Just for Player 1 but i still don't want that).
And by the way: Is it even possible right now, to have more than 1 human player? Because there're no playerslot in the lobby for sharpcraftmaps.
I did what you said. I came to the point where it opens Warcraft, then it (the "console") crashes (stops working). And I am still unable to start the Sharpcraft map.
Thanks for taking your time to help!
[...]
[...]
[...]
You've been talking a bit about Mouse natives and multiplayer. Whether it works in multiplayer or not is up to whoever made the native. SharpCraft itself does not add any natives. I assume the natives you're talking about are these: http://www.hiveworkshop.com/forums/lab-715/custom-jass-natives-requests-submissions-244688/[...]
Looks like an issue with the registry database. Not sure exactly what though. Try and make sure everything is in order in the registry.![]()
this is what i get -_- in 2.07
Seems like it's failing injecting the hack. I've been improving the injection technique, so the next version might work better.Here it is, this is how it looks when it crashes. It starts Wc3 but only the main menu.
I really doubt that's going to be doable, but I'll keep in in the back of my head.Can you make wc3 reload some files on map init it currently only does on game startup, so we can have custom soundsets for example?
It's not quite that simple, but I have hooked DirectX which allows drawing on screen. Not much work has been put into it yet though.What about adding the System.Drawing to the reference, so we could paint some images on the screen?
Or is there an issue i don't know about?
v2.2.4
* Giant refactor. Too many changes to list them all.
* Added three new base classes for scripting.
* * FullPluginBase; // This class is for plugins that need full access, which means file writing and more.
* * SafePluginBase; // This class is for plugins that only need safe access.
* * MapScriptBase; // This class is for internal war3map.cs scripts. It is similar to SafePluginBase.
* The sandbox milestone reached 100%, meaning more safety.
* Interplugin usage it possible through simple dependency.
sub_6F2F45D0Hook
- this: 1BEF0088
- id: A000
- order: healon
- uberTip: "H|cffffcc00e|ral"(16)
- tooltip: "Heals a target friendly non-mechanical wounded unit for 101 hit points. Costs 801 mana.
|cffc3dbffRight-click to activate auto-casting.|r"(138)
- a5: 00000321
- result: 0000008A
...
private void Script_PostMain()
{
var trigger = JassTrigger.Create();
trigger.RegisterPlayerEvent(JassPlayer.FromIndex(0), JassPlayerEvent.EndCinematic);
trigger.AddAction(new Action(this.ESCAction));
}
private void ESCAction()
{
Trace.WriteLine("ESC");
}
...
Ehm, I'm a little bit confused - what kind of feature? Or is it the ability to write script for maps in C#?
...
private void Script_PostMain()
{
string s = "ESC"
var trigger = JassTrigger.Create();
trigger.RegisterPlayerEvent(JassPlayer.FromIndex(0), JassPlayerEvent.EndCinematic);
trigger.AddAction(new Action(this.ESCAction(s)));
}
private void ESCAction(string s )
{
Trace.WriteLine(s);
}
...
I could definitely implement that, a sort of "state" object, which is popular in .NET. Basically, it can be anything, a string, int, array of ints, or even a full class, and have it passed around. I'll make sure to implement that.Does it still have the Jass Limitations, eg. adding parameters to the action calls?
JASS:... private void Script_PostMain() { string s = "ESC" var trigger = JassTrigger.Create(); trigger.RegisterPlayerEvent(JassPlayer.FromIndex(0), JassPlayerEvent.EndCinematic); trigger.AddAction(new Action(this.ESCAction(s))); } private void ESCAction(string s ) { Trace.WriteLine(s); } ...
...
private void Script_PostMain()
{
string s = "ESC"
var trigger = JassTrigger.Create();
trigger.RegisterPlayerEvent(JassPlayer.FromIndex(0), JassPlayerEvent.EndCinematic);
trigger.AddAction(new Action(() => { Trace.WriteLine(s); }));
}
...
Cool ^^ will it be constant then? Like when you declare the action and your state object is "1" and you do some stuff and change it to "2" and now the trigger gets fired...is it "1" or "2" in the action?
Cool ^^ will it be constant then? Like when you declare the action and your state object is "1" and you do some stuff and change it to "2" and now the trigger gets fired...is it "1" or "2" in the action?
...
private void CastHealOn(JassUnit caster, JassUnit target, Single amount, Single duration)
{
var healState = new HealState();
healState.Caster = caster;
healState.Target = target;
if (new Random().NextDouble() <= 0.10) // 10 % chance of double heal and 50 % longer duration.
{
healState.Amount = amount * 2;
healState.Duration = duration * 1.50f;
}
else
{
healState.Amount = amount;
healState.Duration = duration;
}
healState.Trigger = JassTrigger.Create();
healState.Trigger.RegisterTimerEvent(0.50f, true);
healState.Trigger.AddAction(new ManagedAction(HealTick), healState);
}
private void HealTick(Object state)
{
var healState = (state as HealState);
// use healState.Caster to award some experience to the caster for each heal effect.
// use healState.Target to modify the targets health by healState.Amount.
healState.Duration -= 0.50f;
if (healState.Duration <= 0.00f)
{
healState.Trigger.Enabled = false;
healState.Trigger.Destroy();
}
}
class HealState
{
public JassUnit Caster;
public JassUnit Target;
public Single Amount;
public Single Duration;
public JassTrigger Trigger;
}
...
WHAT IS THIS SORCERY!!!!!The state object can be anything, literally. So if you want it to be a single constant used value, you just pass a constant value. If you want to create a periodic heal effect on a unit, you can pass the unit as the state object and cast the state object to a unit in the callback and then update the health that way.
Here's a psuedocode example.
I don't know if that's good code or not, I don't know if you're supposed to destroy triggers like that, but it'll give you an idea what can be done using the state object.C#:... private void CastHealOn(JassUnit caster, JassUnit target, Single amount, Single duration) { var healState = new HealState(); healState.Caster = caster; healState.Target = target; if (new Random().NextDouble() <= 0.10) // 10 % chance of double heal and 50 % longer duration. { healState.Amount = amount * 2; healState.Duration = duration * 1.50f; } else { healState.Amount = amount; healState.Duration = duration; } healState.Trigger = JassTrigger.Create(); healState.Trigger.RegisterTimerEvent(0.50f, true); healState.Trigger.AddAction(new ManagedAction(HealTick), healState); } private void HealTick(Object state) { var healState = (state as HealState); // use healState.Caster to award some experience to the caster for each heal effect. // use healState.Target to modify the targets health by healState.Amount. healState.Duration -= 0.50f; if (healState.Duration <= 0.00f) { healState.Trigger.Enabled = false; healState.Trigger.Destroy(); } } class HealState { public JassUnit Caster; public JassUnit Target; public Single Amount; public Single Duration; public JassTrigger Trigger; } ...
I'll have to see how well abstract classes work with MarshalByRefObject, but that's an even better solution. Perhaps allow both, as one way easily allows anonymous methods but the other allows more structured flow for systems.Maybe I'm overthinking things, but I think a base class with a protected constructor (could be abstract too if a constructor in the base class is not necessary) would be pretty good here. It would have the following methods:
- /virtual/ Condition(void) (defaults to true)
- /virtual/ Action(void) (defaults to "donothing")
- AddEvent(Type eventType,params Object[] parameters) / AddXYZEvent(<parameters>)
- Enable(bool enabled)
- possibly others too - only the first two, virtual ones are important for what I'm trying to say
People could just extend from it, override the necessary methods, and attach whatever else they want to the trigger instance. No need for parameters, typecasting, or anything similar. We're using C#, a pure OO language, after all.
This is almost working sorcery. Right now I have an issue with the game state when I'm detecting the events. For some reason anything JassString related seems to crash, which is a bit limiting. This means no DisplayTextToPlayer, but creating units is fine. I'm sure I can come up with a solution, but it's taking longer than expected.WHAT IS THIS SORCERY!!!!!
Or better, is this sorcery working?
I'll have to see how well abstract classes work with MarshalByRefObject, but that's an even better solution. Perhaps allow both, as one way easily allows anonymous methods but the other allows more structured flow for systems.
public abstract class AutoTrigger
{
public JassTrigger Trigger { get; private set; };
public virtual bool Condition() { return true; }
public virtual void Action() { }
private static bool ConditionHandler(Object obj)
{
return (obj as AutoTrigger).Condition();
}
private static void ActionHandler(Object obj)
{
(obj as AutoTrigger).Action();
}
protected AutoTrigger()
{
this.Trigger=JassTrigger.create();
this.Trigger.AddCondition(new ManagedCondition(ConditionHandler),this);
this.Trigger.AddAction(new ManagedAction(ActionHandler),this);
}
~AutoTrigger()
{
this.Trigger.Destroy();
}
}
...
public class SpellExample: AutoTrigger
{
//store your stuff here
public override bool Condition()
{
//return true if the caster spell's id matches the spell's id
}
public override void Action()
{
// Do some fancy stuff here, using the things attached to your instance
}
public SpellExample()
{
this.Trigger.RegisterSpellEffectEvent();
this.Trigger.Enabled=true;
}
}
Im curious what blizz employes would say if this gets popular.
And if I'm here, does such script work on battle net? Ive read thread and it seems that answer is: yes. However it still seems to be risky. Im curious what blizz employes would say if this gets popular.
Don't get me wrong; it allows to do *some* things, but let's face it: if one of the players doesn't have SharpCraft, then it's use will be so extremely limited that it doesn't justify using SharpCraft at all.AFAIK it works. It is all local responses and stuff though. So you run the risk of desync if the other person doesn't have SharpCraft and you do something desyncy (e.g. you have a function that checks if a key is down. If the other user doesn't have sharpcraft, then it won't do anything, but it may pass for the user who does have sharpcraft. The action would then be evaluated only for the SharpCraft user, and if it, for example, creates a handle, then things will likely desync). Eh, but that is theoretical. I haven't tested it.
You can't get past the lobby with custom natives. With custom natives, you have to run the map through sharpcraft externally (unless, maybe, you include a custom common.j or something?). You can, however, override natives. That way, you can offer special functionality to those who have SharpCraft, and the other people who don't have it can still load the game.
And I think Luorax summed up Blizz's potential response quite nicely.![]()
Don't get me wrong; it allows to do *some* things, but let's face it: if one of the players doesn't have SharpCraft, then it's use will be so extremely limited that it doesn't justify using SharpCraft at all.
I think you are just overcomplicating things by trying to allow a non-SharpCrafter play the map by replacing natives instead of adding custom natives. It has almost no practical use.
v2.2.5.124b
* Expanded the managed JASS type wrappers.
* Implemented script-side events (issue #4)
* Implemented new method for calling natives with strings, resulting in more speed, since we're avoiding conversion.
* Implemented a better method for adding trigger actions.
* Implemented a few more Jass types.
* Minor improvement for the InternalNatives.JassStringHandleToString if check.
* Added missing DelegateAction type.
* Included commit number in the version number.
* Fixed a bug with returned JassStrings when calling natives directly.