![]() |
|
|
#1 | |||
|
Архивный участник
Join Date: Oct 2005
Posts: 18
|
(To keep the information in one place I will just continously update this first post - In order for you to know if a significant update took place i will simply make a notifying post in this topic describing the new things that I have added).
Overview ai.obj is used by a stack machine a stack machine is a combination of a specific data structure, a stack and a language that operates on the stack. The Stack Stacks are data structures which maintain the order of last-in, first-out. A good analogy is that of a stack of plates. The first plate you put in the stack is the last one that you get out. If in place of plates we have data objects let's say that we put objects A B C D in the stack in that order then the stack would look after each addition like thus: [php:1:3a88cfacc0] D C C B B B A A A A [/php:1:3a88cfacc0] You can access data objects only from the top of the stack. If you want to access element C then you will have to change where the top of the stack is. You can do that because a stack data structure is combined with an index THE STACK POINTER, which points to the top of the stack + 1. If the stack has no elements then the STACK POINTER is 0. If you add one element is 1 in our example where all 4 elements have been introduced the STACK POINTER has the value 5. So closing this description you have to remember 2 things for a stack data structure, the last-in first out and the stack pointer index. The Language To be able to understand the examples below, i will introduce now the shift_sp command. shift_sp <integer> : moves the stack pointer so many places as described by the integer (it's a signed integer can be positive in that case we are growing the stack, or negative shrinking the stack) The commands of a stack machine affect the top of the stack. They take their values from the stack and they return a value on the stack. If the command needs one value then it removes this value from the stack and returns the result in its place. The top of the stack has remained the same since one value was removed and one value was added. If it needs 2 values then it takes 2 values from the stack and returns the result in its place. The value of the stack pointer is minus one what it was because the command took 2 values and returned one. Every command on the stack affects the stack and the stack pointer. The only exception is the call_func command. The call_func command doesn't affect the stack pointer. It only reads the arguments that needs and returns a value. Specifically it returns a value on the stack position that exists before all its arguments. That is the reason that we see in ai.obj before any func_call code like this: Quote:
the shift_sp -2 after the func_call is to go back 2 stack positions - remember the func call doesn't remove elements from the stack there are still there finally the shift_sp -1 is used to go to the place we reserved with the shift_sp 1 command at the beggining Quote:
push_const <int> : push the value on the stack, increase the stack pointer by one. fetch_i : pop a value from the stack, assume that is an index on the stack data structure (see it like an address), push the value (an integer) that is contained in this address on the stack. Mnemonic Fetch Integer. The stack pointer remains the same since we got one value and returned one value. fetch_d : like fetch_i but it brings back a double. Mnemonic Fetch Double push_reg_sp : it pushes the stack pointer on the stack. Since we didn't use any element from the stack and we returned one the stack pointer increased by one. Why you should do this? For one thing by giving the following code: push_reg_sp fetch_i you make a copy of the value that is on top of the stack. Quite simple and you can see it in many places in ai.obj other commands like mul (multiplication), div(division) etc are self-explanatory. Some (very fast) notes on events: Events are nothing more than structures that contain specific information, in specific places. For example: Quote:
Reserved Words - Statements Code:
(52 reserved words so far) add assign and bit_and bit_or branch_false branch_true buyselllist_begin buyselllist_end call_super class class_end div equal exit_handler fetch_d fetch_i float func_call greater greater_equal handler handler_end int jump less less_equal mod mul negate not not_equal or parameter_define_begin parameter_define_end property_define_begin property_define_end push_parameter push_event push_property push_string push_reg_sp push_const shift_sp string sub telposlist_begin telposlist_end variable_begin variable_end waypointstype waypointdelaystype Handler Reference Code:
(37 handlers so far) 0 NO_DESIRE 1 ATTACKED 2 SPELLED 3 TALKED 4 TALK_SELECTED 5 SEE_CREATURE 10 MY_DYING 11 TIMER_FIRED 12 TIMER_FIRED_EX 13 CREATED 16 SEE_SPELL 17 OUT_OF_TERRITORY 18 DESIRE_MANIPULATION 19 PARTY_ATTACKED 21 PARTY_DIED 23 CLAN_ATTACKED 25 STATIC_OBJECT_CLAN_ATTACKED 28 TELEPORT_REQUESTED 31 QUEST_ACCEPTED 32 MENU_SELECTED 33 LEARN_SKILL_REQUESTED 34 ONE_SKILL_SELECTED 36 CLASS_CHANGE_REQUESTED 42 CREATE_PLEDGE 43 DISMISS_PLEDGE 44 REVIVE_PLEDGE 45 LEVEL_UP_PLEDGE 48 CREATE_ALLIANCE 49 SCRIPT_EVENT 50 TUTORIAL_EVENT 51 QUESTION_MARK_CLICKED 52 USER_CONNECTED 61 MOVE_TO_WAY_POINT_FINISHED 62 USE_SKILL_FINISHED 63 MOVE_TO_FINISHED 75 DOOR_HP_LEVEL_INFORMED 76 CONTROLTOWER_LEVEL_INFORMED Code:
To be populated... Code:
Here is a list of all the function calls for reference, the arguments for each function is given in descriptive form, rv stands for the return value of the function (the argument list isn't yet complete or standardised). Remember that the rv (return value) is the lowest element on the stack.
(130 functions so far)
func_call 0 // func[AddMoveAroundDesire] (rv,int,int)
func_call 1 // func[AddDoNothingDesire] (rv,int,int)
func_call 2 // func[AddAttackDesire] (rv,attacker,int,int)
func_call 3 // func[AddAttackDesireEx]
func_call 6 // func[AddFleeDesire]
func_call 7 // func[AddFollowDesire]
func_call 9 // func[AddMoveToWayPointDesire] (rv, WayPoints, WayPointDelays, int, int)
func_call 10 // func[AddUseSkillDesire] (rv,event[myself][sm],1056001,1,1,4000000)
func_call 11 // func[AddUseSkillDesireEx]
func_call 12 // func[AddMoveToDesire] (rv,x,y,z,100000)
func_call 13 // func[AddEffectActionDesire]
func_call 14 // func[AddPetDefaultDesire_Follow]
func_call 15 // func[RemoveAllAttackDesire] (rv)
func_call 18 // func[MakeAttackEvent]
func_call 20 // func[GetLifeTime]
func_call 21 // func[GetTick] (rv)
func_call 23 // func[GetCurrentTick] (rv)
func_call 24 // func[GetDirection] (rv, event[c2])
func_call 25 // func[SetCookie]
func_call 26 // func[GetCookie]
func_call 27 // func[SetTeleportPosOnLost]
func_call 28 // func[AddTimerEx] (rv,1002,60000)
func_call 29 // func[GetIndexFromCreature] (rv, event[myself][sm])
func_call 30 // func[GetCreatureFromIndex]
func_call 31 // func[RegisterGlobalMap] (rv, rv from GetIndexFromCreature, push_parameter GM_ID)
func_call 32 // func[UnregisterGlobalMap]
func_call 33 // func[GetGlobalMap]
func_call 34 // func[SendScriptEvent]
func_call 36 // func[IsSpoiled]
func_call 37 // func[Say]
func_call 42 // func[Shout]
func_call 43 // func[ShowPage] (rv,event[talker],string(html_filename))
func_call 45 // func[Teleport]
func_call 46 // func[InstantTeleport] (rv, event[myself][sm],int(x),int(y),int(z))
func_call 47 // func[Sell]
func_call 48 // func[Buy]
func_call 51 // func[DistFromMe] (rv, event[myself][c_ai2])
func_call 52 // func[SetTimerPeriodByTick] (rv,int(0))
func_call 53 // func[SetTimerPeriod]
func_call 54 // func[GetWayPointDelay] (rv,WayPointDelays, event[way_point_index])
func_call 55 // func[Rand] (rv, int(max))
func_call 57 // func[FloatToInt] (rv)
func_call 58 // func[GetMemoCount]
func_call 59 // func[HaveMemo] (rv, event[talker], int(quest_id?))
func_call 60 // func[SetMemo]
func_call 61 // func[SetMemoState] (rv, event[talker], 212, 10)
func_call 62 // func[GetMemoState] (rv, event[talker], 212)
func_call 63 // func[RemoveMemo]
func_call 64 // func[SetJournal]
func_call 65 // func[GetOneTimeQuestFlag] (rv, event[talker], 255)
func_call 66 // func[SetOneTimeQuestFlag]
func_call 67 // func[GetAbnormalLevel] ** not full **
func_call 68 // func[SetDBValue] (rv, event[myself][sm],0)
func_call 74 // func[Pledge_GetLeader]
func_call 76 // func[GetPledge]
func_call 77 // func[GiveItem1] (rv, event[talker],int(item_code),int(quantity))
func_call 80 // func[DeleteItem1] (rv,event[talker],int(item_code),int(quantity))
func_call 81 // func[OwnItemCount] (rv, event[talker],int(item_code))
func_call 83 // func[GetLastAttacker] (rv)???????
func_call 84 // func[FHTML_SetFileName]
func_call 85 // func[FHTML_SetInt]
func_call 86 // func[FHTML_SetFloat]
func_call 87 // func[FHTML_SetStr]
func_call 88 // func[ShowFHTML]
func_call 89 // func[MakeFString]
func_call 100 // func[IsMyLord]
func_call 103 // func[Castle_GetSiegeTime]
func_call 104 // func[Residence_GetTaxRate]
func_call 105 // func[Residence_GetTaxRateCurrent]
func_call 106 // func[Residence_SetTaxRate]
func_call 111 // func[Residence_VaultTakeOutMoney]
func_call 114 // func[Castle_GateOpenClose]
func_call 115 // func[Castle_GetPledgeState]
func_call 116 // func[Castle_IsUnderSiege]
func_call 117 // func[Castle_GetHPRegen]
func_call 118 // func[Castle_GetMPRegen]
func_call 119 // func[Castle_BanishOthers]
func_call 120 // func[Castle_SetHPRegen]
func_call 121 // func[Castle_SetMPRegen]
func_call 122 // func[Castle_GetRawSiegeTime]
func_call 123 // func[Castle_GetRawSystemTime]
func_call 125 // func[Castle_GateOpenClose2]
func_call 126 // func[Castle_GetPledgeId]
func_call 127 // func[Castle_GetLifeControlLevel]
func_call 128 // func[Agit_SetMaster]
func_call 129 // func[Agit_GetTeleportLevel]
func_call 130 // func[Agit_SetTeleportLevel]
func_call 131 // func[AddChoice] (rv, int(0),string)
func_call 132 // func[ShowChoicePage] (rv, event[talker], 1)
func_call 133 // func[ShowSkillList]
func_call 134 // func[ShowGrowSkillMessage]
func_call 143 // func[IsInCategory] (rv, int, event[talker][occupation])
func_call 144 // func[ClassChange] (rv, event[talker],lv2_class11(-1))
func_call 145 // func[Castle_GetCropRate]
func_call 146 // func[Castle_GetCropPrice]
func_call 148 // func[Residence_GetTaxIncome]
func_call 152 // func[Castle_PostCropPurchase]
func_call 154 // func[Skill_GetConsumeHP] (rv, 1044481)
func_call 155 // func[Skill_GetConsumeMP] (rv, 1044481)
func_call 156 // func[Skill_GetEffectPoint]
func_call 157 // func[Skill_GetAttribute]
func_call 158 // func[Skill_GetAbnormalType] *** not full ***(rv, 1056004(skill_id))
func_call 160 // func[Skill_InReuseDelay] (rv, 1044481)
func_call 165 // func[CreatePrivates]
func_call 166 // func[CreateOnePrivate] (rv, 1005180, string("imperial_slave"),0,1)
func_call 168 // func[Maker_GetNpcCount]
func_call 169 // func[Maker_FindNpcByKey]
func_call 170 // func[CreateOnePrivateEx] (rv, 1005121, "actea_of_verdant_wilds",int(event[myself][sm][x]),int(event[myself][sm][y]),int(event[myself][sm][z]),0,0,0) ???????
func_call 171 // func[IncrementParam] (rv, event[talker], int, int)
func_call 173 // func[SoundEffect] (rv,talker[event],string(sound_resource))
func_call 174 // func[EffectMusic] (rv, myself[sm],10000,string(music))
func_call 175 // func[Despawn]
func_call 177 // func[InMyTerritory]
func_call 178 // func[InstantTeleportInMyTerritory] (rv, pos_x1,pos_y1,pos_z1,200)
func_call 180 // func[EarthQuakeByNPC] (rv, myself[sm],20,10,1,0,0,0)
func_call 181 // func[SpecialCamera] (rv, event[myself][sm],700,13,-19,0,10000,20000)
func_call 184 // func[PledgeLevelUp] (rv, event[talker], int)
func_call 188 // func[ShowTutorialHTML] (rv, event[talker], string(htmlFname))
func_call 189 // func[ShowTutorialHTML2]
func_call 190 // func[ShowQuestionMark] (rv, event[talker], 1)
func_call 192 // func[CloseTutorialHTML]
func_call 193 // func[EnableTutorialEvent] (rv, event[talker], event[i0] bit_or 4194304)
func_call 194 // func[ShowRadar] (rv, event[talker],x,y,z)
func_call 195 // func[DeleteRadar]
func_call 196 // func[CreatePet]
func_call 200 // func[OpenSiegeInfo]
func_call 201 // func[SetDoorHpLevel]
func_call 202 // func[GetDoorHpLevel]
func_call 203 // func[SetControlTowerLevel]
func_call 204 // func[GetControlTowerLevel]
Code:
Just an example of the available resources for now... Music: "antaras" Sounds: "ItemSound.quest_fanfare_1" "ItemSound.quest_tutorial" "ItemSound.quest_middle" "ItemSound.quest_itemget" "Itemsound.quest_before_battle" |
|||
|
|
|
|