idanwin Posted August 18, 2013 Report Share Posted August 18, 2013 (edited) I suggest replacingcase "convertunit": for each (var ent in input.selected) { var cmpOwnership = Engine.QueryInterface(ent, IID_Ownership); cmpOwnership.SetOwner(cmpPlayer.GetPlayerID()); } break;with case "convertunit": if (input.number >= cmpPlayerManager.GetNumPlayers()) return; var playerEnt = cmpPlayerManager.GetPlayerByID(input.number); if (playerEnt == INVALID_ENTITY) { var playerID = cmpPlayer.GetPlayerID(); } else { var playerID = input.number; } for each (var ent in input.selected) { var cmpOwnership = Engine.QueryInterface(ent, IID_Ownership); cmpOwnership.SetOwner(playerID); } break;so that you can also convert units to other players with the wololo cheat. Edited August 18, 2013 by idanwin Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted August 18, 2013 Report Share Posted August 18, 2013 Looks like a nice addition to me. Did you test if it works?As we go in feature freeze in 5 hours, it's probably not for immediately. But it's an ideal change to read the wiki section on submitting patches, and submit this one for A15.http://trac.wildfiregames.com/wiki/SubmittingPatches Quote Link to comment Share on other sites More sharing options...
feneur Posted August 18, 2013 Report Share Posted August 18, 2013 As I don't read code fluently =) I need to ask, if you just enter the code by itself, does it still convert to the player? (I'm assuming you convert to other players by entering "wololo 2", "wololo 3" etc?) Quote Link to comment Share on other sites More sharing options...
idanwin Posted August 18, 2013 Author Report Share Posted August 18, 2013 "wololo" converts to player"wololo x", where x is an invalid player id, converts to player"wololo x", where x is a valid player id, converts to player xtested :-) Quote Link to comment Share on other sites More sharing options...
leper Posted August 18, 2013 Report Share Posted August 18, 2013 If that feature is wanted/useful (I've got no real opinion on that one) we could add it, but the code you posted is ugly. I'm quite sure you can do the same without duplicating the loop. Quote Link to comment Share on other sites More sharing options...
feneur Posted August 18, 2013 Report Share Posted August 18, 2013 It sounds like something that could be useful for testing things. Quote Link to comment Share on other sites More sharing options...
idanwin Posted August 18, 2013 Author Report Share Posted August 18, 2013 I'm quite sure you can do the same without duplicating the loop.I'm not a programmer (explains it all :-) ) Removed the double loop.cheat.patch 2 Quote Link to comment Share on other sites More sharing options...
leper Posted August 18, 2013 Report Share Posted August 18, 2013 With the if-else replaced by a ternary operator it'll look fine. Nice work 1 Quote Link to comment Share on other sites More sharing options...
Nolanjoker Posted August 18, 2013 Report Share Posted August 18, 2013 wololo command is possibly to do a kind of convertion if is used with button instead a input? 1 Quote Link to comment Share on other sites More sharing options...
idanwin Posted August 18, 2013 Author Report Share Posted August 18, 2013 (edited) It might also be a good idea to add a defaultnumber to the data/cheats/convertUnit.json filewololo command is possibly to do a kind of convertion if is used with button instead a input?Working on it :-p not sure how someone like me could be able to pull it off, but I'll give it try. Edited August 18, 2013 by idanwin 1 Quote Link to comment Share on other sites More sharing options...
leper Posted August 18, 2013 Report Share Posted August 18, 2013 It might also be a good idea to add a defaultnumber to the data/cheats/convertUnit.json fileUse -1, since that is guranteed to be no valid player. Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted August 18, 2013 Report Share Posted August 18, 2013 I can do it a icon as Mouse pointer and buttons. I know you can do it skilled man. But I want do it. We talk to included this in Aristeia and may be in later stage of the 0 AD. Quote Link to comment Share on other sites More sharing options...
idanwin Posted August 19, 2013 Author Report Share Posted August 19, 2013 (edited) I'd forgotten how much fun it is to have priests converting units :-p (yep, just implemented it! The AI is not using it though :-( )This is how I did it:I added a new attack type called convert that does no damage and changes the unit ownership (all in Attack.js), when a unit has the attack type 'convert' this unit will be able to use a convert attack on enemy units. I got no clue how to give the user a button to control this though ...EDIT:The enemy is not using it because healers are passive, aggressive units with the attack will be used by the AI without problem.EDIT2:If you want to test it or fiddle with it:http://www.mediafire.com/download/7tfb3d4bdg6fze4/bronze_(0.1.1_-_converting_healers).7z Edited August 19, 2013 by idanwin 1 Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted August 19, 2013 Report Share Posted August 19, 2013 Is possibly use a math to each event of convertion can be hard for every time the player try to do it. Example first time 70% successful nextime 69.5%. For each priest of course. Quote Link to comment Share on other sites More sharing options...
idanwin Posted August 19, 2013 Author Report Share Posted August 19, 2013 What would a 'fail' be? Why not just a timer? Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted August 19, 2013 Report Share Posted August 19, 2013 Hmm... Some times like do a tech to unlock abilities or attacks haha, one thing I can evade is the argument about priest rush. And no all civilization were religious fanatic or they give some importance for live after dead. This why the math formula. The timer I like but in age of empires I the Assyrian do a foursome priest rush, that are in our minds in present days XD. Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted August 19, 2013 Report Share Posted August 19, 2013 on the Trac ticket about converrsion and capturing, I also included a patch for timer based conversion. But it's no good yet. Btw, you really want to work with Trac, as forum posts get lost in the stream. And Trac is clever enough to show all changes on top of the current code, so we see immediately what you do. 1 Quote Link to comment Share on other sites More sharing options...
Lion.Kanzen Posted August 19, 2013 Report Share Posted August 19, 2013 We discuss this in this topic from general ideas.http://www.wildfiregames.com/forum/index.php?showtopic=16544&view=findpost&p=250890&hl=conversion&fromsearch=1 Quote Link to comment Share on other sites More sharing options...
leper Posted August 19, 2013 Report Share Posted August 19, 2013 Some comments on the archive:You shouldn't need to supply Cheats.js (or cheats.json) as the Cheats.js in svn should pick up the json files in cheats/.You have the modified Heal.js in there (which is just Convert.js before renaming).Convert.js isn't actually used as you hacked that onto Attack.js (which is ugly IMO, but if you just want the AI to use the feature it is probably the easiest way) (The proper way would be to add a new component (similar to the Convert.js you added) add a new command to Commands.js (and call that from the gui) and add some new state to UnitAI) Quote Link to comment Share on other sites More sharing options...
idanwin Posted August 19, 2013 Author Report Share Posted August 19, 2013 Some comments on the archive:You shouldn't need to supply Cheats.js (or cheats.json) as the Cheats.js in svn should pick up the json files in cheats/.You have the modified Heal.js in there (which is just Convert.js before renaming).Convert.js isn't actually used as you hacked that onto Attack.js (which is ugly IMO, but if you just want the AI to use the feature it is probably the easiest way) (The proper way would be to add a new component (similar to the Convert.js you added) add a new command to Commands.js (and call that from the gui) and add some new state to UnitAI)Thank you, I hadn't noticed the cheats.json had been split up in the meantime.I didn't know what file I had to edit for Convert.js to work (apparently Commands.js, thx) so I replaced Heal to test it and forgot to remove it afterwards...on the Trac ticket about converrsion and capturing, I also included a patch for timer based conversion. But it's no good yet. Btw, you really want to work with Trac, as forum posts get lost in the stream. And Trac is clever enough to show all changes on top of the current code, so we see immediately what you do.I'll try to understand how to work with it Quote Link to comment Share on other sites More sharing options...
idanwin Posted August 19, 2013 Author Report Share Posted August 19, 2013 @Ieper: how should I call that from the GUI? I added a new convert.js and made all the necessary changes to UnitAI and Commands (I think I did at least) but I don't know how to make sure that when rightclicking an enemy unit the healer converts it. Quote Link to comment Share on other sites More sharing options...
leper Posted August 19, 2013 Report Share Posted August 19, 2013 That is handled in gui/session/input.js. The relevant places are line 333 (checking if the action (convert in this case) is possible (done when hovering the unit)), line 532 (calling the first and what priority the action should have (eg if a unit can both heal and attack what should be done (bad example, but you should get the point))) and line 1350 (sending the command to the simulation (different script contexts, so you need some way to pass the data between those (with PostNetworkCommand being GUI->simulation and GuiInterfaceCalls mostly being simulation->GUI (as in GuiInterfaceCalls shouldn't change the simulation state (the sychronized state that is), setting the display of rallypoints would be an example)); this will result in calling ProcessCommand() in Commands.js which will then handle it on the simulation side). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.