Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SRB2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tatsuru
SRB2
Commits
2fda89f1
Commit
2fda89f1
authored
5 years ago
by
James R.
Browse files
Options
Downloads
Plain Diff
Merge branch 'bot-respawn-hook' into 'next'
BotRespawn hook See merge request
STJr/SRB2!804
parents
bd7d05fd
934808ef
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/b_bot.c
+15
-0
15 additions, 0 deletions
src/b_bot.c
src/lua_hook.h
+2
-0
2 additions, 0 deletions
src/lua_hook.h
src/lua_hooklib.c
+46
-0
46 additions, 0 deletions
src/lua_hooklib.c
with
63 additions
and
0 deletions
src/b_bot.c
+
15
−
0
View file @
2fda89f1
...
@@ -459,6 +459,21 @@ boolean B_CheckRespawn(player_t *player)
...
@@ -459,6 +459,21 @@ boolean B_CheckRespawn(player_t *player)
if
(
!
sonic
||
sonic
->
health
<=
0
)
if
(
!
sonic
||
sonic
->
health
<=
0
)
return
false
;
return
false
;
#ifdef HAVE_BLUA
// B_RespawnBot doesn't do anything if the condition above this isn't met
{
UINT8
shouldForce
=
LUAh_BotRespawn
(
sonic
,
tails
);
if
(
P_MobjWasRemoved
(
sonic
)
||
P_MobjWasRemoved
(
tails
))
return
(
shouldForce
==
1
);
// mobj was removed
if
(
shouldForce
==
1
)
return
true
;
else
if
(
shouldForce
==
2
)
return
false
;
}
#endif
// Check if Sonic is busy first.
// Check if Sonic is busy first.
// If he's doing any of these things, he probably doesn't want to see us.
// If he's doing any of these things, he probably doesn't want to see us.
if
(
sonic
->
player
->
pflags
&
(
PF_GLIDING
|
PF_SLIDING
|
PF_BOUNCING
)
if
(
sonic
->
player
->
pflags
&
(
PF_GLIDING
|
PF_SLIDING
|
PF_BOUNCING
)
...
...
This diff is collapsed.
Click to expand it.
src/lua_hook.h
+
2
−
0
View file @
2fda89f1
...
@@ -40,6 +40,7 @@ enum hook {
...
@@ -40,6 +40,7 @@ enum hook {
hook_JumpSpinSpecial
,
hook_JumpSpinSpecial
,
hook_BotTiccmd
,
hook_BotTiccmd
,
hook_BotAI
,
hook_BotAI
,
hook_BotRespawn
,
hook_LinedefExecute
,
hook_LinedefExecute
,
hook_PlayerMsg
,
hook_PlayerMsg
,
hook_HurtMsg
,
hook_HurtMsg
,
...
@@ -91,6 +92,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8
...
@@ -91,6 +92,7 @@ boolean LUAh_MobjDeath(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8
#define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air))
#define LUAh_JumpSpinSpecial(player) LUAh_PlayerHook(player, hook_JumpSpinSpecial) // Hook for P_DoJumpStuff (Spin button effect (mid-air))
boolean
LUAh_BotTiccmd
(
player_t
*
bot
,
ticcmd_t
*
cmd
);
// Hook for B_BuildTiccmd
boolean
LUAh_BotTiccmd
(
player_t
*
bot
,
ticcmd_t
*
cmd
);
// Hook for B_BuildTiccmd
boolean
LUAh_BotAI
(
mobj_t
*
sonic
,
mobj_t
*
tails
,
ticcmd_t
*
cmd
);
// Hook for B_BuildTailsTiccmd by skin name
boolean
LUAh_BotAI
(
mobj_t
*
sonic
,
mobj_t
*
tails
,
ticcmd_t
*
cmd
);
// Hook for B_BuildTailsTiccmd by skin name
boolean
LUAh_BotRespawn
(
mobj_t
*
sonic
,
mobj_t
*
tails
);
// Hook for B_CheckRespawn
boolean
LUAh_LinedefExecute
(
line_t
*
line
,
mobj_t
*
mo
,
sector_t
*
sector
);
// Hook for linedef executors
boolean
LUAh_LinedefExecute
(
line_t
*
line
,
mobj_t
*
mo
,
sector_t
*
sector
);
// Hook for linedef executors
boolean
LUAh_PlayerMsg
(
int
source
,
int
target
,
int
flags
,
char
*
msg
);
// Hook for chat messages
boolean
LUAh_PlayerMsg
(
int
source
,
int
target
,
int
flags
,
char
*
msg
);
// Hook for chat messages
boolean
LUAh_HurtMsg
(
player_t
*
player
,
mobj_t
*
inflictor
,
mobj_t
*
source
,
UINT8
damagetype
);
// Hook for hurt messages
boolean
LUAh_HurtMsg
(
player_t
*
player
,
mobj_t
*
inflictor
,
mobj_t
*
source
,
UINT8
damagetype
);
// Hook for hurt messages
...
...
This diff is collapsed.
Click to expand it.
src/lua_hooklib.c
+
46
−
0
View file @
2fda89f1
...
@@ -52,6 +52,7 @@ const char *const hookNames[hook_MAX+1] = {
...
@@ -52,6 +52,7 @@ const char *const hookNames[hook_MAX+1] = {
"JumpSpinSpecial"
,
"JumpSpinSpecial"
,
"BotTiccmd"
,
"BotTiccmd"
,
"BotAI"
,
"BotAI"
,
"BotRespawn"
,
"LinedefExecute"
,
"LinedefExecute"
,
"PlayerMsg"
,
"PlayerMsg"
,
"HurtMsg"
,
"HurtMsg"
,
...
@@ -1111,6 +1112,51 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
...
@@ -1111,6 +1112,51 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd)
return
hooked
;
return
hooked
;
}
}
// Hook for B_CheckRespawn
boolean
LUAh_BotRespawn
(
mobj_t
*
sonic
,
mobj_t
*
tails
)
{
hook_p
hookp
;
UINT8
shouldRespawn
=
0
;
// 0 = default, 1 = force yes, 2 = force no.
if
(
!
gL
||
!
(
hooksAvailable
[
hook_BotRespawn
/
8
]
&
(
1
<<
(
hook_BotRespawn
%
8
))))
return
false
;
lua_settop
(
gL
,
0
);
for
(
hookp
=
roothook
;
hookp
;
hookp
=
hookp
->
next
)
{
if
(
hookp
->
type
!=
hook_BotRespawn
)
continue
;
if
(
lua_gettop
(
gL
)
==
0
)
{
LUA_PushUserdata
(
gL
,
sonic
,
META_MOBJ
);
LUA_PushUserdata
(
gL
,
tails
,
META_MOBJ
);
}
lua_pushfstring
(
gL
,
FMT_HOOKID
,
hookp
->
id
);
lua_gettable
(
gL
,
LUA_REGISTRYINDEX
);
lua_pushvalue
(
gL
,
-
3
);
lua_pushvalue
(
gL
,
-
3
);
if
(
lua_pcall
(
gL
,
2
,
1
,
0
))
{
if
(
!
hookp
->
error
||
cv_debug
&
DBG_LUA
)
CONS_Alert
(
CONS_WARNING
,
"%s
\n
"
,
lua_tostring
(
gL
,
-
1
));
lua_pop
(
gL
,
1
);
hookp
->
error
=
true
;
continue
;
}
if
(
!
lua_isnil
(
gL
,
-
1
))
{
if
(
lua_toboolean
(
gL
,
-
1
))
shouldRespawn
=
1
;
// Force yes
else
shouldRespawn
=
2
;
// Force no
}
lua_pop
(
gL
,
1
);
}
lua_settop
(
gL
,
0
);
return
shouldRespawn
;
}
// Hook for linedef executors
// Hook for linedef executors
boolean
LUAh_LinedefExecute
(
line_t
*
line
,
mobj_t
*
mo
,
sector_t
*
sector
)
boolean
LUAh_LinedefExecute
(
line_t
*
line
,
mobj_t
*
mo
,
sector_t
*
sector
)
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment