| 02-06-2010, 08:00 AM | #1 |
I'm currently working on a friends project (has still no name...) map description: * 2 team with 6 players each * each team has a tower to defend * now each team has one player controlling the ballistae of the team's tower --> cam eye position locked, can only look up and down and turn (xy:-45°; 45°| z: +30°;-60°); frist person cam problem: how to detect clicks and get the curser-position of the two ballistae-players? 2 ways: 1) cover everything around the tower with trackables 2) cover everything around the tower with alphaed-out units and detect spellcast I'd prefer to use the first method now I'm stuck how to set a trackables z and more important, how to calculate the positions of the trackables I've seen some fps-mod flying around here, but didn't get it working for only 2 players instead of all IMPORTANT: should be useable in lan and bnet if anyone can help me he'll be +rep ed and mentioned in the maps credits |
| 02-06-2010, 08:48 AM | #2 |
you can use a dummy targeting ability that is 'forced' for the ballista users: - every short interval, force the ballista users to select units with the dummy targeting ability and do ForceUIKey(dummyAbilityHotkey) for them. - detect when the units use/are-ordered-to-use the dummy ability. this will also give information on the target of the 'click'. you can automate the missile by using pocket factory as the dummy ability: detect when the summon spawns and run your effects at its position. |
| 02-06-2010, 09:22 AM | #3 |
yea..., only problem is, that the cam is parallel to the ground, and the ability needs to target something --> can't target ground, cause most times the player can't see it --> needs to target something --> need to create units --> need to know the units positions --> can also use trackables the main problem is the calculation, not the real mouselistener/clickdetection/whatever |
| 02-06-2010, 02:21 PM | #4 |
you want to use some struct for it; Zinc:library libTrackable { type trackableFunc extends function (Trackable); struct Trackable { private real m_x; private real m_y; private real m_z; private player m_p; private string m_model; trackable self; private trackableFunc m_onClick; private trackableFunc m_onMouseOver; private static trigger actions; private static hashtable storage = InitHashtable(); private static location loc = Location(0, 0); method operator x () -> real { return m_x; } method operator y () -> real { return m_y; } method operator z () -> real { return m_z; } method operator model () -> string { return m_model; } method operator owner () -> player { return m_p; } private static method registerEvent () { Trackable this = Trackable(LoadInteger(storage, 0, GetHandleId(GetTriggeringTrackable())); if (GetTriggerEventId() == EVENT_TRACKABLE_HIT) { // or w/e this is m_onClick.evaluate(this); } else { m_onMouseOver.evaluate(this); } } static method create (string model, player p, real x, real y, real z, trackableFunc onClick, trackableFunc onMouseOver) -> Trackable { Trackable this = allocate(); destructable d; string s = ""; if (GetLocalPlayer() == p) { s = model; } MoveLocation(loc, x, y); z += GetLocationZ(loc); d = CreateDestructableZ('OTip', x, y, z, 0.00, 1, 0); self = CreateTrackable(s, x, y, 270); RemoveDestructable(d); d = null; m_actions = CreateTrigger(); m_onClick = onClick; m_onMouseOver = onMouseOver; m_model = model; m_x = x; m_y = y; m_z = z; TriggerRegisterTrackableHitEvent(actions, self, function registerEvent); TriggerRegisterTrackableTrackEvent(actions, self, function registerEvent); return this; } private static method onInit () { actions = CreateTrigger(); TriggerAddAction(actions, function registerEvent); } } } |
| 02-07-2010, 05:47 PM | #5 | |
Quote:
thanks for the struct, man...(especially the set z-thingy...) +rep only thing I don't get is why you evaluate the trackableFuncs and not execute them... |
