Mobbstar Posted February 20, 2016 Share Posted February 20, 2016 (edited) Credits go to @The Letter W for the art and concept. We are trying to make a character ("elecman") who can cast lightning wherever he points. Using Kzisor's amazing keylistener component, this works well on a local game. ElecMan first does an emote, when the charge sound plays, the cursor position gets recorded and the player can let go to summon the lightning strike. However, the server doesn't know the cursor position of the client. Pardon me for the folly of this paragraph in advance. I have only two ideas how it could work, but no ideas how those themselves would work. Maybe a netvar could be used to communicate from server to client and back. Alternatively, the position could somehow be sent by the client automatically, which leads to a large number of consequential problems, so I'd rather not do this. Do you have any idea how to solve this problem? Do you know any mods with similiar problems (not client-only)? The mod in question: -removed- Edited May 2, 2016 by Mobbstar Removed file Link to comment https://forums.kleientertainment.com/forums/topic/64558-using-clients-cursor-position/ Share on other sites More sharing options...
Kzisor Posted February 20, 2016 Share Posted February 20, 2016 (edited) 7 hours ago, Mobbstar said: Do you know any mods with similiar problems (not client-only)? This is already done by the 'blinkstaff' (orange staff). The following code should point you in the right direction, it's all untested but it's good theory/starting place. (Edit: This goes in your modmain.lua file.) local function OnLightningStrike ( act ) -- Call forth lightning strike at act.pos local inst = act.doer inst.SoundEmitter:KillSound("zapcharge_sound") print("ZEUS IS JEALOUS - elec man used lightning strike") inst.AnimState:PlayAnimation("punch") if GLOBAL.TheWorld then local pt = act.pos inst.components.playerlightningtarget:SetHitChance(0) GLOBAL.TheWorld:PushEvent("ms_sendlightningstrike",pt) inst.components.playerlightningtarget:SetHitChance(GLOBAL.TUNING.ELECMAN.LIGHTNING_HITCHANCE) if inst.components.hunger then inst.components.hunger:DoDelta(GLOBAL.TUNING.ELECMAN.FOOD_TO_ZAP) end end end AddAction( "LIGHTNING_STRIKE", "Strike", OnLightningStrike ) AddComponentAction( "POINT", "keyhandler", function( inst, doer, pos, actions, right ) -- Can only do lightning strikes while chargetask is not nil. if inst.chargetask ~= nil and inst:HasTag( "[INSERT TAG HERE]" ) and right then table.insert( actions, ACTIONS.LIGHTNING_STRIKE ) end end ) Edited February 20, 2016 by Kzisor Link to comment https://forums.kleientertainment.com/forums/topic/64558-using-clients-cursor-position/#findComment-724875 Share on other sites More sharing options...
Mobbstar Posted February 20, 2016 Author Share Posted February 20, 2016 Just now, Kzisor said: This is already done by the 'blinkstaff' (orange staff). I obviously did not remember that. Good job me! Thank you, I will try it right now and update this post with my results! Link to comment https://forums.kleientertainment.com/forums/topic/64558-using-clients-cursor-position/#findComment-724877 Share on other sites More sharing options...
SenL Posted February 23, 2016 Share Posted February 23, 2016 I looked at orange staff and couldn't understand it. The staff uses blinkstaff component. In it the only function that teleports caster is ":Blink(pt, caster)" but this function is only called in onhauntorange() (ie: when you haunt the staff as a ghost). Then there is "reticule" component. It uses blinkstaff_reticuletargetfn() to find walkable coordinate when item is being equipped. However, how does these two work together? Link to comment https://forums.kleientertainment.com/forums/topic/64558-using-clients-cursor-position/#findComment-725617 Share on other sites More sharing options...
Muche Posted February 23, 2016 Share Posted February 23, 2016 Its blinkstaff component is referenced in componentactions.lua where it allows use of BLINK action, defined in actions.lua which does indeed call blinkstaff:Blink(). Link to comment https://forums.kleientertainment.com/forums/topic/64558-using-clients-cursor-position/#findComment-725624 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now