Skip to content

Commit

Permalink
[10365] Implement ACTION_T_MOUNT_TO_ENTRY_OR_MODEL (43) for creature …
Browse files Browse the repository at this point in the history
…eventAI.

Read doc/EventAI.txt for details.
SQL query to update existing scripts are included (convert from using ACTION_T_SET_UNIT_FIELD, field 68)

Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed Aug 17, 2010
1 parent 40e47fb commit cdf5b03
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/EventAI.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ For all ACTION_T_RANDOM, When a Particular Param is selected for the Event... Th
40 ACTION_T_SET_SHEATH Sheath Sets sheath state for a creature (0 = no weapon, 1 = melee weapon, 2 = ranged weapon).
41 ACTION_T_FORCE_DESPAWN Delay Despawns the creature, if delay = 0 immediate otherwise will despawn after delay time set in Param1 (in ms).
42 ACTION_T_SET_INVINCIBILITY_HP_LEVEL HP_Level, HP_Percent Set min. health level for creature that can be set at damage as flat value or percent from max health
43 ACTION_T_MOUNT_TO_ENTRY_OR_MODEL CreatureEntry, ModelId Set mount model from creature_template.entry (Param1) OR explicit modelId (Param2). If (Param1) AND (Param2) are both 0, unmount.

* = Use -1 where the param is expected to do nothing. Random constant is generated for each event, so if you have a random yell and a random sound, they will be linked up with each other (ie. param2 with param2).

Expand Down
2 changes: 1 addition & 1 deletion sql/mangos.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CREATE TABLE `db_version` (
`version` varchar(120) default NULL,
`creature_ai_version` varchar(120) default NULL,
`cache_id` int(10) default '0',
`required_10362_01_mangos_creature_movement_template` bit(1) default NULL
`required_10365_01_mangos_creature_ai_scripts` bit(1) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';

--
Expand Down
5 changes: 5 additions & 0 deletions sql/updates/10365_01_mangos_creature_ai_scripts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE db_version CHANGE COLUMN required_10362_01_mangos_creature_movement_template required_10365_01_mangos_creature_ai_scripts bit;

UPDATE creature_ai_scripts SET action1_type=43, action1_param1=0 WHERE action1_type=17 AND action1_param1=68;
UPDATE creature_ai_scripts SET action2_type=43, action2_param1=0 WHERE action2_type=17 AND action2_param1=68;
UPDATE creature_ai_scripts SET action3_type=43, action3_param1=0 WHERE action3_type=17 AND action3_param1=68;
2 changes: 2 additions & 0 deletions sql/updates/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pkgdata_DATA = \
10353_01_mangos_mangos_string.sql \
10353_02_mangos_command.sql \
10362_01_mangos_creature_movement_template.sql \
10365_01_mangos_creature_ai_scripts.sql \
README

## Additional files to include when running 'make dist'
Expand Down Expand Up @@ -142,4 +143,5 @@ EXTRA_DIST = \
10353_01_mangos_mangos_string.sql \
10353_02_mangos_command.sql \
10362_01_mangos_creature_movement_template.sql \
10365_01_mangos_creature_ai_scripts.sql \
README
22 changes: 22 additions & 0 deletions src/game/CreatureEventAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,28 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32
m_InvinceabilityHpLevel = action.invincibility_hp_level.hp_level;
break;
}
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL:
{
if (action.mount.creatureId || action.mount.modelId)
{
// set model based on entry from creature_template
if (action.mount.creatureId)
{
if (CreatureInfo const* cInfo = GetCreatureTemplateStore(action.mount.creatureId))
{
uint32 display_id = Creature::ChooseDisplayId(0, cInfo);
m_creature->Mount(display_id);
}
}
//if no param1, then use value from param2 (modelId)
else
m_creature->Mount(action.mount.modelId);
}
else
m_creature->Unmount();

break;
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/game/CreatureEventAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ enum EventAI_ActionType
ACTION_T_SET_SHEATH = 40, // Sheath (0-passive,1-melee,2-ranged)
ACTION_T_FORCE_DESPAWN = 41, // No Params
ACTION_T_SET_INVINCIBILITY_HP_LEVEL = 42, // MinHpValue, format(0-flat,1-percent from max health)
ACTION_T_MOUNT_TO_ENTRY_OR_MODEL = 43, // Creature_template entry(param1) OR ModelId (param2) (or 0 for both to unmount)
ACTION_T_END,
};

Expand Down Expand Up @@ -377,6 +378,12 @@ struct CreatureEventAI_Action
uint32 hp_level;
uint32 is_percent;
} invincibility_hp_level;
// ACTION_T_MOUNT_TO_ENTRY_OR_MODEL = 43
struct
{
uint32 creatureId; // set one from fields (or 0 for both to dismount)
uint32 modelId;
} mount;
// RAW
struct
{
Expand Down
24 changes: 24 additions & 0 deletions src/game/CreatureEventAIMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,30 @@ void CreatureEventAIMgr::LoadCreatureEventAI_Scripts()
}
}
break;
case ACTION_T_MOUNT_TO_ENTRY_OR_MODEL:
if (action.mount.creatureId != 0 || action.mount.modelId != 0)
{
if (action.mount.creatureId && !sCreatureStorage.LookupEntry<CreatureInfo>(action.mount.creatureId))
{
sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent Creature entry %u.", i, j+1, action.mount.creatureId);
action.morph.creatureId = 0;
}

if (action.mount.modelId)
{
if (action.mount.creatureId)
{
sLog.outErrorDb("CreatureEventAI: Event %u Action %u have unused ModelId %u with also set creature id %u.", i, j+1, action.mount.modelId, action.mount.creatureId);
action.mount.modelId = 0;
}
else if (!sCreatureDisplayInfoStore.LookupEntry(action.mount.modelId))
{
sLog.outErrorDb("CreatureEventAI: Event %u Action %u uses nonexistent ModelId %u.", i, j+1, action.mount.modelId);
action.mount.modelId = 0;
}
}
}
break;
case ACTION_T_EVADE: //No Params
case ACTION_T_FLEE_FOR_ASSIST: //No Params
case ACTION_T_DIE: //No Params
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10364"
#define REVISION_NR "10365"
#endif // __REVISION_NR_H__
2 changes: 1 addition & 1 deletion src/shared/revision_sql.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef __REVISION_SQL_H__
#define __REVISION_SQL_H__
#define REVISION_DB_CHARACTERS "required_10332_02_characters_pet_aura"
#define REVISION_DB_MANGOS "required_10362_01_mangos_creature_movement_template"
#define REVISION_DB_MANGOS "required_10365_01_mangos_creature_ai_scripts"
#define REVISION_DB_REALMD "required_10008_01_realmd_realmd_db_version"
#endif // __REVISION_SQL_H__

0 comments on commit cdf5b03

Please sign in to comment.