Posté le: 22/01/10 12:04 Sujet du message: Optimisation: Help Center
Permet de diffuser une liste de mot clef quand un joueur rentre "-help".
Ensuite, il n'a plus qu'à faire -help (lemotclef) pour avoir des informations sur ce mot clef.
Secret:
Jass:
library HelpCenter initializer init
globals
private constant real DUR = 30. //the text will be displayed during DUR seconds
private constant string COM = "-help" //string entered to run the trigger
private constant string LINE = "|c00AFAAFF"+"=============================================================="+"|r"//To separate text
private constant string NAME = "|c00AFAAFF"+"Help Center"+"|r" //Title displayed each time the trigger starts
private constant string INFO = "Enter -help XXXX where XXXX is one of the following key words:" //Text displayed then
string array HelpName [30] //The real title of each keyword, there, 30 keywords maximum
string array HelpText [30][15] //The content of each keywords: up to 15 sentences wroten
constant integer HelpTextMax = 15//Maximum amount of sentence displayed
integer HelpMax = 0
private StringTable Str_table
private integer HelpCommand_length
endglobals
//! textmacro t__HelpSystem_Init takes TEXT_ID, TITLE1 ,TITLE2
set Str_table["$TEXT_ID$"] = $TEXT_ID$
set Str_table["$TITLE1$"] = $TEXT_ID$
set Str_table["$TITLE2$"] = $TEXT_ID$
//! endtextmacro
private function SetTextVariables takes nothing returns nothing
local integer i = 1
//Respect the order of letters is better.
set HelpName[i]= "Alien"
set HelpText[i][0]="Can not colonize planet or build structures."
set HelpText[i][1]="Can not collect resources."
set HelpText[i][2]="Do not have income."
set HelpText[i][3]="Can only build light shuttle."
set HelpText[i][4]="Can improve units by making them assemblate."
set HelpText[i][5]="Really different units than other ways."
set HelpText[i][6]= "Aliens earn XP by assimilating planets."
//! runtextmacro t__HelpSystem_Init("i","alien","aliens")
set i = i + 1
//
set HelpName[i]= "Assimilate"
set HelpText[i][0]= "Assimilate is available for Aliens only."
set HelpText[i][1]= "To assimilate a planet, which will grants you Resources (Iron and Pulsars), you need to send an Alien Mothership or Omega Cruiser to the planet target."
set HelpText[i][2]= "Then you have to use the skill of the Mothership or the Omega Cruiser called Assimilate by targeting the planet with this skill."
set HelpText[i][3]= "This skill works on all planets."
set HelpText[i][4]= "If Assimilate is a success, you will get more Resources and you will be receive more Alpha Light Shuttles."
set HelpText[i][5]= "Assimilation grants XP"
//! runtextmacro t__HelpSystem_Init("i","assimilate","assimilise")
set i = i + 1
//
set HelpName[i]= "Asteroid"
set HelpText[i][0]= "Asteroids are a way to collect Iron (check -help Iron)"
set HelpText[i][1]= "Asteroids can be used as resource with Cargo Shuttles (buildable in Station or Shipyard Mark I)."
set HelpText[i][2]= "You just need to select a Cargo Shuttle and to right click the Asteroid."
set HelpText[i][3]= "The Cargo Shuttle will then return the Iron to the nearest Planet, Pirate Base (Pirate only) or Warehouse."
set HelpText[i][4]= "Terrorist can not use Asteroid as resource."
//! runtextmacro t__HelpSystem_Init("i","asteroid","asteroids")
set i = i + 1
//
set HelpName[i]= "Colonization"
set HelpText[i][0]= "Colonization is available for Merchants and Militaries only."
set HelpText[i][1]= "To colonize a planet, which will grants you Slots (food), you need to send a Builder Shuttle to the neutral planet target."
set HelpText[i][2]= "Then you have to use the skill of the Builder Shuttle called Colonize by targeting the planet with this skill."
set HelpText[i][3]= "This skill works only on neutral planets."
set HelpText[i][4]= "This skill is available with the research called Improved Colonization."
set HelpText[i][5]= "Higher levels of the research Improved Colonization reduces the time of the colonization."
set HelpText[i][6]= "The research Improved Colonization is available in a Research Facility - Production Center."
set HelpText[i][7]= "If the colonization is a success, you will get more Slots (food) and you will be able to build more satellites."
set HelpText[i][8]= "The other way to get planets is the Invasion."
//! runtextmacro t__HelpSystem_Init("i","colonization","colonize")
set i = i + 1
//
set HelpName[i]= "Command"
set HelpText[i][0]= "-cam XXXX"
set HelpText[i][1]= "Set the camera height to XXXX. XXXX is a number between 200 and 4000."
set HelpText[i][2]= "-ally XXXX"
set HelpText[i][3]= "-unally XXXX"
set HelpText[i][4]= "Propose an alliance/declare the war to the player XXXX."
set HelpText[i][5]= "XXXX can be a Player exact name, its number, or its color."
set HelpText[i][6]= "List: 1-red, 2-blue, 3-teal,4-purple,5-yellow,6-orange,7-green,8-pink,9-grey"
set HelpText[i][7]= "-save"
set HelpText[i][8]= "Save your experience and gives you a load Code. You can only save 3 times during a game."
set HelpText[i][9]= "-load XXXX"
set HelpText[i][10]= "Load your experience games after games. You can load it to show your experience to other players."
set HelpText[i][11]= "The Rank gives you bonus (health, damage, speed of attack and movement."
//! runtextmacro t__HelpSystem_Init("i","command","commands")
set i = i + 1
//
set HelpName[i]= "Income"
set HelpText[i][0]= "Income or Periodic Income grants resources every minute."
set HelpText[i][1]= "Income is function of the amount of food (slots) and of the Improved Iron/Pulsars Collect Research."
set HelpText[i][2]= "Some planets add an Income Bonus."
set HelpText[i][3]= "Merchants have an Income Bonus."
set HelpText[i][4]= "Merchants provide an Income Bonus with to their Alliance with their Freeport."
//! runtextmacro t__HelpSystem_Init("i","income","income")
set i = i + 1
//
set HelpName[i]= "Invasion"
set HelpText[i][0]= "Invasion is for Merchants, Militaries and Pirates only."
set HelpText[i][1]= "Invasion is the way to capture an enemy planet (not neutral one)."
set HelpText[i][2]= "To invade a planet, you need to build an Invasion Frigate - Galaxy in a Shipyard Mark II."
set HelpText[i][3]= "Then you should load troops on this Invasion Frigate thanks to a Training Center (buildable on a planet)."
set HelpText[i][4]= "When your frigate is ready, to invade, you must you the skill Invade Planet by targeting an enemy planet."
set HelpText[i][5]= "The invasion will take some time."
set HelpText[i][6]= "At the end of this time, if your offensive force is better than the defensive force of the planet, you will own it."
set HelpText[i][7]= "Capturing an enemy planet will grant you the same things as in Colonization."
set HelpText[i][8]= "Invasion grants XP for Militaries"
//! runtextmacro t__HelpSystem_Init("i","invasion","invade")
set i = i + 1
//
set HelpName[i]= "Iron"
set HelpText[i][0]="Periodic Income grants Iron for each player. Merchants have an Income bonus."
set HelpText[i][1]="All ways except terrorists can send Cargo Shuttles to harvest on Asteroids to earn more Iron."
set HelpText[i][2]="Pirates earns Iron when they attack enemies and/or capture trading ships with Harasser Frigates or Marauder Cruisers."
set HelpText[i][3]="Terrorists earns Iron when they kill enemies."
set HelpText[i][4]="Trade between freeports (or planets for merchants) grants Iron."
set HelpText[i][5]="Improved Iron Collect grants higher income and a raised power of harvest for Cargo Shuttles."
set HelpText[i][6]="Some planets raise the Periodic Income of Iron with the Improved Iron Income ability."
//! runtextmacro t__HelpSystem_Init("i","iron","lumber")
set i = i + 1
//
set HelpName[i]= "Merchant"
set HelpText[i][0]="Merchant is a way to earn a lot of cash without fighting. This way is really useful in Alliance Enabled mode, because Merchant will be able to feed its allies and develop the trade."
set HelpText[i][1]= "5% health points penalty for all units."
set HelpText[i][2]= "25% income bonus."
set HelpText[i][3]= "15% trade bonus."
set HelpText[i][4]= "Can trade with planets."
set HelpText[i][5]= "2 harvest points bonus at start for cargo shuttles."
set HelpText[i][6]= "Can choose Merchant or Polyvalent Mothership."
set HelpText[i][7]= "Special ships: Spy Cruiser: Secret Agent, Merchant Cruiser: Miserly"
set HelpText[i][8]= "Special building: Radar Tower: Guardian"
set HelpText[i][9]= "Special ability: Nanite saturation, Send Spy, Destructuration, Alliance Income Bonus"
set HelpText[i][10]= "Merchants earn XP by trading or leading researchs"
//! runtextmacro t__HelpSystem_Init("i","merchant","merchants")
set i = i + 1
//
set HelpName[i]= "Military"
set HelpText[i][0]= "Military is a long-development way, based on pure power of attack/defence and resistant ships."
set HelpText[i][1]= "10% health points bonus for all units"
set HelpText[i][2]= "Can choose Military or Polyvalent Mothership."
set HelpText[i][3]= "Special ship: Invasion Shuttle: Squareroot, Frigate: Starkiller Gunship, Invasion Cruiser: Universe"
set HelpText[i][4]= "Special Building: MicroMissiles Thrower: Typhoon"
set HelpText[i][5]= "Special ability: Derivation, MicroBlackHole, Telemetry, Self Guided Mine, Particle Shield"
set HelpText[i][6]= "Special Troop: Aircraft"
set HelpText[i][7]= "Merchants earn XP by invading planets or leading researchs"
//! runtextmacro t__HelpSystem_Init("i","military","militaries")
set i = i + 1
//
set HelpName[i]= "Mine"
set HelpText[i][0]= "Pulsars Mines are a way to collect Pulsars (check -help Pulsar)"
set HelpText[i][1]= "Pulsars Mines can be used as resource with Cargo Shuttles (buildable in Station or Shipyard Mark I)."
set HelpText[i][2]= "You just need to select a Cargo Shuttle and to right click the Pulsar Mine."
set HelpText[i][3]= "The Cargo Shuttle will then return the Pulsar to the nearest Planet, Pirate Base (Pirate only) or Warehouse."
set HelpText[i][4]= "Terrorist can not use Pulsar Mine as resource."
//! runtextmacro t__HelpSystem_Init("i","mine","mines")
set i = i + 1
//
set HelpName[i]= "Motherhip"
set HelpText[i][0]= "Motherships are upgradable and modulable ships made of a Main Body. It can be upgrade from Shuttle to Frigate and from Frigate to Cruiser"
set HelpText[i][1]= "Motherhips modules are buildable from a Dock."
set HelpText[i][2]= "If the module of the Mothership die, this will not prevent the Main Body to work."
set HelpText[i][3]= "MotherShips can be revived in the Docks"
set HelpText[i][4]= "MotherShips can be upgrade in the Docks"
//! runtextmacro t__HelpSystem_Init("i","motherhip","motherships")
set i = i + 1
//
set HelpName[i]= "Planet"
set HelpText[i][0]= "Planets are objects able to create buildings, raise your Slots (food), raise your periodic Income."
set HelpText[i][1]= "Planets can be used like Warehouse to receive the resources of the nearby Cargo Shuttles collecting resources."
set HelpText[i][2]= "Planets can be colonized if they are neutral (check -help Colonization) or invaded if they are enemy (check -help Invasion)."
set HelpText[i][3]= "Planets can be destroyed by Plasma Weapon equiped ships, like Assaut Shuttles, Assaut Frigate or Assaut Cruisers."
set HelpText[i][4]= "Planets can be assimilated by Alien with the skill Assimilation (Omega Cruiser or Alien Mothership), granting resources and Alpha Light Shuttles"
set HelpText[i][5]= "Planets are a way to increase the amount of Slots (food) you have. (check -help Slot)."
set HelpText[i][6]= "Planets grants XP to Militaries when they are invaded or to Alien when they are assimilated"
//! runtextmacro t__HelpSystem_Init("i","planet","planets")
set i = i + 1
//
set HelpName[i]= "Pirate"
set HelpText[i][0]= "Pirate is a fast-way development, to play the role of a harasser. They can be independent but will suffer problems if they only fight militaries."
set HelpText[i][1]= "20% speed of movement bonus for all units."
set HelpText[i][2]= "Resources earned by attacking other players"
set HelpText[i][3]= "Can not colonize more than one planet"
set HelpText[i][4]= "Can choose Pirate or Polyvalent Mothership"
set HelpText[i][5]= "Special ship: Frigate: Pirate Harasser, Cruiser: Pirate Marauder"
set HelpText[i][6]= "Special Building: Pirate Base"
set HelpText[i][7]= "Special ability: Afterburn, Set Up a Ionic Mine, Steal"
set HelpText[i][8]= "Pirates earn XP by attacking Cargo Shuttles, Merchant Cruisers or Merchant Motherships"
//! runtextmacro t__HelpSystem_Init("i","pirate","pirates")
set i = i + 1
//
set HelpName[i]= "Pulsar"
set HelpText[i][0]="Periodic Income grants Pulsars for each player. Merchants have an Income bonus."
set HelpText[i][1]="All ways except terrorists can send Cargo Shuttles to harves on Pulsar mines to earn more Pulsars."
set HelpText[i][2]="Pirates earn Pulsars when they attack enemies and/or capture trading ships with Harasser Frigates or Marauder Cruisers."
set HelpText[i][3]="Terrorists earn Pulsars when they kill enemies."
set HelpText[i][4]="Trade between freeports (or planets for merchants) grants Pulsars."
set HelpText[i][5]="Improved Pulsars Collect grants higher income and a raised power of harvest for Cargo Shuttles."
set HelpText[i][6]="Some planets raise the Periodic Income of Pulsars with the Improved Pulsars Income ability."
//! runtextmacro t__HelpSystem_Init("i","pulsar","gold")
set i = i + 1
//
set HelpName[i]= "Rank"
set HelpText[i][0]="Rank is a title given to a player in function of its global experience."
set HelpText[i][1]="They are up to 50 ranks to earn."
set HelpText[i][2]="Each earned rank provides a bonus of health, damage, speed of movement and attack rate to all ships. "
set HelpText[i][3]= "Rank is raised each time the experience goes higher than the required steps."
set HelpText[i][4]= "Each ways earn experience points through different means."
//! runtextmacro t__HelpSystem_Init("i","rank","grade")
set i = i + 1
//
set HelpName[i]= "Slot"
set HelpText[i][0]= "Food is called Slot in Stars. It determinates the amount of ships a Clan can build"
set HelpText[i][1]= "Colonize or invade planets raise the number of slots. Terrorist can't do this. Pirate can only colonize one planet."
set HelpText[i][2]= "Pirates can build Pirate Base to raise their Slots."
set HelpText[i][3]= "Motherships Modules MicroCity Mark I and II called Pool and Cavern can raise the amount of Slots for Merchants."
set HelpText[i][4]= "Maximum Slot amount is 150 for Merchants/Militaries/Pirates and 30 for Terrorists"
//! runtextmacro t__HelpSystem_Init("i","slot","food")
set i = i + 1
//
set HelpName[i]= "Terrorist"
set HelpText[i][0]= "Terrorist is a way centered on a unic base, the terrorist mothership. They are hard to play, and can not ally other players."
set HelpText[i][1]= "30 slots (food) maximum."
set HelpText[i][2]= "Resources earned by killing other player units and Periodic Income: no collect."
set HelpText[i][3]= "Can not colonize planet."
set HelpText[i][4]= "Only have one Terrorist Mothership as base/Mothership."
set HelpText[i][5]= "Special ship: Shuttle: Fury Cultist, Assault Shuttle: Infection, Frigate: Starkiller Gunship, Frigate: Bacillus, Frigate: Incubator, Cruiser: Aggressor"
set HelpText[i][6]= "Special research: Fear, Improved Biologic Weapons."
set HelpText[i][10]= "Terrorists earn XP by killing units"
//! runtextmacro t__HelpSystem_Init("i","terrorist","terrorists")
set i = i + 1
//
set HelpName[i]= "Trade"
set HelpText[i][0]= "Trade is a system for all ways excepted Terrorists to earn Iron and Pulsars."
set HelpText[i][1]= "To trade, you need to build a Freeport with a Builder Shuttle."
set HelpText[i][2]= "Then, you must select an allied Freeport with the Select a Buyer ability of a Cargo Shuttle."
set HelpText[i][3]= "The cargo will then fly to your freeport, load items called Products and fly to send them to the allied Freeport."
set HelpText[i][4]= "This is called a Trade road and can be stopped at any moment by using the Abort Trade ability of a cargo."
set HelpText[i][5]= "The amount of Pulsars and Iron is raised with the Distance between Freeports."
set HelpText[i][6]= "Merchants can use allied Planets instead of allied Freeport as a buyer; it is called Local Trade."
set HelpText[i][7]= "Merchants can replace Cargo Shuttles with Miserly Merchant Cruiser or Merchant Mothership."
set HelpText[i][8]= "Merchants can add MotherShip Cargo Module Mk I, II and III-called Blob,Giant and Titans- to their Motherships to raise the amount of resources earned."
set HelpText[i][9]= "Merchants have a bonus for each Trade Operation."
set HelpText[i][10]= "Merchants earn XP by trading"
//! runtextmacro t__HelpSystem_Init("i","trade","trades")
set i = i + 1
//
set HelpName[i]= "Victory"
set HelpText[i][0]= "The game is ended if you are able to destroy all of your enemies."
//! runtextmacro t__HelpSystem_Init("i","victory","win")
set i = i + 1
//
set HelpName[i]= "Way"
set HelpText[i][0]= "Ways provide specific bonus and gameplay for a player. They are like something like Race"
set HelpText[i][1]= "You choose them at the beginning of the game"
set HelpText[i][2]= "They are 5 ways: Aliens, Merchant, Military, Pirate, Terrorist"
set HelpText[i][3]= "Each way allows a player to earn experience points through different ways."
//! runtextmacro t__HelpSystem_Init("i","way","ways")
//
set HelpMax = i
endfunction
private function Conditions takes nothing returns boolean
local player whichPlayer = GetTriggerPlayer()
local string text = GetEventPlayerChatString()
local integer string_length = StringLength(text)
local integer index
local integer i = 0
if SubString(text,0,HelpCommand_length) == COM then
set text = SubString(text,HelpCommand_length+1,string_length)
if text != null then
set index = Str_table[text]
call DisplayTimedTextToPlayer(whichPlayer,0.,0.,DUR,LINE)
call DisplayTimedTextToPlayer(whichPlayer,0.,0.,DUR,"|c00AFAAFF"+HelpName[index]+"|r")
loop
exitwhen i > HelpTextMax
if HelpText[index][i]!= null then
call DisplayTimedTextToPlayer(whichPlayer,0.,0.,DUR,HelpText[index][i])
endif
set i = i + 1
endloop
else
set text = "Keywords: "
call DisplayTimedTextToPlayer(whichPlayer,0.,0.,DUR,LINE)
call DisplayTimedTextToPlayer(whichPlayer,0.,0.,DUR,NAME)
call DisplayTimedTextToPlayer(whichPlayer,0.,0.,DUR,INFO)
loop
exitwhen i > HelpMax
if HelpName[i]!= null then
set text = text+" - "+HelpName[i]
endif
endif
set text = null
set whichPlayer = null
return false
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
set Str_table = StringTable.create()
call SetTextVariables()
set HelpCommand_length = StringLength(COM)
set i = 0
loop
exitwhen i > MAXPLAYER
call TriggerRegisterPlayerChatEvent( t, Player(i), COM, false )
set i = i + 1
endloop
call TriggerAddCondition(t, Condition(function Conditions))
endfunction
endlibrary
_________________
Dernière édition par jk2pach le 06/04/10 21:37; édité 8 fois
//! runtextmacro t__HelpSystem_Init("Way", "way", "Ways", "ways", "Ways provide specific bonus and gameplay for a player. They are like something like Race","You choose them at the beginning of the game","They are 5 ways: Aliens, Merchant, Military, Pirate, Terrorist","Each way allows a player to earn experience points through different ways.")
Sous le JNPG c'est illisible (encore là j'ai pris un exemple court, mais les rubriques de 10 lignes c'est hardcore. _________________
Inscrit le: 23 Aoû 2007 Messages: 7143 Sujets: 147 Spécialité en worldedit: le troll, le flood, la vulgarité, mon coeur balance Médailles: 2 (En savoir plus...)
Posté le: 21/03/10 12:51 Sujet du message:
En Zinc oui, mais pas en vJass
Tu peux toujours laisser des espaces entre les virgules, ensuite, tu n'as qu'à coller le modèle et double cliquer pour changer le string.
PS : Je regarderais le code plus tard. _________________
Inscrit le: 23 Aoû 2007 Messages: 7143 Sujets: 147 Spécialité en worldedit: le troll, le flood, la vulgarité, mon coeur balance Médailles: 2 (En savoir plus...)
Posté le: 22/03/10 16:37 Sujet du message:
Apocalypse a écrit:
Exact.
Mais reste surtout le problème des champs de texte (le contenu de l'aide).
C'est tout bête hein mais pour relire sans retour automatique à la ligne c'est bof bof.
Les textmacros ne sont volontairement (d'après Vexorian) pas sexy à utiliser, car celui ci ne voulait pas que ca devienne une speek fread fashion.
Ca reste cool à utiliser pour leur fonction première : générer du code répétitif en ne changeant que ce qu'il y a besoin, limiter aussi par conséquent le risque d'erreurs en copiant/collant/éditant.
Après leur utilisation n'est pas une obligation.
En fait je ne crois pas qu'en Zinc on puisse faire des retours à la ligne tout en gardant la même ligne de code.
Je crois que je suis prêt à passer au cJass, au moins les développeurs semblent plus actifs et I <3 defines et comment on peut justement ainsi fragmenter une ligne de code en plusieurs.
Et enfin comment le (v)Jass peut être utilisé simultanément (dans les grandes lignes), contrairement au Zinc ou c'est toute la scope/library qui doit être en Zinc, en plus faut utiliser à chaque fois les tags "//! zinc" "//! endzinc" ...
Hmm, il faudrait que je me trouves une autre convention pour nommer mes variables global. _________________
Inscrit le: 23 Aoû 2007 Messages: 7143 Sujets: 147 Spécialité en worldedit: le troll, le flood, la vulgarité, mon coeur balance Médailles: 2 (En savoir plus...)
Posté le: 04/04/10 19:09 Sujet du message:
Laisse tomber ce que j'ai dit pour le cJass, le compilateur est complètement foireux, probablement parce qu'ils ont eu la prétention de le faire en assembleur (speed freak).
Dommage, je me serais exercé pour sc2. _________________
Inscrit le: 23 Aoû 2007 Messages: 7143 Sujets: 147 Spécialité en worldedit: le troll, le flood, la vulgarité, mon coeur balance Médailles: 2 (En savoir plus...)
Posté le: 05/04/10 14:22 Sujet du message:
Rien n'est vrai, tout est permis.
Fais le comme tu le sens c'est quand même uniquement à l'init de la map ...
Personnellement j'aurais utilisé des textmacro, mais c'est moi. _________________
Toutes les heures sont au format GMT + 1 Heure Aller à la page 1, 2Suivante
Page 1 sur 2 La question posée dans ce topic a été résolue !
Vous ne pouvez pas poster de nouveaux sujets dans ce forum Vous ne pouvez pas répondre aux sujets dans ce forum Vous ne pouvez pas éditer vos messages dans ce forum Vous ne pouvez pas supprimer vos messages dans ce forum Vous ne pouvez pas voter dans les sondages de ce forum